-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathbabel.config.js
More file actions
26 lines (23 loc) · 726 Bytes
/
Copy pathbabel.config.js
File metadata and controls
26 lines (23 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const MIN_BABEL_VERSION = 7;
export default (api) => {
api.assertVersion(MIN_BABEL_VERSION);
// Only the CommonJS build rewrites modules; the ESM build keeps them
const toCommonJs = api.env() === "cjs";
return {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "22.12.0",
},
modules: toCommonJs ? "commonjs" : false,
// Keep `import()` dynamic, a `stylelintPath` is only known at runtime
exclude: ["transform-dynamic-import"],
},
],
],
// `import.meta` has no CommonJS equivalent, so the CommonJS build needs it rewritten
plugins: toCommonJs ? ["babel-plugin-transform-import-meta"] : [],
};
};