Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ module.exports = {
},
},
{
files: ["rollup.config.js"],
files: ["rollup.config.js", "web-ext-config.mjs"],
parserOptions: {
sourceType: "module",
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function makeSourceCodeBundle(): Promise<void> {
"project.config.ts",
"rollup.config.js",
"tsconfig.json",
"web-ext-config.cjs",
"web-ext-config.mjs",
].map((file) => path.join(BASE_DIR, file));

const dirs = ["@types", "docs", "patches", "scripts", "src"];
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"exclude": [
"compiled*",
"html"
"html",
"web-ext-config.mjs"
]
}
19 changes: 0 additions & 19 deletions web-ext-config.cjs

This file was deleted.

28 changes: 28 additions & 0 deletions web-ext-config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createRequire } from "module";

// This config needs to be an ES module. web-ext loads it with `import()`, and on
// newer Node versions importing a `.cjs` file also exposes a `module.exports`
// named export, which web-ext then rejects: `The config option "module.exports"
// must be specified in camel case`. Reading project.config.ts still needs a
// CommonJS `require` (so the sucrase-node hook kicks in), hence createRequire.
const require = createRequire(import.meta.url);

const optionalRequire = require("optional-require")(require);

const config = require("./project.config").default;

const customConfig = optionalRequire("./custom.config.cjs") || {};

export default {
sourceDir: config.compiled,
artifactsDir: config.dist,
ignoreFiles: config.webextIgnoreFiles,
build: {
overwriteDest: true,
},
lint: {
warningsAsErrors: true,
},
run: customConfig.run || {},
sign: customConfig.sign || {},
};