esm-dev / esm.sh

The no-build CDN for modern web development.
https://esm.sh
MIT License
3.19k stars 150 forks source link

Duplicate dependencies loaded #442

Closed marvinhagemeister closed 2 years ago

marvinhagemeister commented 2 years ago

Failing module

import { h, render } from "https://esm.sh/preact";
import { signal } from "https://esm.sh/@preact/signals@1.1.2";

const count = signal(0);

function Counter() {
  return h("div", {}, [
    h("p", {}, `Count: ${count}`),
    h("button", { onClick: () => count.value++ }, "click me"),
  ]);
}

render(h(Counter), document.getElementById("app"));

Error message

No explicit error message as esm.sh loads two different copies of Preact instead of latest. For some reason the signals import loads Preact 10.11.1 instead of the latest version 10.11.2.

ije commented 2 years ago

try to add ?deps options

import { h, render } from "https://esm.sh/preact@10.11.2";
import { signal } from "https://esm.sh/@preact/signals@1.1.2?deps=preact@10.11.2";

or use import maps to point out the preact specifier by adding the ?external=preact query:

{
  "imports": {
    "preact": "https://esm.sh/preact@10.11.2",
    "@preact/signals": "https://esm.sh/@preact/signals@1.1.2?external=preact"
  }
}