preactjs / preact-www

:book: Preact documentation website.
https://preactjs.com
MIT License
358 stars 500 forks source link

Aliasing documentation for importmaps misses test-util and jsx-runtime #1097

Closed schlichtanders closed 7 months ago

schlichtanders commented 7 months ago

On https://preactjs.com/guide/v10/getting-started#using-preact-with-htm-and-importmaps an importmap aliasing is defined as

<script type="importmap">
  {
    "imports": {
      "react": "https://esm.sh/preact@10.19.2/compat",
      "react-dom": "https://esm.sh/preact@10.19.2/compat"
    }
  }
</script>

This apparently leaves out two further aliases which are needed for package.json (parcel example in the same docs)

{
  "alias": {
    "react": "preact/compat",
    "react-dom/test-utils": "preact/test-utils",
    "react-dom": "preact/compat",
    "react/jsx-runtime": "preact/jsx-runtime"
  },
}

Are these two further aliases just not needed? If they are needed, how can they be supported in importmaps?

marvinhagemeister commented 7 months ago

The assumption is that most folks don't run tests in their browser. Since writing the compiled JSX output by hand most folks don't use the jsx-runtime either, and rather use htm instead.

rschristian commented 7 months ago

Exactly, those extra two aliases address tools that are quite unlikely to be used, hence why they're not included in the simple demo.

You can add them in if you want, they follow the same pattern, nothing unique.

schlichtanders commented 6 months ago

Thank you for your support