-
Notifications
You must be signed in to change notification settings - Fork 182
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
shamefully-hoist breaks package isolation in a monorepo #286
Comments
I also use WXT in a pnpm monorepo, but we have an electron app that requires So I can look into fixing this in WXT as well. Right now, there are 2 dependencies that prevent it from working:
Unfortunately, I'm not an expert on PNPM and module resolution, so I don't know why only these two packages cause problems. But if you list those two dependencies in your $ pnpx wxt@latest init wxt-without-hoisting
$ cd wxt-without-hoisting
$ rm .npmrc
$ pnpm i
$ pnpm build
...
[vite]: Rollup failed to resolve import "webextension-polyfill" from "virtual:wxt-background?/Users/aklinker1/Development/local/wxt-without-hoisting/entrypoints/background.ts".
...
$ pnpm i webextension-polyfill
$ pnpm build
...
[vite]: Rollup failed to resolve import "@webext-core/match-patterns" from "virtual:wxt-background?/Users/aklinker1/Development/local/wxt-without-hoisting/entrypoints/background.ts".
...
$ pnpm i @webext-core/match-patterns
$ pnpm build
...
✔ Built extension
So I don't really know where to start with this... Nuxt solved their problems by listing |
Here's an issue for vite that talks more about it: vitejs/vite#324 And here's a issue that this was fixed in: preactjs/prefresh#75 Both talk about talk about packages importing a subdependency not listed in the library's package.json, but I do list |
Actually, I know what the problem is now.
The error says it's coming from a virtual input. These inputs are shipped with WXT, but are not bundled until build time. This means they're effectively apart of your project, not WXT. That means they can't import any package not listed in your project's Solution: Export any utilities from WXT and import them from WXT in these virtual entrypoints instead of from the 3rd party package directly. This may also work for |
@rsweeney21 Can you try out pnpm i -D [email protected] |
@aklinker1 I encountered this issue today using the package manager |
Ok, I'll merge and release this today then! |
Released in |
Today when I use
And my folder structure is
Is there any advice for solve it? |
@tesths Can you open a new issue? Your problem is unrelated to this issue |
Describe the bug
wxt adds shamefully-hoist=true to an .npmrc file in the folder of the wxt extension. However, this setting changes hoisting for the entire monorepo. After running pnpm install, pnpm shows the following warning:
Now the node_modules at the root of the monorepo has all modules from all packages in the monorepo hoisted. This breaks one of the main benefits of using pnpm.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
node_modules in root shouldn't have modules from my-app and my-ext
Environment
Additional context
I love wxt. It's incredible!
The text was updated successfully, but these errors were encountered: