Fix extension private prop mangling when compiling all projects (#167464)

#167269
This commit is contained in:
Matt Bierner 2022-11-28 16:32:18 -08:00 committed by GitHub
parent cf01f3bb99
commit 725330a7cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 13 deletions

View file

@ -7,17 +7,26 @@
const webpack = require('webpack');
const { Mangler } = require('../build/lib/mangleTypeScript');
let map;
/**
* Map of project paths to mangled file contents
*
* @type {Map<string, Map<string, string>>}
*/
const mangleMap = new Map();
/**
* @param {string} projectPath
*/
function getMangledFileContents(projectPath) {
if (!map) {
let entry = mangleMap.get(projectPath);
if (!entry) {
console.log(`Mangling ${projectPath}`);
const ts2tsMangler = new Mangler(projectPath, console.log);
map = ts2tsMangler.computeNewFileContents();
entry = ts2tsMangler.computeNewFileContents();
mangleMap.set(projectPath, entry);
}
return map;
return entry;
}
/**

View file

@ -15,6 +15,13 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const { NLSBundlePlugin } = require('vscode-nls-dev/lib/webpack-bundler');
const { DefinePlugin, optimize } = require('webpack');
const tsLoaderOptions = {
compilerOptions: {
'sourceMap': true,
},
onlyCompileBundledFiles: true,
};
function withNodeDefaults(/**@type WebpackConfig*/extConfig) {
/** @type WebpackConfig */
const defaultConfig = {
@ -42,11 +49,7 @@ function withNodeDefaults(/**@type WebpackConfig*/extConfig) {
// configure TypeScript loader:
// * enable sources maps for end-to-end source maps
loader: 'ts-loader',
options: {
compilerOptions: {
'sourceMap': true,
}
}
options: tsLoaderOptions
}, {
loader: path.resolve(__dirname, 'mangle-loader.js'),
options: {
@ -125,11 +128,8 @@ function withBrowserDefaults(/**@type WebpackConfig*/extConfig, /** @type Additi
// * enable sources maps for end-to-end source maps
loader: 'ts-loader',
options: {
compilerOptions: {
'sourceMap': true,
},
...tsLoaderOptions,
...(additionalOptions ? {} : { configFile: additionalOptions.configFile }),
onlyCompileBundledFiles: true,
}
},
{