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
If you use a module that imports/depends on webextension-polyfill, you must add the module to Vite's ssr.noExternal option in your vitest.config.ts file:
aklinker1
changed the title
[testing] Automatically detect dependencies that depend on webextension-polyfill and add them to the ssr option
[testing] Automatically detect dependencies to add to the ssr.noExternal option
Feb 21, 2024
aklinker1
changed the title
[testing] Automatically detect dependencies to add to the ssr.noExternal option
[testing] Detect dependencies to add to the ssr.noExternal option
Feb 21, 2024
Feature Request
If you use a module that imports/depends on
webextension-polyfill
, you must add the module to Vite'sssr.noExternal
option in yourvitest.config.ts
file:In this case,
@webext-core/storage
depends onwebextension-polyfill
, so it needs to be added.If you don't add it to
ssr
, you'll get errors like this:Caution
Error: This script should only be loaded in a browser extension
In theory, WXT should be able to perform an analysis of your dependencies, and add all of them automatically to
ssr
, like it does with WXT itself:wxt/src/core/builders/vite/plugins/webextensionPolyfillMock.ts
Lines 34 to 37 in 86b7162
You can see a list of dependencies that depend on
webextension-polyfill
usingpnpm list webextension-polyfill
:Not sure if there's an equivalent for other package managers.
Is your feature request related to a bug?
"N/A"
What are the alternatives?
Add better documentation around this requirement, it can be confusing to deal with. Will do both.
Additional context
wxt-dev/wxt-examples#15
The text was updated successfully, but these errors were encountered: