fix: avoid leaking @types/node
into client code
#1531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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