You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> [email protected] dev
> wxt
WXT 0.18.13 18:18:56
✔ Started dev server @ http://localhost:3000 18:18:56
ℹ Pre-rendering chrome-mv3 for development with Vite 5.3.4 18:18:56
✖ Command failed after 235 ms 18:18:56
[18:18:56] ERROR entrypoints/background.ts: Cannot use imported variable "z" outside the main function. See https://wxt.dev/guide/go-further/entrypoint-side-effects.html
at importEntrypointFile (node_modules/wxt/dist/cli.js:2656:13)
at async Object.importEntrypoint (node_modules/wxt/dist/cli.js:1118:18)
at async getBackgroundEntrypoint (node_modules/wxt/dist/cli.js:1805:27)
at async node_modules/wxt/dist/cli.js:1609:18
at async Promise.all (index 0)
at async findEntrypoints (node_modules/wxt/dist/cli.js:1597:23)
at async internalBuild (node_modules/wxt/dist/cli.js:3537:23)
at async buildAndOpenBrowser (node_modules/wxt/dist/cli.js:3868:28)
at async Object.start (node_modules/wxt/dist/cli.js:3833:9)
at async node_modules/wxt/dist/cli.js:4347:5
Ahh, I see. Added to #506, going to close this one as a duplicate.
For now, you should put the zod schemas in a different file and import them or define them inside the main function. Either option should work for the short-term.
Activity
aklinker1 commentedon Jul 15, 2024
Can you share code? Zod shouldn't cause any problems, I use it in several of my extensions.
HotariTobu commentedon Jul 17, 2024
Reproduction steps
Run
npx wxt init wxt-zod-sample -t vanilla --pm npm cd wxt-zod-sample npm install zodUpdate
Run
Result
aklinker1 commentedon Jul 17, 2024
Ahh, I see. Added to #506, going to close this one as a duplicate.
For now, you should put the zod schemas in a different file and import them or define them inside the
mainfunction. Either option should work for the short-term.HotariTobu commentedon Jul 17, 2024
The error occurs even if I define zod schemas in other script files and import them.
aklinker1 commentedon Jul 17, 2024
Don't use the schemas outside the main function and it will work
HotariTobu commentedon Jul 17, 2024
I avoided it by putting schemas files out of
entrypoints.Thank you.