Skip to content

Commit

Permalink
fix(node): disable name mangling when building for production
Browse files Browse the repository at this point in the history
disable name mangling when building for production with optimization on,
in order not to break
features relying on runtime reflection

ISSUES CLOSED: nrwl#8537
  • Loading branch information
Alexandre Delattre committed Jan 17, 2022
1 parent dcb839c commit a4d3d15
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/node/package.json
Expand Up @@ -51,6 +51,7 @@
"webpack": "^5.58.1",
"webpack-merge": "^5.8.0",
"webpack-node-externals": "^3.0.0",
"terser-webpack-plugin": "^5.1.1",
"rxjs-for-await": "0.0.2",
"ts-node": "~9.1.1"
}
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/utils/node.config.spec.ts
Expand Up @@ -53,6 +53,7 @@ describe('getNodePartial', () => {
});

expect(result.optimization.minimize).toEqual(true);
expect(result.optimization.minimizer).toBeDefined();
});

it('should concatenate modules', () => {
Expand Down
8 changes: 8 additions & 0 deletions packages/node/src/utils/node.config.ts
Expand Up @@ -5,6 +5,7 @@ import { merge } from 'webpack-merge';
import { getBaseWebpackPartial } from './config';
import { BuildNodeBuilderOptions } from './types';
import nodeExternals = require('webpack-node-externals');
import TerserPlugin = require('terser-webpack-plugin');

function getNodePartial(options: BuildNodeBuilderOptions) {
const webpackConfig: Configuration = {
Expand All @@ -18,6 +19,13 @@ function getNodePartial(options: BuildNodeBuilderOptions) {
if (options.optimization) {
webpackConfig.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: false,
},
}),
],
concatenateModules: true,
};
}
Expand Down

0 comments on commit a4d3d15

Please sign in to comment.