Skip to content

Commit f2c27cc

Browse files
committed
Try to only run one mangler at a time
Also makes sure we clean up the workerpool after each run
1 parent 11b3889 commit f2c27cc

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

build/lib/mangle/index.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/mangle/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,18 @@ export class Mangler {
406406
private readonly log: typeof console.log = () => { },
407407
private readonly config: { readonly manglePrivateFields: boolean; readonly mangleExports: boolean },
408408
) {
409-
410409
this.renameWorkerPool = workerpool.pool(path.join(__dirname, 'renameWorker.js'), {
411410
maxWorkers: 1,
412411
minWorkers: 'max'
413412
});
414413
}
415414

415+
dispose() {
416+
this.renameWorkerPool.terminate();
417+
this.allClassDataByKey.clear();
418+
this.allExportedSymbols.clear();
419+
}
420+
416421
async computeNewFileContents(strictImplicitPublicHandling?: Set<string>): Promise<Map<string, MangleOutput>> {
417422

418423
const service = ts.createLanguageService(new StaticLanguageServiceHost(this.projectPath));

extensions/mangle-loader.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const { Mangler } = require('../build/lib/mangle/index');
1717
*/
1818
const mangleMap = new Map();
1919

20+
const sequentializer = Promise.resolve();
21+
2022
/**
2123
* @param {string} projectPath
2224
*/
@@ -26,7 +28,12 @@ function getMangledFileContents(projectPath) {
2628
const log = (...data) => fancyLog(ansiColors.blue('[mangler]'), ...data);
2729
log(`Mangling ${projectPath}`);
2830
const ts2tsMangler = new Mangler(projectPath, log, { mangleExports: true, manglePrivateFields: true });
29-
entry = ts2tsMangler.computeNewFileContents();
31+
const mangleTask = () => {
32+
return ts2tsMangler.computeNewFileContents().finally(() => {
33+
ts2tsMangler.dispose();
34+
});
35+
};
36+
entry = sequentializer.then(mangleTask, mangleTask);
3037
mangleMap.set(projectPath, entry);
3138
}
3239

@@ -41,10 +48,7 @@ module.exports = async function (source, sourceMap, meta) {
4148
// Only enable mangling in production builds
4249
return source;
4350
}
44-
if (true) {
45-
// disable mangling for now, SEE https://github.com/microsoft/vscode/issues/204692
46-
return source;
47-
}
51+
4852
const options = this.getOptions();
4953
if (options.disabled) {
5054
// Dynamically disabled

0 commit comments

Comments
 (0)