Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

aleclarson
Copy link
Contributor

@aleclarson aleclarson commented Mar 22, 2025

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 from wxt/src/types.ts, as it depends on Node.js-specific packages (like vite). This inadvertently introduces Node.js globals into the extension's client environment, which is undesirable (e.g. it breaks the return type of setTimeout).

Edit 1

Updated other "offending" imports. Split out the option-related types (into option-types.ts) and the client-related types (into client-types.ts).

Manual Testing

Without this change, you should see setTimeout return a NodeJS.Timeout object.

After this change, setTimeout will return a number as expected.

Related Issue

#1459

Copy link

netlify bot commented Mar 22, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 54b8603
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/67dedb998bb9b00008912f85
😎 Deploy Preview https://deploy-preview-1531--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aleclarson
Copy link
Contributor Author

I can retarget this to #1085 if you prefer. LMK!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant