Skip to content

Commit d8dcdb9

Browse files
authored
Merge pull request microsoft#184575 from microsoft/joh/protective-cicada
joh/protective cicada
2 parents 70daab7 + 978bb08 commit d8dcdb9

File tree

8 files changed

+79
-20
lines changed

8 files changed

+79
-20
lines changed

build/gulpfile.compile.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ const task = require('./lib/task');
1111
const compilation = require('./lib/compilation');
1212
const optimize = require('./lib/optimize');
1313

14-
// Full compile, including nls and inline sources in sourcemaps, for build
15-
const compileBuildTask = task.define('compile-build',
16-
task.series(
14+
function makeCompileBuildTask(disableMangle) {
15+
return task.series(
1716
util.rimraf('out-build'),
1817
util.buildWebNodePaths('out-build'),
1918
compilation.compileApiProposalNamesTask,
20-
compilation.compileTask('src', 'out-build', true),
19+
compilation.compileTask('src', 'out-build', true, { disableMangle }),
2120
optimize.optimizeLoaderTask('out-build', 'out-build', true)
22-
)
23-
);
21+
);
22+
}
23+
24+
// Full compile, including nls and inline sources in sourcemaps, mangling, minification, for build
25+
const compileBuildTask = task.define('compile-build', makeCompileBuildTask(false));
2426
gulp.task(compileBuildTask);
2527
exports.compileBuildTask = compileBuildTask;
28+
29+
// Full compile for PR ci, e.g no mangling
30+
const compileBuildTaskPullRequest = task.define('compile-build-pr', makeCompileBuildTask(true));
31+
gulp.task(compileBuildTaskPullRequest);
32+
exports.compileBuildTaskPullRequest = compileBuildTaskPullRequest;

build/gulpfile.extensions.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,22 @@ const cleanExtensionsBuildTask = task.define('clean-extensions-build', util.rimr
238238
const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series(
239239
cleanExtensionsBuildTask,
240240
task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream(false).pipe(gulp.dest('.build'))),
241-
task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream(false).pipe(gulp.dest('.build'))),
241+
task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream(false, false).pipe(gulp.dest('.build'))),
242242
));
243243

244244
gulp.task(compileExtensionsBuildTask);
245245
gulp.task(task.define('extensions-ci', task.series(compileExtensionsBuildTask, compileExtensionMediaBuildTask)));
246246

247+
const compileExtensionsBuildPullRequestTask = task.define('compile-extensions-build-pr', task.series(
248+
cleanExtensionsBuildTask,
249+
task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream(false).pipe(gulp.dest('.build'))),
250+
task.define('bundle-extensions-build-pr', () => ext.packageLocalExtensionsStream(false, true).pipe(gulp.dest('.build'))),
251+
));
252+
253+
gulp.task(compileExtensionsBuildPullRequestTask);
254+
gulp.task(task.define('extensions-ci-pr', task.series(compileExtensionsBuildPullRequestTask, compileExtensionMediaBuildTask)));
255+
256+
247257
exports.compileExtensionsBuildTask = compileExtensionsBuildTask;
248258

249259
//#endregion

build/gulpfile.vscode.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ const core = task.define('core-ci', task.series(
150150
));
151151
gulp.task(core);
152152

153+
const corePr = task.define('core-ci-pr', task.series(
154+
gulp.task('compile-build-pr'),
155+
task.parallel(
156+
gulp.task('minify-vscode'),
157+
gulp.task('minify-vscode-reh'),
158+
gulp.task('minify-vscode-reh-web'),
159+
)
160+
));
161+
gulp.task(corePr);
162+
153163
/**
154164
* Compute checksums for some files.
155165
*

build/gulpfile.vscode.web.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function packageTask(sourceFolderName, destinationFolderName) {
233233

234234
const compileWebExtensionsBuildTask = task.define('compile-web-extensions-build', task.series(
235235
task.define('clean-web-extensions-build', util.rimraf('.build/web/extensions')),
236-
task.define('bundle-web-extensions-build', () => extensions.packageLocalExtensionsStream(true).pipe(gulp.dest('.build/web'))),
236+
task.define('bundle-web-extensions-build', () => extensions.packageLocalExtensionsStream(true, false).pipe(gulp.dest('.build/web'))),
237237
task.define('bundle-marketplace-web-extensions-build', () => extensions.packageMarketplaceExtensionsStream(true).pipe(gulp.dest('.build/web'))),
238238
task.define('bundle-web-extension-media-build', () => extensions.buildExtensionMedia(false, '.build/web/extensions')),
239239
));

build/lib/extensions.js

Lines changed: 19 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/extensions.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ function updateExtensionPackageJSON(input: Stream, update: (data: any) => any):
6161
.pipe(packageJsonFilter.restore);
6262
}
6363

64-
function fromLocal(extensionPath: string, forWeb: boolean): Stream {
64+
function fromLocal(extensionPath: string, forWeb: boolean, disableMangle: boolean): Stream {
6565
const webpackConfigFileName = forWeb ? 'extension-browser.webpack.config.js' : 'extension.webpack.config.js';
6666

6767
const isWebPacked = fs.existsSync(path.join(extensionPath, webpackConfigFileName));
6868
let input = isWebPacked
69-
? fromLocalWebpack(extensionPath, webpackConfigFileName)
69+
? fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle)
7070
: fromLocalNormal(extensionPath);
7171

7272
if (isWebPacked) {
@@ -85,7 +85,7 @@ function fromLocal(extensionPath: string, forWeb: boolean): Stream {
8585
}
8686

8787

88-
function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string): Stream {
88+
function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string, disableMangle: boolean): Stream {
8989
const vsce = require('@vscode/vsce') as typeof import('@vscode/vsce');
9090
const webpack = require('webpack');
9191
const webpackGulp = require('webpack-stream');
@@ -141,6 +141,19 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string):
141141
...config,
142142
...{ mode: 'production' }
143143
};
144+
if (disableMangle) {
145+
if (Array.isArray(config.module.rules)) {
146+
for (const rule of config.module.rules) {
147+
if (Array.isArray(rule.use)) {
148+
for (const use of rule.use) {
149+
if (String(use.loader).endsWith('mangle-loader.js')) {
150+
use.options.disabled = true;
151+
}
152+
}
153+
}
154+
}
155+
}
156+
}
144157
const relativeOutputPath = path.relative(extensionPath, webpackConfig.output.path);
145158

146159
return webpackGulp(webpackConfig, webpack, webpackDone)
@@ -318,7 +331,7 @@ function isWebExtension(manifest: IExtensionManifest): boolean {
318331
return true;
319332
}
320333

321-
export function packageLocalExtensionsStream(forWeb: boolean): Stream {
334+
export function packageLocalExtensionsStream(forWeb: boolean, disableMangle: boolean): Stream {
322335
const localExtensionsDescriptions = (
323336
(<string[]>glob.sync('extensions/*/package.json'))
324337
.map(manifestPath => {
@@ -334,7 +347,7 @@ export function packageLocalExtensionsStream(forWeb: boolean): Stream {
334347
const localExtensionsStream = minifyExtensionResources(
335348
es.merge(
336349
...localExtensionsDescriptions.map(extension => {
337-
return fromLocal(extension.path, forWeb)
350+
return fromLocal(extension.path, forWeb, disableMangle)
338351
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
339352
})
340353
)

extensions/mangle-loader.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ module.exports = async function (source, sourceMap, meta) {
4141
// Only enable mangling in production builds
4242
return source;
4343
}
44+
const options = this.getOptions();
45+
if (options.disabled) {
46+
// Dynamically disabled
47+
return source;
48+
}
4449

4550
if (source !== fs.readFileSync(this.resourcePath).toString()) {
4651
// File content has changed by previous webpack steps.
4752
// Skip mangling.
4853
return source;
4954
}
5055

51-
const options = this.getOptions();
5256
const callback = this.async();
5357

5458
const fileContentsMap = getMangledFileContents(options.configFile);

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
"minify-vscode-reh-web": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js minify-vscode-reh-web",
5858
"hygiene": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js hygiene",
5959
"core-ci": "node --max_old_space_size=8095 ./node_modules/gulp/bin/gulp.js core-ci",
60+
"core-ci-pr": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js core-ci-pr",
6061
"extensions-ci": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js extensions-ci",
62+
"extensions-ci-pr": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js extensions-ci-pr",
6163
"perf": "node scripts/code-perf.js"
6264
},
6365
"dependencies": {

0 commit comments

Comments
 (0)