Make the web-ext config an ES module#115
Draft
LemonBreezes wants to merge 1 commit into
Draft
Conversation
web-ext loads its config file with `import()`. On newer Node versions, importing the `.cjs` config also exposes a `module.exports` named export, which web-ext rejects: `The config option "module.exports" must be specified in camel case`. That breaks `npm run build:firefox` before it can produce an .xpi. Renaming the config to `.mjs` with `export default` avoids the extra named export; project.config.ts is still loaded through the sucrase-node hook via `createRequire`. Update the eslint override, the tsconfig exclude and the source-bundle file list for the new name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
npm run build:firefoxfails for me at theweb-ext buildstep:web-ext loads
web-ext-config.cjswithimport(). On newer Node, importing a CommonJS module also exposes amodule.exportsnamed export next todefault, and web-ext's config loader spreads the named exports onto the config object and then rejects themodule.exportskey. (The same thing breaksweb-ext run, i.e.npm start.)Renaming the config to
.mjswithexport defaultavoids it — the import then only carriesdefault.project.config.tsis still read through the sucrase-node require hook viacreateRequire, so nothing else about the setup changes. I also pointed the eslintsourceTypeoverride, the tsconfigexclude, and the source-bundle file list at the new name.npm run build:firefoxandbuild:chromeboth produce artifacts withweb-ext lintclean (Node 24).