mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
Fix extension private prop mangling when compiling all extensions (#167626)
Fix extension private prop mangling when compiling all projects #167269 Re-applies previous commit with a fix for html's custom webpack logic
This commit is contained in:
@@ -61,7 +61,7 @@ module.exports = function () {
|
||||
output: `"${escapeText(lines.join('\n'))}"`
|
||||
});
|
||||
|
||||
strResult = `\nconst libs : { [name:string]: string; } = {\n`
|
||||
let strResult = `\nconst libs : { [name:string]: string; } = {\n`
|
||||
for (let i = result.length - 1; i >= 0; i--) {
|
||||
strResult += `"${result[i].name}": ${result[i].output},\n`;
|
||||
}
|
||||
|
||||
@@ -4,26 +4,42 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
// @ts-check
|
||||
|
||||
const fs = require('fs');
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {webpack.LoaderDefinitionFunction}
|
||||
*/
|
||||
module.exports = async function (source, sourceMap, meta) {
|
||||
if (source !== fs.readFileSync(this.resourcePath).toString()) {
|
||||
// File content has changed by previous webpack steps.
|
||||
// Skip mangling.
|
||||
return source;
|
||||
}
|
||||
|
||||
const options = this.getOptions();
|
||||
const callback = this.async();
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user