Skip to content

Commit

Permalink
perf(webpack): babel should transpile only selected libraries
Browse files Browse the repository at this point in the history
If all node_modules are transpiled webpack works too slow on low-end hardware
  • Loading branch information
goooseman committed Jun 16, 2020
1 parent 1d0611f commit dbfe779
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config/webpack/config.webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ module.exports = {
},
{
test: /\.js$/,
// Transpiling node_modules is bad for the perfomance reasons
// But some libraries can contain non-es5 code
// So es5-check is used after production build to make sure no new libraries contain non-es5 code
exclude: [
new RegExp(
"node_modules\\" +
path.sep +
"(?!await-lock|react-youtube|socket.io-client)"
),
],
use: {
loader: "babel-loader",
options: {
Expand Down Expand Up @@ -95,6 +105,7 @@ module.exports = {
extensions: [".js", ".ts", ".tsx", ".json"],
alias: {
src: path.resolve(__dirname, "../../src/"),
debug: "debug-es5",
},
},
};
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"copy-webpack-plugin": "^6.0.2",
"css-loader": "^3.6.0",
"cssnano": "^4.1.10",
"debug-es5": "^4.1.0",
"dotenv-webpack": "^1.8.0",
"es-check": "^5.1.0",
"file-loader": "^6.0.0",
Expand Down

0 comments on commit dbfe779

Please sign in to comment.