Skip to content

Try to only run one mangler at a time #204766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build/lib/mangle/index.js

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

7 changes: 6 additions & 1 deletion build/lib/mangle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,18 @@ export class Mangler {
private readonly log: typeof console.log = () => { },
private readonly config: { readonly manglePrivateFields: boolean; readonly mangleExports: boolean },
) {

this.renameWorkerPool = workerpool.pool(path.join(__dirname, 'renameWorker.js'), {
maxWorkers: 1,
minWorkers: 'max'
});
}

dispose() {
this.renameWorkerPool.terminate();
this.allClassDataByKey.clear();
this.allExportedSymbols.clear();
}

async computeNewFileContents(strictImplicitPublicHandling?: Set<string>): Promise<Map<string, MangleOutput>> {

const service = ts.createLanguageService(new StaticLanguageServiceHost(this.projectPath));
Expand Down
14 changes: 9 additions & 5 deletions extensions/mangle-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const { Mangler } = require('../build/lib/mangle/index');
*/
const mangleMap = new Map();

const sequentializer = Promise.resolve();

/**
* @param {string} projectPath
*/
Expand All @@ -26,7 +28,12 @@ function getMangledFileContents(projectPath) {
const log = (...data) => fancyLog(ansiColors.blue('[mangler]'), ...data);
log(`Mangling ${projectPath}`);
const ts2tsMangler = new Mangler(projectPath, log, { mangleExports: true, manglePrivateFields: true });
entry = ts2tsMangler.computeNewFileContents();
const mangleTask = () => {
return ts2tsMangler.computeNewFileContents().finally(() => {
ts2tsMangler.dispose();
});
};
entry = sequentializer.then(mangleTask, mangleTask);
mangleMap.set(projectPath, entry);
}

Expand All @@ -41,10 +48,7 @@ module.exports = async function (source, sourceMap, meta) {
// Only enable mangling in production builds
return source;
}
if (true) {
// disable mangling for now, SEE https://github.com/microsoft/vscode/issues/204692
return source;
}

const options = this.getOptions();
if (options.disabled) {
// Dynamically disabled
Expand Down
Loading