deno icon indicating copy to clipboard operation
deno copied to clipboard

[[email protected]] unexpected js error with deno 2.0.1+

Open mindon opened this issue 1 year ago • 4 comments

Version: Deno 2.0.1+

https://github.com/denoland/fresh/issues/2714

jsr:@fresh/[email protected] works fine with Deno 2.0.0, but not 2.0.1+ with an js error

image

mindon avatar Oct 29 '24 09:10 mindon

That error always occurs when there are multiple instances of Preact being used at the same time. They don't know about each other. Running deno info main.ts might reveal where the other copy of Preact is getting pulled in.

marvinhagemeister avatar Oct 29 '24 10:10 marvinhagemeister

That error always occurs when there are multiple instances of Preact being used at the same time. They don't know about each other. Running deno info main.ts might reveal where the other copy of Preact is getting pulled in.

thanks.

jsr:@preact-icons/tb deps @preact-icons/common deps npm:preact@^10.22.1, while others such as @preact/[email protected] deps @preact/10.24.3

one more question is that the deno 2.0.0 works, and 2.0.1+ not, so i thought this would be a deno issue

multiple versions of deps is very common situation, it matters.

mindon avatar Oct 30 '24 03:10 mindon

@mindon is there a repo that you could share so we can try this case?

bartlomieju avatar Oct 31 '24 11:10 bartlomieju

it seems the issue comes from chunks import orders of preact-signals, NOT the multiple versions of Preact.

when i use a simple demo project with following islands/Counter.tsx there's only one chunk generated, everything is fine. the Symbol.for("preact-signals") is found in the middle of the only chunk js imported by Counter.js

but if i using the same Counter.tsx in my real project, Counter.js imports 4 chunk js, and Symbol.for("preact-signals") is the very beginning of the first chunk js, the js error happened! (Deno 2.0.1+), under Deno 2.0.0 there're 2 chunk js before the Symbol.for("preact-signals").

@bartlomieju here's how the output diff build with Deno 2.0.0 and 2.0.4 Counter_js-Deno_v2.0.0-vs-v2.0.4.zip

import { useSignal } from "@preact/signals";

export default function Counter() {
  const s = useSignal(1);
  return (
    <>
      <div>{ s.value }</div>
    </>
  );
}

mindon avatar Nov 01 '24 04:11 mindon

finaly, it's gone in Deno v2.1.6

mindon avatar Jan 17 '25 07:01 mindon