Skip to content

Commit d729e50

Browse files
committed
Fix standalone editor gulp scripts.
Tree Shaking: - do not proceed with tree shaking when there are compilation errors - load .d.ts files in the language service - adopt TS 3.1.1 in symbol resolution - use the real tsconfig.json / with "node" resolution Bundling: - fix issue where files were being looked for in out-build instead of out-editor-build
1 parent 4312f42 commit d729e50

11 files changed

Lines changed: 217 additions & 213 deletions

File tree

build/gulpfile.editor.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var editorEntryPoints = [
2828
name: 'vs/editor/editor.main',
2929
include: [],
3030
exclude: ['vs/css', 'vs/nls'],
31-
prepend: ['out-build/vs/css.js', 'out-build/vs/nls.js'],
31+
prepend: ['out-editor-build/vs/css.js', 'out-editor-build/vs/nls.js'],
3232
},
3333
{
3434
name: 'vs/base/common/worker/simpleWorker',
@@ -79,16 +79,21 @@ gulp.task('extract-editor-src', ['clean-editor-src'], function () {
7979
apiusages,
8080
extrausages
8181
],
82+
typings: [
83+
'typings/lib.ie11_safe_es6.d.ts',
84+
'typings/thenable.d.ts',
85+
'typings/es6-promise.d.ts',
86+
'typings/require-monaco.d.ts',
87+
'vs/monaco.d.ts'
88+
],
8289
libs: [
83-
`lib.d.ts`,
84-
`lib.es2015.collection.d.ts`
90+
`lib.es5.d.ts`,
91+
`lib.dom.d.ts`,
92+
`lib.webworker.importscripts.d.ts`
8593
],
8694
redirects: {
8795
'vs/base/browser/ui/octiconLabel/octiconLabel': 'vs/base/browser/ui/octiconLabel/octiconLabel.mock',
8896
},
89-
compilerOptions: {
90-
module: 2, // ModuleKind.AMD
91-
},
9297
shakeLevel: 2, // 0-Files, 1-InnerFile, 2-ClassMembers
9398
importIgnorePattern: /^vs\/css!/,
9499
destRoot: path.join(root, 'out-editor-src')
@@ -108,6 +113,8 @@ gulp.task('optimize-editor', ['clean-optimized-editor', 'compile-editor-build'],
108113
loaderConfig: {
109114
paths: {
110115
'vs': 'out-editor-build/vs',
116+
'vs/css': 'out-editor-build/vs/css.build',
117+
'vs/nls': 'out-editor-build/vs/nls.build',
111118
'vscode': 'empty:'
112119
}
113120
},
@@ -125,7 +132,7 @@ gulp.task('clean-editor-esm', util.rimraf('out-editor-esm'));
125132
gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro', 'extract-editor-src'], function () {
126133
standalone.createESMSourcesAndResources2({
127134
srcFolder: './out-editor-src',
128-
outFolder: './out-editor-esm/src',
135+
outFolder: './out-editor-esm',
129136
outResourcesFolder: './out-monaco-editor-core/esm',
130137
ignores: [
131138
'inlineEntryPoint:0.ts',

build/lib/bundle.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ function bundle(entryPoints, config, callback) {
3232
var loader = loaderModule.exports;
3333
config.isBuild = true;
3434
config.paths = config.paths || {};
35-
config.paths['vs/nls'] = 'out-build/vs/nls.build';
36-
config.paths['vs/css'] = 'out-build/vs/css.build';
35+
if (!config.paths['vs/nls']) {
36+
config.paths['vs/nls'] = 'out-build/vs/nls.build';
37+
}
38+
if (!config.paths['vs/css']) {
39+
config.paths['vs/css'] = 'out-build/vs/css.build';
40+
}
3741
loader.config(config);
3842
loader(['require'], function (localRequire) {
3943
var resolvePath = function (path) {

build/lib/bundle.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,12 @@ export function bundle(entryPoints: IEntryPoint[], config: ILoaderConfig, callba
123123
const loader: any = loaderModule.exports;
124124
config.isBuild = true;
125125
config.paths = config.paths || {};
126-
config.paths['vs/nls'] = 'out-build/vs/nls.build';
127-
config.paths['vs/css'] = 'out-build/vs/css.build';
126+
if (!config.paths['vs/nls']) {
127+
config.paths['vs/nls'] = 'out-build/vs/nls.build';
128+
}
129+
if (!config.paths['vs/css']) {
130+
config.paths['vs/css'] = 'out-build/vs/css.build';
131+
}
128132
loader.config(config);
129133

130134
loader(['require'], (localRequire: any) => {

build/lib/standalone.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ function writeFile(filePath, contents) {
2727
fs.writeFileSync(filePath, contents);
2828
}
2929
function extractEditor(options) {
30+
var tsConfig = JSON.parse(fs.readFileSync(path.join(options.sourcesRoot, 'tsconfig.json')).toString());
31+
tsConfig.compilerOptions.noUnusedLocals = false;
32+
tsConfig.compilerOptions.preserveConstEnums = false;
33+
tsConfig.compilerOptions.declaration = false;
34+
delete tsConfig.compilerOptions.types;
35+
tsConfig.exclude = [];
36+
options.compilerOptions = tsConfig.compilerOptions;
3037
var result = tss.shake(options);
3138
for (var fileName in result) {
3239
if (result.hasOwnProperty(fileName)) {
@@ -73,25 +80,16 @@ function extractEditor(options) {
7380
}
7481
}
7582
}
76-
var tsConfig = JSON.parse(fs.readFileSync(path.join(options.sourcesRoot, 'tsconfig.json')).toString());
77-
tsConfig.compilerOptions.noUnusedLocals = false;
78-
tsConfig.compilerOptions.preserveConstEnums = false;
79-
tsConfig.compilerOptions.declaration = false;
8083
writeOutputFile('tsconfig.json', JSON.stringify(tsConfig, null, '\t'));
8184
[
8285
'vs/css.build.js',
8386
'vs/css.d.ts',
8487
'vs/css.js',
8588
'vs/loader.js',
86-
'vs/monaco.d.ts',
8789
'vs/nls.build.js',
8890
'vs/nls.d.ts',
8991
'vs/nls.js',
9092
'vs/nls.mock.ts',
91-
'typings/lib.ie11_safe_es6.d.ts',
92-
'typings/thenable.d.ts',
93-
'typings/es6-promise.d.ts',
94-
'typings/require.d.ts',
9593
].forEach(copyFile);
9694
}
9795
exports.extractEditor = extractEditor;
@@ -102,7 +100,7 @@ function createESMSourcesAndResources2(options) {
102100
var getDestAbsoluteFilePath = function (file) {
103101
var dest = options.renames[file.replace(/\\/g, '/')] || file;
104102
if (dest === 'tsconfig.json') {
105-
return path.join(OUT_FOLDER, "../tsconfig.json");
103+
return path.join(OUT_FOLDER, "tsconfig.json");
106104
}
107105
if (/\.ts$/.test(dest)) {
108106
return path.join(OUT_FOLDER, dest);
@@ -117,11 +115,8 @@ function createESMSourcesAndResources2(options) {
117115
}
118116
if (file === 'tsconfig.json') {
119117
var tsConfig = JSON.parse(fs.readFileSync(path.join(SRC_FOLDER, file)).toString());
120-
tsConfig.compilerOptions.moduleResolution = undefined;
121-
tsConfig.compilerOptions.baseUrl = undefined;
122118
tsConfig.compilerOptions.module = 'es6';
123-
tsConfig.compilerOptions.rootDir = 'src';
124-
tsConfig.compilerOptions.outDir = path.relative(path.dirname(OUT_FOLDER), OUT_RESOURCES_FOLDER);
119+
tsConfig.compilerOptions.outDir = path.join(path.relative(OUT_FOLDER, OUT_RESOURCES_FOLDER), 'vs');
125120
write(getDestAbsoluteFilePath(file), JSON.stringify(tsConfig, null, '\t'));
126121
continue;
127122
}

build/lib/standalone.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ function writeFile(filePath: string, contents: Buffer | string): void {
3131
}
3232

3333
export function extractEditor(options: tss.ITreeShakingOptions & { destRoot: string }): void {
34+
const tsConfig = JSON.parse(fs.readFileSync(path.join(options.sourcesRoot, 'tsconfig.json')).toString());
35+
tsConfig.compilerOptions.noUnusedLocals = false;
36+
tsConfig.compilerOptions.preserveConstEnums = false;
37+
tsConfig.compilerOptions.declaration = false;
38+
delete tsConfig.compilerOptions.types;
39+
tsConfig.exclude = [];
40+
41+
options.compilerOptions = tsConfig.compilerOptions;
42+
3443
let result = tss.shake(options);
3544
for (let fileName in result) {
3645
if (result.hasOwnProperty(fileName)) {
@@ -79,26 +88,17 @@ export function extractEditor(options: tss.ITreeShakingOptions & { destRoot: str
7988
}
8089
}
8190

82-
const tsConfig = JSON.parse(fs.readFileSync(path.join(options.sourcesRoot, 'tsconfig.json')).toString());
83-
tsConfig.compilerOptions.noUnusedLocals = false;
84-
tsConfig.compilerOptions.preserveConstEnums = false;
85-
tsConfig.compilerOptions.declaration = false;
8691
writeOutputFile('tsconfig.json', JSON.stringify(tsConfig, null, '\t'));
8792

8893
[
8994
'vs/css.build.js',
9095
'vs/css.d.ts',
9196
'vs/css.js',
9297
'vs/loader.js',
93-
'vs/monaco.d.ts',
9498
'vs/nls.build.js',
9599
'vs/nls.d.ts',
96100
'vs/nls.js',
97101
'vs/nls.mock.ts',
98-
'typings/lib.ie11_safe_es6.d.ts',
99-
'typings/thenable.d.ts',
100-
'typings/es6-promise.d.ts',
101-
'typings/require.d.ts',
102102
].forEach(copyFile);
103103
}
104104

@@ -118,7 +118,7 @@ export function createESMSourcesAndResources2(options: IOptions2): void {
118118
const getDestAbsoluteFilePath = (file: string): string => {
119119
let dest = options.renames[file.replace(/\\/g, '/')] || file;
120120
if (dest === 'tsconfig.json') {
121-
return path.join(OUT_FOLDER, `../tsconfig.json`);
121+
return path.join(OUT_FOLDER, `tsconfig.json`);
122122
}
123123
if (/\.ts$/.test(dest)) {
124124
return path.join(OUT_FOLDER, dest);
@@ -136,11 +136,8 @@ export function createESMSourcesAndResources2(options: IOptions2): void {
136136

137137
if (file === 'tsconfig.json') {
138138
const tsConfig = JSON.parse(fs.readFileSync(path.join(SRC_FOLDER, file)).toString());
139-
tsConfig.compilerOptions.moduleResolution = undefined;
140-
tsConfig.compilerOptions.baseUrl = undefined;
141139
tsConfig.compilerOptions.module = 'es6';
142-
tsConfig.compilerOptions.rootDir = 'src';
143-
tsConfig.compilerOptions.outDir = path.relative(path.dirname(OUT_FOLDER), OUT_RESOURCES_FOLDER);
140+
tsConfig.compilerOptions.outDir = path.join(path.relative(OUT_FOLDER, OUT_RESOURCES_FOLDER), 'vs');
144141
write(getDestAbsoluteFilePath(file), JSON.stringify(tsConfig, null, '\t'));
145142
continue;
146143
}

0 commit comments

Comments
 (0)