- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: avoid leaking @types/node
into client code
#1531
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I can retarget this to #1085 if you prefer. LMK! |
I think that would be better as @aklinker1 should be merging 0.20.0 very soon as he rebased everything from main into it and we've been testing it |
0.20.0 is released and out so make sure to rebase your changes on main! |
54b8603
to
a6969b0
Compare
Rebased ✅ |
You can definitely avoid it. The key is to use multiple
This is off the top of my noggin, so could be missing a detail. I assume there isn't a demo with this setup already? |
Overview
The
defineWxtPlugin
function is referenced by the generated.wxt/types/imports.d.ts
module, which is used by client code. Therefore, we need to avoid importing fromwxt/src/types.ts
, as it depends on Node.js-specific packages (likevite
). This inadvertently introduces Node.js globals into the extension's client environment, which is undesirable (e.g. it breaks the return type ofsetTimeout
).Edit 1
Updated other "offending" imports. Split out the option-related types (into
option-types.ts
) and the client-related types (intoclient-types.ts
).Manual Testing
Without this change, you should see
setTimeout
return aNodeJS.Timeout
object.After this change,
setTimeout
will return a number as expected.Related Issue
#1459