Skip to content

Commit 8d3200b

Browse files
authored
Merge branch 'master' into monaco/ci
2 parents 25d4fa5 + b5ce601 commit 8d3200b

86 files changed

Lines changed: 756 additions & 1501 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.editor.js

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ var BUNDLED_FILE_HEADER = [
5757
const languages = i18n.defaultLanguages.concat([]); // i18n.defaultLanguages.concat(process.env.VSCODE_QUALITY !== 'stable' ? i18n.extraLanguages : []);
5858

5959
const extractEditorSrcTask = task.define('extract-editor-src', () => {
60-
console.log(`If the build fails, consider tweaking shakeLevel below to a lower value.`);
6160
const apiusages = monacoapi.execute().usageContent;
6261
const extrausages = fs.readFileSync(path.join(root, 'build', 'monaco', 'monaco.usage.recipe')).toString();
6362
standalone.extractEditor({
@@ -71,14 +70,6 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
7170
apiusages,
7271
extrausages
7372
],
74-
typings: [
75-
'typings/lib.ie11_safe_es6.d.ts',
76-
'typings/thenable.d.ts',
77-
'typings/es6-promise.d.ts',
78-
'typings/require-monaco.d.ts',
79-
"typings/lib.es2018.promise.d.ts",
80-
'vs/monaco.d.ts'
81-
],
8273
libs: [
8374
`lib.es5.d.ts`,
8475
`lib.dom.d.ts`,
@@ -138,18 +129,70 @@ const createESMSourcesAndResourcesTask = task.define('extract-editor-esm', () =>
138129
});
139130

140131
const compileEditorESMTask = task.define('compile-editor-esm', () => {
132+
console.log(`Launching the TS compiler at ${path.join(__dirname, '../out-editor-esm')}...`);
133+
let result;
141134
if (process.platform === 'win32') {
142-
const result = cp.spawnSync(`..\\node_modules\\.bin\\tsc.cmd`, {
135+
result = cp.spawnSync(`..\\node_modules\\.bin\\tsc.cmd`, {
143136
cwd: path.join(__dirname, '../out-editor-esm')
144137
});
145-
console.log(result.stdout.toString());
146-
console.log(result.stderr.toString());
147138
} else {
148-
const result = cp.spawnSync(`node`, [`../node_modules/.bin/tsc`], {
139+
result = cp.spawnSync(`node`, [`../node_modules/.bin/tsc`], {
149140
cwd: path.join(__dirname, '../out-editor-esm')
150141
});
151-
console.log(result.stdout.toString());
152-
console.log(result.stderr.toString());
142+
}
143+
144+
console.log(result.stdout.toString());
145+
console.log(result.stderr.toString());
146+
147+
if (result.status !== 0) {
148+
console.log(`The TS Compilation failed, preparing analysis folder...`);
149+
const destPath = path.join(__dirname, '../../vscode-monaco-editor-esm-analysis');
150+
return util.rimraf(destPath)().then(() => {
151+
fs.mkdirSync(destPath);
152+
153+
// initialize a new repository
154+
cp.spawnSync(`git`, [`init`], {
155+
cwd: destPath
156+
});
157+
158+
// build a list of files to copy
159+
const files = util.rreddir(path.join(__dirname, '../out-editor-esm'));
160+
161+
// copy files from src
162+
for (const file of files) {
163+
const srcFilePath = path.join(__dirname, '../src', file);
164+
const dstFilePath = path.join(destPath, file);
165+
if (fs.existsSync(srcFilePath)) {
166+
util.ensureDir(path.dirname(dstFilePath));
167+
const contents = fs.readFileSync(srcFilePath).toString().replace(/\r\n|\r|\n/g, '\n');
168+
fs.writeFileSync(dstFilePath, contents);
169+
}
170+
}
171+
172+
// create an initial commit to diff against
173+
cp.spawnSync(`git`, [`add`, `.`], {
174+
cwd: destPath
175+
});
176+
177+
// create the commit
178+
cp.spawnSync(`git`, [`commit`, `-m`, `"original sources"`, `--no-gpg-sign`], {
179+
cwd: destPath
180+
});
181+
182+
// copy files from esm
183+
for (const file of files) {
184+
const srcFilePath = path.join(__dirname, '../out-editor-esm', file);
185+
const dstFilePath = path.join(destPath, file);
186+
if (fs.existsSync(srcFilePath)) {
187+
util.ensureDir(path.dirname(dstFilePath));
188+
const contents = fs.readFileSync(srcFilePath).toString().replace(/\r\n|\r|\n/g, '\n');
189+
fs.writeFileSync(dstFilePath, contents);
190+
}
191+
}
192+
193+
console.log(`Open in VS Code the folder at '${destPath}' and you can alayze the compilation error`);
194+
throw new Error('Standalone Editor compilation failed. If this is the build machine, simply launch `yarn run gulp editor-distro` on your machine to further analyze the compilation problem.');
195+
});
153196
}
154197
});
155198

build/lib/i18n.resources.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"project": "vscode-workbench"
144144
},
145145
{
146-
"name": "vs/workbench/contrib/stats",
146+
"name": "vs/workbench/contrib/tags",
147147
"project": "vscode-workbench"
148148
},
149149
{

build/lib/standalone.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ function extractEditor(options) {
4747
compilerOptions.declaration = false;
4848
compilerOptions.moduleResolution = ts.ModuleResolutionKind.Classic;
4949
options.compilerOptions = compilerOptions;
50-
console.log(`Running with shakeLevel ${tss.toStringShakeLevel(options.shakeLevel)}`);
50+
console.log(`Running tree shaker with shakeLevel ${tss.toStringShakeLevel(options.shakeLevel)}`);
51+
// Take the extra included .d.ts files from `tsconfig.monaco.json`
52+
options.typings = tsConfig.include.filter(includedFile => /\.d\.ts$/.test(includedFile));
5153
let result = tss.shake(options);
5254
for (let fileName in result) {
5355
if (result.hasOwnProperty(fileName)) {

build/lib/standalone.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export function extractEditor(options: tss.ITreeShakingOptions & { destRoot: str
5454

5555
options.compilerOptions = compilerOptions;
5656

57-
console.log(`Running with shakeLevel ${tss.toStringShakeLevel(options.shakeLevel)}`);
57+
console.log(`Running tree shaker with shakeLevel ${tss.toStringShakeLevel(options.shakeLevel)}`);
58+
59+
// Take the extra included .d.ts files from `tsconfig.monaco.json`
60+
options.typings = (<string[]>tsConfig.include).filter(includedFile => /\.d\.ts$/.test(includedFile));
5861

5962
let result = tss.shake(options);
6063
for (let fileName in result) {

build/lib/treeshaking.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ function toStringShakeLevel(shakeLevel) {
2525
}
2626
}
2727
exports.toStringShakeLevel = toStringShakeLevel;
28-
function printDiagnostics(diagnostics) {
28+
function printDiagnostics(options, diagnostics) {
2929
for (const diag of diagnostics) {
3030
let result = '';
3131
if (diag.file) {
32-
result += `${diag.file.fileName}: `;
32+
result += `${path.join(options.sourcesRoot, diag.file.fileName)}`;
3333
}
3434
if (diag.file && diag.start) {
3535
let location = diag.file.getLineAndCharacterOfPosition(diag.start);
36-
result += `- ${location.line + 1},${location.character} - `;
36+
result += `:${location.line + 1}:${location.character}`;
3737
}
38-
result += JSON.stringify(diag.messageText);
38+
result += ` - ` + JSON.stringify(diag.messageText);
3939
console.log(result);
4040
}
4141
}
@@ -44,17 +44,17 @@ function shake(options) {
4444
const program = languageService.getProgram();
4545
const globalDiagnostics = program.getGlobalDiagnostics();
4646
if (globalDiagnostics.length > 0) {
47-
printDiagnostics(globalDiagnostics);
47+
printDiagnostics(options, globalDiagnostics);
4848
throw new Error(`Compilation Errors encountered.`);
4949
}
5050
const syntacticDiagnostics = program.getSyntacticDiagnostics();
5151
if (syntacticDiagnostics.length > 0) {
52-
printDiagnostics(syntacticDiagnostics);
52+
printDiagnostics(options, syntacticDiagnostics);
5353
throw new Error(`Compilation Errors encountered.`);
5454
}
5555
const semanticDiagnostics = program.getSemanticDiagnostics();
5656
if (semanticDiagnostics.length > 0) {
57-
printDiagnostics(semanticDiagnostics);
57+
printDiagnostics(options, semanticDiagnostics);
5858
throw new Error(`Compilation Errors encountered.`);
5959
}
6060
markNodes(languageService, options);
@@ -358,7 +358,7 @@ function markNodes(languageService, options) {
358358
++step;
359359
let node;
360360
if (step % 100 === 0) {
361-
console.log(`${step}/${step + black_queue.length + gray_queue.length} (${black_queue.length}, ${gray_queue.length})`);
361+
console.log(`Treeshaking - ${Math.floor(100 * step / (step + black_queue.length + gray_queue.length))}% - ${step}/${step + black_queue.length + gray_queue.length} (${black_queue.length}, ${gray_queue.length})`);
362362
}
363363
if (black_queue.length === 0) {
364364
for (let i = 0; i < gray_queue.length; i++) {

build/lib/treeshaking.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ export interface ITreeShakingResult {
7171
[file: string]: string;
7272
}
7373

74-
function printDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>): void {
74+
function printDiagnostics(options: ITreeShakingOptions, diagnostics: ReadonlyArray<ts.Diagnostic>): void {
7575
for (const diag of diagnostics) {
7676
let result = '';
7777
if (diag.file) {
78-
result += `${diag.file.fileName}: `;
78+
result += `${path.join(options.sourcesRoot, diag.file.fileName)}`;
7979
}
8080
if (diag.file && diag.start) {
8181
let location = diag.file.getLineAndCharacterOfPosition(diag.start);
82-
result += `- ${location.line + 1},${location.character} - `;
82+
result += `:${location.line + 1}:${location.character}`;
8383
}
84-
result += JSON.stringify(diag.messageText);
84+
result += ` - ` + JSON.stringify(diag.messageText);
8585
console.log(result);
8686
}
8787
}
@@ -92,19 +92,19 @@ export function shake(options: ITreeShakingOptions): ITreeShakingResult {
9292

9393
const globalDiagnostics = program.getGlobalDiagnostics();
9494
if (globalDiagnostics.length > 0) {
95-
printDiagnostics(globalDiagnostics);
95+
printDiagnostics(options, globalDiagnostics);
9696
throw new Error(`Compilation Errors encountered.`);
9797
}
9898

9999
const syntacticDiagnostics = program.getSyntacticDiagnostics();
100100
if (syntacticDiagnostics.length > 0) {
101-
printDiagnostics(syntacticDiagnostics);
101+
printDiagnostics(options, syntacticDiagnostics);
102102
throw new Error(`Compilation Errors encountered.`);
103103
}
104104

105105
const semanticDiagnostics = program.getSemanticDiagnostics();
106106
if (semanticDiagnostics.length > 0) {
107-
printDiagnostics(semanticDiagnostics);
107+
printDiagnostics(options, semanticDiagnostics);
108108
throw new Error(`Compilation Errors encountered.`);
109109
}
110110

@@ -471,7 +471,7 @@ function markNodes(languageService: ts.LanguageService, options: ITreeShakingOpt
471471
let node: ts.Node;
472472

473473
if (step % 100 === 0) {
474-
console.log(`${step}/${step + black_queue.length + gray_queue.length} (${black_queue.length}, ${gray_queue.length})`);
474+
console.log(`Treeshaking - ${Math.floor(100 * step / (step + black_queue.length + gray_queue.length))}% - ${step}/${step + black_queue.length + gray_queue.length} (${black_queue.length}, ${gray_queue.length})`);
475475
}
476476

477477
if (black_queue.length === 0) {

build/lib/util.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,31 @@ function rimraf(dir) {
185185
return result;
186186
}
187187
exports.rimraf = rimraf;
188+
function _rreaddir(dirPath, prepend, result) {
189+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
190+
for (const entry of entries) {
191+
if (entry.isDirectory()) {
192+
_rreaddir(path.join(dirPath, entry.name), `${prepend}/${entry.name}`, result);
193+
}
194+
else {
195+
result.push(`${prepend}/${entry.name}`);
196+
}
197+
}
198+
}
199+
function rreddir(dirPath) {
200+
let result = [];
201+
_rreaddir(dirPath, '', result);
202+
return result;
203+
}
204+
exports.rreddir = rreddir;
205+
function ensureDir(dirPath) {
206+
if (fs.existsSync(dirPath)) {
207+
return;
208+
}
209+
ensureDir(path.dirname(dirPath));
210+
fs.mkdirSync(dirPath);
211+
}
212+
exports.ensureDir = ensureDir;
188213
function getVersion(root) {
189214
let version = process.env['BUILD_SOURCEVERSION'];
190215
if (!version || !/^[0-9a-f]{40}$/i.test(version)) {

build/lib/util.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,31 @@ export function rimraf(dir: string): () => Promise<void> {
243243
return result;
244244
}
245245

246+
function _rreaddir(dirPath: string, prepend: string, result: string[]): void {
247+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
248+
for (const entry of entries) {
249+
if (entry.isDirectory()) {
250+
_rreaddir(path.join(dirPath, entry.name), `${prepend}/${entry.name}`, result);
251+
} else {
252+
result.push(`${prepend}/${entry.name}`);
253+
}
254+
}
255+
}
256+
257+
export function rreddir(dirPath: string): string[] {
258+
let result: string[] = [];
259+
_rreaddir(dirPath, '', result);
260+
return result;
261+
}
262+
263+
export function ensureDir(dirPath: string): void {
264+
if (fs.existsSync(dirPath)) {
265+
return;
266+
}
267+
ensureDir(path.dirname(dirPath));
268+
fs.mkdirSync(dirPath);
269+
}
270+
246271
export function getVersion(root: string): string | undefined {
247272
let version = process.env['BUILD_SOURCEVERSION'];
248273

build/monaco/monaco.d.ts.recipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare namespace monaco {
4343
}
4444

4545
declare namespace monaco.editor {
46-
46+
#include(vs/editor/browser/widget/diffNavigator): IDiffNavigator
4747
#includeAll(vs/editor/standalone/browser/standaloneEditor;modes.=>languages.;editorCommon.=>):
4848
#include(vs/editor/standalone/common/standaloneThemeService): BuiltinTheme, IStandaloneThemeData, IColors
4949
#include(vs/editor/common/modes/supports/tokenization): ITokenThemeRule

build/monaco/monaco.usage.recipe

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,17 @@
22
// This file is adding references to various symbols which should not be removed via tree shaking
33

44
import { ServiceIdentifier } from './vs/platform/instantiation/common/instantiation';
5-
import { IContextViewService } from './vs/platform/contextview/browser/contextView';
6-
import { IHighlight } from './vs/base/parts/quickopen/browser/quickOpenModel';
7-
import { IWorkspaceContextService } from './vs/platform/workspace/common/workspace';
8-
import { IEnvironmentService } from './vs/platform/environment/common/environment';
9-
import { CountBadge } from './vs/base/browser/ui/countBadge/countBadge';
10-
import { SimpleWorkerClient, create as create1 } from './vs/base/common/worker/simpleWorker';
5+
import { create as create1 } from './vs/base/common/worker/simpleWorker';
116
import { create as create2 } from './vs/editor/common/services/editorSimpleWorker';
12-
import { QuickOpenWidget } from './vs/base/parts/quickopen/browser/quickOpenWidget';
13-
import { WorkbenchAsyncDataTree } from './vs/platform/list/browser/listService';
147
import { SyncDescriptor0, SyncDescriptor1, SyncDescriptor2, SyncDescriptor3, SyncDescriptor4, SyncDescriptor5, SyncDescriptor6, SyncDescriptor7, SyncDescriptor8 } from './vs/platform/instantiation/common/descriptors';
15-
import { DiffNavigator } from './vs/editor/browser/widget/diffNavigator';
16-
import { DocumentRangeFormattingEditProvider } from './vs/editor/common/modes';
178
import * as editorAPI from './vs/editor/editor.api';
189

1910
(function () {
2011
var a: any;
2112
var b: any;
22-
a = (<IContextViewService>b).layout; // IContextViewProvider
23-
a = (<IWorkspaceContextService>b).getWorkspaceFolder; // IWorkspaceFolderProvider
24-
a = (<IWorkspaceContextService>b).getWorkspace; // IWorkspaceFolderProvider
25-
a = (<CountBadge>b).style; // IThemable
26-
a = (<QuickOpenWidget>b).style; // IThemable
27-
a = (<WorkbenchAsyncDataTree<any,any>>b).style; // IThemable
28-
a = (<IEnvironmentService>b).userHome; // IUserHomeProvider
29-
a = (<DiffNavigator>b).previous; // IDiffNavigator
3013
a = (<ServiceIdentifier<any>>b).type;
31-
a = (<IHighlight>b).start;
32-
a = (<IHighlight>b).end;
33-
a = (<SimpleWorkerClient<any, any>>b).getProxyObject; // IWorkerClient
3414
a = create1;
3515
a = create2;
36-
a = (<DocumentRangeFormattingEditProvider>b).extensionId;
3716

3817
// injection madness
3918
a = (<SyncDescriptor0<any>>b).ctor;

0 commit comments

Comments
 (0)