Skip to content

Commit d6331e3

Browse files
authored
⬆️ Webpack, Babel 更新至 ES2015+ (#1001)
* [MV2] Webpack, Babel 更新至 ES2015+ * [MV2] Webpack, Babel 更新至 ES2015+ * 可以只在 webpack.config.ts ,都会merge这个公共配置的
1 parent c13b502 commit d6331e3

4 files changed

Lines changed: 36 additions & 7 deletions

File tree

babel.config.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ module.exports = {
33
[
44
"@babel/preset-env",
55
{
6-
corejs: {
7-
version: 3,
8-
},
6+
corejs: 3,
97
useBuiltIns: "entry",
10-
targets: "> 0.1%, last 2 versions, Firefox ESR, not dead",
8+
targets: { esmodules: true }, // modern browsers (all ES2015+)
9+
// targets: "> 0.1%, last 2 versions, Firefox ESR, not dead",
10+
bugfixes: true, // for tiny browser specific fixes
11+
// modules: false, // for webpack
1112
},
1213
],
1314
"@babel/preset-react",
1415
"@babel/preset-typescript",
1516
],
1617
plugins: [
17-
"@babel/plugin-transform-runtime",
18-
["@babel/plugin-proposal-decorators", { legacy: true }],
18+
"@babel/plugin-transform-runtime", // helpers only, no corejs here
19+
["@babel/plugin-proposal-decorators", { legacy: true }], // only if you use them
1920
],
2021
};

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@emotion/react": "^11.10.4",
3030
"@emotion/styled": "^11.10.4",
3131
"axios": "^1.4.0",
32+
"core-js": "^3.47.0",
3233
"cron": "^2.4.4",
3334
"crx": "^5.0.1",
3435
"crypto-js": "^4.2.0",
@@ -109,4 +110,4 @@
109110
"webpack-cli": "^5.1.4",
110111
"webpack-merge": "^5.9.0"
111112
}
112-
}
113+
}

webpack.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ const config: Configuration = {
3131
path: `${dist}/ext/src`,
3232
filename: "[name].js",
3333
clean: true,
34+
// min versions: Chrome 62, Firefox 57, Safari 11.1, Edge 79 (ES2015+)
35+
environment: {
36+
// The environment supports arrow functions ('() => { ... }').
37+
arrowFunction: true,
38+
// The environment supports async function and await ('async function () { await ... }').
39+
asyncFunction: true,
40+
// The environment supports const and let for variable declarations.
41+
const: true,
42+
// The environment supports destructuring ('{ a, b } = obj').
43+
destructuring: true,
44+
// The environment supports 'for of' iteration ('for (const x of array) { ... }').
45+
forOf: true,
46+
// The environment supports template literals.
47+
templateLiteral: true,
48+
}
3449
},
3550
plugins: [
3651
new HtmlWebpackPlugin({

0 commit comments

Comments
 (0)