Skip to content

Commit fc53087

Browse files
clydinvikerman
authored andcommitted
refactor(@angular-devkit/build-angular): add debug no mangle environment variable
1 parent c867f2a commit fc53087

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import { RawSource } from 'webpack-sources';
2424
import { AssetPatternClass, ExtraEntryPoint } from '../../../browser/schema';
2525
import { BuildBrowserFeatures, fullDifferential } from '../../../utils';
26+
import { manglingDisabled } from '../../../utils/mangle-options';
2627
import { BundleBudgetPlugin } from '../../plugins/bundle-budget';
2728
import { CleanCssWebpackPlugin } from '../../plugins/cleancss-webpack-plugin';
2829
import { NamedLazyChunksPlugin } from '../../plugins/named-chunks-plugin';
@@ -362,6 +363,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
362363
// We also want to avoid mangling on server.
363364
// Name mangling is handled within the browser builder
364365
mangle:
366+
!manglingDisabled &&
365367
buildOptions.platform !== 'server' &&
366368
(!differentialLoadingNeeded || (differentialLoadingNeeded && fullDifferential)),
367369
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
const mangleVariable = process.env['NG_BUILD_MANGLE'];
9+
export const manglingDisabled =
10+
!!mangleVariable && (mangleVariable === '0' || mangleVariable.toLowerCase() === 'false');

packages/angular_devkit/build_angular/src/utils/process-bundle.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as fs from 'fs';
99
import * as path from 'path';
1010
import { SourceMapConsumer, SourceMapGenerator } from 'source-map';
1111
import { minify } from 'terser';
12+
import { manglingDisabled } from './mangle-options';
1213

1314
const { transformAsync } = require('@babel/core');
1415
const cacache = require('cacache');
@@ -134,7 +135,7 @@ async function processWorker(options: ProcessBundleOptions): Promise<void> {
134135
const result = minify(code, {
135136
compress: false,
136137
ecma: 5,
137-
mangle: true,
138+
mangle: !manglingDisabled,
138139
safari10: true,
139140
toplevel: true,
140141
output: {
@@ -184,7 +185,7 @@ async function mangleOriginal(options: ProcessBundleOptions): Promise<void> {
184185
const resultOriginal = minify(options.code, {
185186
compress: false,
186187
ecma: 6,
187-
mangle: true,
188+
mangle: !manglingDisabled,
188189
safari10: true,
189190
output: {
190191
ascii_only: true,

0 commit comments

Comments
 (0)