-
-
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
Build fails if doing destructuring assignment outside of the define function of entrypoints #1485
Comments
You should put your runtime code inside the main function, see this for a complete explanation of why: But, this might still be a bug, and could be a valid use-case. Can you share the debug output? wxt build --debug |
I understand that the runtime code must be placed in the main function, OK.
|
Yeah, it's a bug. You can see in the transformed code, WXT is removing the https://github.com/wxt-dev/wxt/blob/main/packages%2Fwxt%2Fsrc%2Fcore%2Futils%2Ftransform.ts#L10 |
Describe the bug
In the entrypoints, if a destructuring assignment is performed outside of the define function and references that variable, the build fails.
Reproduction
For example, the code that fails in
entrypoints/background.ts
is as follows:The build failure message is as follows:
However, if the variable reference is within a define function, it succeeds.
Or, if no destructuring assignment is done, it will succeed.
In the success example, it can be seen that the value is output to the console.
Steps to reproduce
This can be seen immediately on the demo project created by
npx wxt@latest init
.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: