Skip to content

Commit c4a8491

Browse files
clydinvikerman
authored andcommitted
fix(@angular-devkit/build-angular): prevent differential loading double sourcemap search
This can drastically reduce memory usage; especially in cases where bundled code modules contain individual sourcemap comments and vendor sourcemaps are disabled. Enabling the vendor sourcemap option has the side effect of removing all individual module sourcemap comments and as a result removes the potential for those comments to be found and processed.
1 parent f08d79b commit c4a8491

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,16 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
115115
const mapSize = options.map ? Buffer.byteLength(options.map) : 0;
116116
const manualSourceMaps = codeSize >= 500 * 1024 || mapSize >= 500 * 1024;
117117
const sourceCode = options.code;
118-
const sourceMap = options.map ? JSON.parse(options.map) : undefined;
118+
const sourceMap = options.map ? JSON.parse(options.map) : false;
119119

120120
let downlevelCode;
121121
let downlevelMap;
122122
if (downlevel) {
123123
// Downlevel the bundle
124124
const transformResult = await transformAsync(sourceCode, {
125125
filename: options.filename,
126-
inputSourceMap: manualSourceMaps ? undefined : sourceMap,
126+
// using false ensures that babel will NOT search and process sourcemap comments (large memory usage)
127+
inputSourceMap: manualSourceMaps ? false : sourceMap,
127128
babelrc: false,
128129
presets: [[
129130
require.resolve('@babel/preset-env'),

0 commit comments

Comments
 (0)