Skip to content

Make the web-ext config an ES module#115

Draft
LemonBreezes wants to merge 1 commit into
lydell:mainfrom
LemonBreezes:esm-web-ext-config
Draft

Make the web-ext config an ES module#115
LemonBreezes wants to merge 1 commit into
lydell:mainfrom
LemonBreezes:esm-web-ext-config

Conversation

@LemonBreezes
Copy link
Copy Markdown

npm run build:firefox fails for me at the web-ext build step:

UsageError: The config option "module.exports" must be specified in camel case: "moduleExports"

web-ext loads web-ext-config.cjs with import(). On newer Node, importing a CommonJS module also exposes a module.exports named export next to default, and web-ext's config loader spreads the named exports onto the config object and then rejects the module.exports key. (The same thing breaks web-ext run, i.e. npm start.)

Renaming the config to .mjs with export default avoids it — the import then only carries default. project.config.ts is still read through the sucrase-node require hook via createRequire, so nothing else about the setup changes. I also pointed the eslint sourceType override, the tsconfig exclude, and the source-bundle file list at the new name.

npm run build:firefox and build:chrome both produce artifacts with web-ext lint clean (Node 24).

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.
@LemonBreezes LemonBreezes marked this pull request as draft June 6, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant