fresh
fresh copied to clipboard
Incorrect transpilation makes DevTools check always falsy
// This is wrong.
typeof Deno < "u" && window.__PREACT_DEVTOOLS__ && window.__PREACT_DEVTOOLS__.attachPreact("10.15.1", d, {
Fragment: A,
Component: T
});
Could esm.sh
be serving up a Deno target and rewriting the modules here? It was added 3 weeks ago.
Hypothesis is that esbuild performs imports using the Deno http agent, which has a Deno/
user agent. esm.sh
checks the user agent and sets the target to denonext
here which causes imported modules to have typeof window
string replaced, incorrectly, with typeof Deno
. This would break any code destined for the browser.
I tried specifying a target on the import and it does seem to resolve the issue. For example:
- import docsearch from "https://esm.sh/@docsearch/js@3";
+ import docsearch from "https://esm.sh/@docsearch/js@3?target=esnext";
Any updates or insight on this issue? I was able to load Preact devtools after changing the import map to include npm:preact/debug
and npm:preact/devtools
; however, I cannot get past a message that says:
Connected, listening for Preact operations... If this message doesn't go away Preact started rendering before devtools was initialized. You can fix this by adding the
preact/debug
orpreact/devtools
import at the top of your entry file.
I added these imports to the top of dev.ts
to no avail. I tried injecting the import to the main entry through a Fresh plugin too, but that also had no effect.
The preact/debug
import is already injected by Fresh. No need to manually add it. I haven't checked yet with npm:
imports, but that's no my to do list.
Happy to report that dev tools work in Fresh 1.5.1 with Preact 10.18.1 🙌