Repository navigation
Description
Describe the bug
I have a content script which has a react code.
I have created constant file from which i export window variable.
the wxt prepare command fails
Error logs
> wxt prepare
WXT 0.19.0 5:51:11 PM
ℹ Generating types... 5:51:13 PM
✖ Command failed after 3.837 s 5:51:15 PM
ERROR window is not defined 5:51:15 PM
at entrypoints/content/constant.ts:1:21
at ViteNodeRunner.runModule (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:399:11)
at ViteNodeRunner.directRequest (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:381:16)
at ViteNodeRunner.cachedRequest (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:206:14)
at ViteNodeRunner.dependencyRequest (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:259:12)
at entrypoints/content/App.tsx:3:31
at ViteNodeRunner.runModule (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:399:5)
at ViteNodeRunner.directRequest (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:381:5)
at ViteNodeRunner.cachedRequest (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:206:14)
at ViteNodeRunner.dependencyRequest (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite-node/dist/client.mjs:259:12)
Reproduction
Steps to reproduce
pnpm i
System Info
System:
OS: macOS 14.5
CPU: (8) arm64 Apple M1
Memory: 65.75 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.15.0/bin/npm
pnpm: 9.6.0 - ~/.nvm/versions/node/v20.15.0/bin/pnpm
Watchman: 2024.06.10.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 127.1.68.128
Edge: 127.0.2651.74
Safari: 17.5
npmPackages:
wxt: ^0.19.0 => 0.19.0Used Package Manager
pnpm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
No labels
Activity
aiktb commentedon Jul 26, 2024
I have the same issue, the side effect of the import statement is triggered in v0.19.0, but not in v.0.18.0.
Timeraa commentedon Jul 26, 2024
Pinged @aklinker1 about this in the Discord but seems to be an issue from the move to tsup, same behaviour with
selfaklinker1 commentedon Jul 26, 2024
@aiktb @Timeraa @mehimanshupatil Can you guys try out
[email protected]and let me know if it works for you?Just an FYI - you shouldn't be using browser environment globals, like
windoworself, outside themainfunction of an entrypoint. In this new version, I made it so most browser environment globals are at least defined, but you will still run into issues with things likewindow.location.href, because I didn't implement all the APIs.aiktb commentedon Jul 27, 2024
Fixed.👍
Thank you for your answer, I have a Selector Class, in which the static member new a Class with a
document.querySelectoroperation, and that is the problem.mehimanshupatil commentedon Jul 27, 2024
getting error when running prepare
aklinker1 commentedon Jul 27, 2024
@mehimanshupatil Interesting, could you share your project?
mehimanshupatil commentedon Jul 27, 2024
@aklinker1
its reproducible on Reproduction repo
https://github.com/mehimanshupatil/wxt-example
tried running by removing
window.location.hrefimport but stillReceived protocol 'virtual:'error is thrownaklinker1 commentedon Jul 27, 2024
Yup, got it now, thanks. Looks like
vite-nodedoesn't like thewxt/clientimport because it eventually importsvirtual:app-config... For now,[email protected]fixes this for your case, but I need to do additional work before releasing 0.19.1 based on this feedback and this thread: #866mehimanshupatil commentedon Jul 27, 2024
cool window error is resolved
another error related to scss file import
when scss file is imported in
index.tsxerror is thrown[sass] Cannot read properties of undefined (reading 'pop')have updated Reproduction repo to reproduce sass erorr
aklinker1 commentedon Jul 27, 2024
Ok, sounds good! Thanks for helping me test this out btw 🙏
aklinker1 commentedon Jul 27, 2024
@mehimanshupatil Sass error fixed in
0.19.1-alpha3, confirmed with your latest reproduction.aklinker1 commentedon Jul 27, 2024
Fixes released in
v0.19.1. If people are still having problems, feel free to re-open or create another issue!