Skip to content

Commit d2dd59c

Browse files
authored
Merge branch 'master' into prompt_code_inside_wsl
2 parents 08580a4 + 96106db commit d2dd59c

93 files changed

Lines changed: 1381 additions & 769 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/gulpfile.extensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const tasks = compilations.map(function (tsconfigFile) {
119119
const watchTask = task.define(`watch-extension:${name}`, task.series(cleanTask, () => {
120120
const pipeline = createPipeline(false);
121121
const input = pipeline.tsProjectSrc();
122-
const watchInput = watcher(src, srcOpts);
122+
const watchInput = watcher(src, { ...srcOpts, ...{ readDelay: 200 } });
123123

124124
return watchInput
125125
.pipe(util.incremental(pipeline, input))

build/gulpfile.vscode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series(
9393
resources: vscodeResources,
9494
loaderConfig: common.loaderConfig(nodeModules),
9595
out: 'out-vscode',
96+
inlineAmdImages: true,
9697
bundleInfo: undefined
9798
})
9899
));

build/gulpfile.vscode.linux.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ function prepareSnapPackage(arch) {
238238

239239
function buildSnapPackage(arch) {
240240
const snapBuildPath = getSnapBuildPath(arch);
241-
return shell.task(`cd ${snapBuildPath} && snapcraft build`);
241+
// Default target for snapcraft runs: pull, build, stage and prime, and finally assembles the snap.
242+
return shell.task(`cd ${snapBuildPath} && snapcraft`);
242243
}
243244

244245
const BUILD_TARGETS = [

build/gulpfile.vscode.web.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const nodeModules = Object.keys(product.dependencies || {})
3434
const vscodeWebResources = [
3535

3636
// Workbench
37-
'out-build/vs/{base,platform,editor,workbench}/**/*.{svg,png,html}',
37+
'out-build/vs/{base,platform,editor,workbench}/**/*.{svg,png}',
38+
'out-build/vs/code/browser/workbench/workbench.html',
3839
'out-build/vs/base/browser/ui/octiconLabel/octicons/**',
3940
'out-build/vs/**/markdown.css',
4041

build/lib/compilation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function watchTask(out, build) {
8181
return function () {
8282
const compile = createCompile('src', build);
8383
const src = gulp.src('src/**', { base: 'src' });
84-
const watchSrc = watch('src/**', { base: 'src' });
84+
const watchSrc = watch('src/**', { base: 'src', readDelay: 200 });
8585
let generator = new MonacoGenerator(true);
8686
generator.execute();
8787
return watchSrc

build/lib/compilation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function watchTask(out: string, build: boolean): () => NodeJS.ReadWriteSt
9999
const compile = createCompile('src', build);
100100

101101
const src = gulp.src('src/**', { base: 'src' });
102-
const watchSrc = watch('src/**', { base: 'src' });
102+
const watchSrc = watch('src/**', { base: 'src', readDelay: 200 });
103103

104104
let generator = new MonacoGenerator(true);
105105
generator.execute();

build/lib/optimize.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'use strict';
66
Object.defineProperty(exports, "__esModule", { value: true });
77
const es = require("event-stream");
8+
const fs = require("fs");
89
const gulp = require("gulp");
910
const concat = require("gulp-concat");
1011
const minifyCSS = require("gulp-cssnano");
@@ -132,6 +133,14 @@ function optimizeTask(opts) {
132133
if (err || !result) {
133134
return bundlesStream.emit('error', JSON.stringify(err));
134135
}
136+
if (opts.inlineAmdImages) {
137+
try {
138+
result = inlineAmdImages(src, result);
139+
}
140+
catch (err) {
141+
return bundlesStream.emit('error', JSON.stringify(err));
142+
}
143+
}
135144
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
136145
// Remove css inlined resources
137146
const filteredResources = resources.slice();
@@ -167,6 +176,39 @@ function optimizeTask(opts) {
167176
};
168177
}
169178
exports.optimizeTask = optimizeTask;
179+
function inlineAmdImages(src, result) {
180+
for (const outputFile of result.files) {
181+
for (const sourceFile of outputFile.sources) {
182+
if (sourceFile.path && /\.js$/.test(sourceFile.path)) {
183+
sourceFile.contents = sourceFile.contents.replace(/\([^.]+\.registerAndGetAmdImageURL\(([^)]+)\)\)/g, (_, m0) => {
184+
let imagePath = m0;
185+
// remove `` or ''
186+
if ((imagePath.charAt(0) === '`' && imagePath.charAt(imagePath.length - 1) === '`')
187+
|| (imagePath.charAt(0) === '\'' && imagePath.charAt(imagePath.length - 1) === '\'')) {
188+
imagePath = imagePath.substr(1, imagePath.length - 2);
189+
}
190+
if (!/\.(png|svg)$/.test(imagePath)) {
191+
console.log(`original: ${_}`);
192+
return _;
193+
}
194+
const repoLocation = path.join(src, imagePath);
195+
const absoluteLocation = path.join(REPO_ROOT_PATH, repoLocation);
196+
if (!fs.existsSync(absoluteLocation)) {
197+
const message = `Invalid amd image url in file ${sourceFile.path}: ${imagePath}`;
198+
console.log(message);
199+
throw new Error(message);
200+
}
201+
const fileContents = fs.readFileSync(absoluteLocation);
202+
const mime = /\.svg$/.test(imagePath) ? 'image/svg+xml' : 'image/png';
203+
// Mark the file as inlined so we don't ship it by itself
204+
result.cssInlinedResources.push(repoLocation);
205+
return `("data:${mime};base64,${fileContents.toString('base64')}")`;
206+
});
207+
}
208+
}
209+
}
210+
return result;
211+
}
170212
/**
171213
* Wrap around uglify and allow the preserveComments function
172214
* to have a file "context" to include our copyright only once per file.
@@ -202,9 +244,6 @@ function uglifyWithCopyrights() {
202244
const output = input
203245
.pipe(flatmap((stream, f) => {
204246
return stream.pipe(minify({
205-
compress: {
206-
hoist_funs: true // required due to https://github.com/microsoft/vscode/issues/80202
207-
},
208247
output: {
209248
comments: preserveComments(f),
210249
max_line_len: 1024

build/lib/optimize.ts

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'use strict';
77

88
import * as es from 'event-stream';
9+
import * as fs from 'fs';
910
import * as gulp from 'gulp';
1011
import * as concat from 'gulp-concat';
1112
import * as minifyCSS from 'gulp-cssnano';
@@ -159,6 +160,10 @@ export interface IOptimizeTaskOpts {
159160
* (emit bundleInfo.json file)
160161
*/
161162
bundleInfo: boolean;
163+
/**
164+
* replace calls to `registerAndGetAmdImageURL` with data uris
165+
*/
166+
inlineAmdImages: boolean;
162167
/**
163168
* (out folder name)
164169
*/
@@ -192,6 +197,14 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
192197
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
193198
if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); }
194199

200+
if (opts.inlineAmdImages) {
201+
try {
202+
result = inlineAmdImages(src, result);
203+
} catch (err) {
204+
return bundlesStream.emit('error', JSON.stringify(err));
205+
}
206+
}
207+
195208
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
196209

197210
// Remove css inlined resources
@@ -236,6 +249,42 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
236249
};
237250
}
238251

252+
function inlineAmdImages(src: string, result: bundle.IBundleResult): bundle.IBundleResult {
253+
for (const outputFile of result.files) {
254+
for (const sourceFile of outputFile.sources) {
255+
if (sourceFile.path && /\.js$/.test(sourceFile.path)) {
256+
sourceFile.contents = sourceFile.contents.replace(/\([^.]+\.registerAndGetAmdImageURL\(([^)]+)\)\)/g, (_, m0) => {
257+
let imagePath = m0;
258+
// remove `` or ''
259+
if ((imagePath.charAt(0) === '`' && imagePath.charAt(imagePath.length - 1) === '`')
260+
|| (imagePath.charAt(0) === '\'' && imagePath.charAt(imagePath.length - 1) === '\'')) {
261+
imagePath = imagePath.substr(1, imagePath.length - 2);
262+
}
263+
if (!/\.(png|svg)$/.test(imagePath)) {
264+
console.log(`original: ${_}`);
265+
return _;
266+
}
267+
const repoLocation = path.join(src, imagePath);
268+
const absoluteLocation = path.join(REPO_ROOT_PATH, repoLocation);
269+
if (!fs.existsSync(absoluteLocation)) {
270+
const message = `Invalid amd image url in file ${sourceFile.path}: ${imagePath}`;
271+
console.log(message);
272+
throw new Error(message);
273+
}
274+
const fileContents = fs.readFileSync(absoluteLocation);
275+
const mime = /\.svg$/.test(imagePath) ? 'image/svg+xml' : 'image/png';
276+
277+
// Mark the file as inlined so we don't ship it by itself
278+
result.cssInlinedResources.push(repoLocation);
279+
280+
return `("data:${mime};base64,${fileContents.toString('base64')}")`;
281+
});
282+
}
283+
}
284+
}
285+
return result;
286+
}
287+
239288
declare class FileWithCopyright extends VinylFile {
240289
public __hasOurCopyright: boolean;
241290
}
@@ -278,9 +327,6 @@ function uglifyWithCopyrights(): NodeJS.ReadWriteStream {
278327
const output = input
279328
.pipe(flatmap((stream, f) => {
280329
return stream.pipe(minify({
281-
compress: {
282-
hoist_funs: true // required due to https://github.com/microsoft/vscode/issues/80202
283-
},
284330
output: {
285331
comments: preserveComments(<FileWithCopyright>f),
286332
max_line_len: 1024

build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"mime": "^1.3.4",
4141
"minimist": "^1.2.0",
4242
"request": "^2.85.0",
43-
"terser": "^4.2.1",
43+
"terser": "4.3.1",
4444
"tslint": "^5.9.1",
4545
"typescript": "3.6.2",
4646
"vsce": "1.48.0",

build/yarn.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ supports-color@^5.3.0:
21692169
dependencies:
21702170
has-flag "^3.0.0"
21712171

2172-
terser@*, terser@^4.2.1:
2172+
terser@*:
21732173
version "4.2.1"
21742174
resolved "https://registry.yarnpkg.com/terser/-/terser-4.2.1.tgz#1052cfe17576c66e7bc70fcc7119f22b155bdac1"
21752175
integrity sha512-cGbc5utAcX4a9+2GGVX4DsenG6v0x3glnDi5hx8816X1McEAwPlPgRtXPJzSBsbpILxZ8MQMT0KvArLuE0HP5A==
@@ -2178,6 +2178,15 @@ terser@*, terser@^4.2.1:
21782178
source-map "~0.6.1"
21792179
source-map-support "~0.5.12"
21802180

2181+
terser@4.3.1:
2182+
version "4.3.1"
2183+
resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.1.tgz#09820bcb3398299c4b48d9a86aefc65127d0ed65"
2184+
integrity sha512-pnzH6dnFEsR2aa2SJaKb1uSCl3QmIsJ8dEkj0Fky+2AwMMcC9doMqLOQIH6wVTEKaVfKVvLSk5qxPBEZT9mywg==
2185+
dependencies:
2186+
commander "^2.20.0"
2187+
source-map "~0.6.1"
2188+
source-map-support "~0.5.12"
2189+
21812190
through2@2.X, through2@^2.0.0, through2@^2.0.3:
21822191
version "2.0.3"
21832192
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"

0 commit comments

Comments
 (0)