I'm trying to use Snowpack to compile a WebExtension that has a background script that uses code from the npm Registry, but I'm getting some weird errors trying to run it:
$ npx snowpack build --watch --verbose
[17:03:34] [snowpack] run command: build
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\EdingtonJames\Desktop\cerdicator\node_modules\web-ext\index.js
require() of ES modules is not supported.
require() of C:\Users\EdingtonJames\Desktop\cerdicator\node_modules\web-ext\index.js from C:\Users\EdingtonJames\Desktop\cerdicator\node_modules\snowpack-plugin-web-ext\dist-node\index.js is a
n ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename C:\Users\EdingtonJames\Desktop\cerdicator\node_modules\web-ext\index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\Eding
tonJames\Desktop\cerdicator\node_modules\web-ext\package.json.
at new NodeError (node:internal/errors:363:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1126:13)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (C:\Users\EdingtonJames\Desktop\cerdicator\node_modules\snowpack-plugin-web-ext\dist-node\index.js:7:14)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at Object.require [as NATIVE_REQUIRE] (node:internal/modules/cjs/helpers:93:18)
at loadPluginFromConfig (C:\Users\EdingtonJames\Desktop\cerdicator\node_modules\snowpack\lib\cjs\config.js:286:34)
at C:\Users\EdingtonJames\Desktop\cerdicator\node_modules\snowpack\lib\cjs\config.js:316:24
at Array.forEach (<anonymous>)
If background scripts are currently supported by this tool, could you include a minimum viable codebase example, like the one that you've currently got that demos browser actions? (Or are browser actions are the only extension page type currently supported?)
I'm trying to use Snowpack to compile a WebExtension that has a background script that uses code from the npm Registry, but I'm getting some weird errors trying to run it:
The codebase I'm trying this on can currently be got via:
If background scripts are currently supported by this tool, could you include a minimum viable codebase example, like the one that you've currently got that demos browser actions? (Or are browser actions are the only extension page type currently supported?)