You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change import version from latest to direct version (for example 10.5.13)
import { h, render } from "https://unpkg.com/[email protected]?module";
import { useState } from "https://unpkg.com/[email protected]/hooks/dist/hooks.mjs?module";
Erorr in console
Expected behavior
hooks.mjs shouldn't import latest version of preact for direct (and oldest) version. It should use the version actually requested
Incorrect:
The text was updated successfully, but these errors were encountered:
vyushin
changed the title
hooks.mjs always imports @latest version of preact
hooks.mjs imports @latest version of preact for direct (and oldest) versions.
Mar 21, 2021
So that's not actually something done here. preact/hooks doesn't necessarily depend on the latest version of preact. It only lists Preact v^10.0.0 as a peerDep:
In this situation, it's up to Unpkg to choose how to supply that peer dependency, and I guess it chooses the latest version.
It might be possible to just tie the versions together, i.e., preact/hooks v10.5.13 has a peerDep on preact v10.5.13, but I don't know if that's going to pop up to cause issues somewhere.
The issue has open for a long while over at unpkg and it's therefore probably unlikely that they'll fix it. So the only solution is to switch to a CDN that does follow the module spec. The current popular ones are either https://www.skypack.dev/ or https://npm.reversehttp.com/ .
https://codesandbox.io/s/serverless-resonance-spus5
Describe the bug
Preact hooks script is importing latest version of preact for every version. It makes conflicts for instances.
To Reproduce
https://codesandbox.io/s/serverless-resonance-spus5?file=/index.html
Steps to reproduce the behavior:
Expected behavior
hooks.mjs shouldn't import latest version of preact for direct (and oldest) version. It should use the version actually requested
Incorrect:
The text was updated successfully, but these errors were encountered: