Skip to content

Commit 74fab50

Browse files
committed
consolidate build package.json
1 parent 613724d commit 74fab50

27 files changed

Lines changed: 3612 additions & 23471 deletions

build/lib/bundle.js

Lines changed: 453 additions & 453 deletions
Large diffs are not rendered by default.

build/lib/compilation.js

Lines changed: 171 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,171 @@
1-
/*---------------------------------------------------------------------------------------------
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
4-
*--------------------------------------------------------------------------------------------*/
5-
'use strict';
6-
Object.defineProperty(exports, "__esModule", { value: true });
7-
var gulp = require("gulp");
8-
var tsb = require("gulp-tsb");
9-
var es = require("event-stream");
10-
var watch = require('./watch');
11-
var nls = require("./nls");
12-
var util = require("./util");
13-
var reporter_1 = require("./reporter");
14-
var path = require("path");
15-
var bom = require("gulp-bom");
16-
var sourcemaps = require("gulp-sourcemaps");
17-
var _ = require("underscore");
18-
var monacodts = require("../monaco/api");
19-
var fs = require("fs");
20-
var reporter = reporter_1.createReporter();
21-
var rootDir = path.join(__dirname, '../../src');
22-
var options = require('../../src/tsconfig.json').compilerOptions;
23-
options.verbose = false;
24-
options.sourceMap = true;
25-
options.rootDir = rootDir;
26-
options.sourceRoot = util.toFileUri(rootDir);
27-
function createCompile(build, emitError) {
28-
var opts = _.clone(options);
29-
opts.inlineSources = !!build;
30-
opts.noFilesystemLookup = true;
31-
var ts = tsb.create(opts, null, null, function (err) { return reporter(err.toString()); });
32-
return function (token) {
33-
var utf8Filter = util.filter(function (data) { return /(\/|\\)test(\/|\\).*utf8/.test(data.path); });
34-
var tsFilter = util.filter(function (data) { return /\.ts$/.test(data.path); });
35-
var noDeclarationsFilter = util.filter(function (data) { return !(/\.d\.ts$/.test(data.path)); });
36-
var input = es.through();
37-
var output = input
38-
.pipe(utf8Filter)
39-
.pipe(bom())
40-
.pipe(utf8Filter.restore)
41-
.pipe(tsFilter)
42-
.pipe(util.loadSourcemaps())
43-
.pipe(ts(token))
44-
.pipe(build ? reloadTypeScriptNodeModule() : es.through())
45-
.pipe(noDeclarationsFilter)
46-
.pipe(build ? nls() : es.through())
47-
.pipe(noDeclarationsFilter.restore)
48-
.pipe(sourcemaps.write('.', {
49-
addComment: false,
50-
includeContent: !!build,
51-
sourceRoot: options.sourceRoot
52-
}))
53-
.pipe(tsFilter.restore)
54-
.pipe(reporter.end(emitError));
55-
return es.duplex(input, output);
56-
};
57-
}
58-
function compileTask(out, build) {
59-
return function () {
60-
var compile = createCompile(build, true);
61-
var src = es.merge(gulp.src('src/**', { base: 'src' }), gulp.src('node_modules/typescript/lib/lib.d.ts'), gulp.src('node_modules/@types/**/index.d.ts'));
62-
return src
63-
.pipe(compile())
64-
.pipe(gulp.dest(out))
65-
.pipe(monacodtsTask(out, false));
66-
};
67-
}
68-
exports.compileTask = compileTask;
69-
function watchTask(out, build) {
70-
return function () {
71-
var compile = createCompile(build);
72-
var src = es.merge(gulp.src('src/**', { base: 'src' }), gulp.src('node_modules/typescript/lib/lib.d.ts'), gulp.src('node_modules/@types/**/index.d.ts'));
73-
var watchSrc = watch('src/**', { base: 'src' });
74-
return watchSrc
75-
.pipe(util.incremental(compile, src, true))
76-
.pipe(gulp.dest(out))
77-
.pipe(monacodtsTask(out, true));
78-
};
79-
}
80-
exports.watchTask = watchTask;
81-
function reloadTypeScriptNodeModule() {
82-
var util = require('gulp-util');
83-
function log(message) {
84-
var rest = [];
85-
for (var _i = 1; _i < arguments.length; _i++) {
86-
rest[_i - 1] = arguments[_i];
87-
}
88-
util.log.apply(util, [util.colors.cyan('[memory watch dog]'), message].concat(rest));
89-
}
90-
function heapUsed() {
91-
return (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2) + ' MB';
92-
}
93-
return es.through(function (data) {
94-
this.emit('data', data);
95-
}, function () {
96-
log('memory usage after compilation finished: ' + heapUsed());
97-
// It appears we are running into some variant of
98-
// https://bugs.chromium.org/p/v8/issues/detail?id=2073
99-
//
100-
// Even though all references are dropped, some
101-
// optimized methods in the TS compiler end up holding references
102-
// to the entire TypeScript language host (>600MB)
103-
//
104-
// The idea is to force v8 to drop references to these
105-
// optimized methods, by "reloading" the typescript node module
106-
log('Reloading typescript node module...');
107-
var resolvedName = require.resolve('typescript');
108-
var originalModule = require.cache[resolvedName];
109-
delete require.cache[resolvedName];
110-
var newExports = require('typescript');
111-
require.cache[resolvedName] = originalModule;
112-
for (var prop in newExports) {
113-
if (newExports.hasOwnProperty(prop)) {
114-
originalModule.exports[prop] = newExports[prop];
115-
}
116-
}
117-
log('typescript node module reloaded.');
118-
this.emit('end');
119-
});
120-
}
121-
function monacodtsTask(out, isWatch) {
122-
var neededFiles = {};
123-
monacodts.getFilesToWatch(out).forEach(function (filePath) {
124-
filePath = path.normalize(filePath);
125-
neededFiles[filePath] = true;
126-
});
127-
var inputFiles = {};
128-
for (var filePath in neededFiles) {
129-
if (/\bsrc(\/|\\)vs\b/.test(filePath)) {
130-
// This file is needed from source => simply read it now
131-
inputFiles[filePath] = fs.readFileSync(filePath).toString();
132-
}
133-
}
134-
var setInputFile = function (filePath, contents) {
135-
if (inputFiles[filePath] === contents) {
136-
// no change
137-
return;
138-
}
139-
inputFiles[filePath] = contents;
140-
var neededInputFilesCount = Object.keys(neededFiles).length;
141-
var availableInputFilesCount = Object.keys(inputFiles).length;
142-
if (neededInputFilesCount === availableInputFilesCount) {
143-
run();
144-
}
145-
};
146-
var run = function () {
147-
var result = monacodts.run(out, inputFiles);
148-
if (!result.isTheSame) {
149-
if (isWatch) {
150-
fs.writeFileSync(result.filePath, result.content);
151-
}
152-
else {
153-
resultStream.emit('error', 'monaco.d.ts is no longer up to date. Please run gulp watch and commit the new file.');
154-
}
155-
}
156-
};
157-
var resultStream;
158-
if (isWatch) {
159-
watch('build/monaco/*').pipe(es.through(function () {
160-
run();
161-
}));
162-
}
163-
resultStream = es.through(function (data) {
164-
var filePath = path.normalize(data.path);
165-
if (neededFiles[filePath]) {
166-
setInputFile(filePath, data.contents.toString());
167-
}
168-
this.emit('data', data);
169-
});
170-
return resultStream;
171-
}
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
'use strict';
6+
Object.defineProperty(exports, "__esModule", { value: true });
7+
var gulp = require("gulp");
8+
var tsb = require("gulp-tsb");
9+
var es = require("event-stream");
10+
var watch = require('./watch');
11+
var nls = require("./nls");
12+
var util = require("./util");
13+
var reporter_1 = require("./reporter");
14+
var path = require("path");
15+
var bom = require("gulp-bom");
16+
var sourcemaps = require("gulp-sourcemaps");
17+
var _ = require("underscore");
18+
var monacodts = require("../monaco/api");
19+
var fs = require("fs");
20+
var reporter = reporter_1.createReporter();
21+
var rootDir = path.join(__dirname, '../../src');
22+
var options = require('../../src/tsconfig.json').compilerOptions;
23+
options.verbose = false;
24+
options.sourceMap = true;
25+
options.rootDir = rootDir;
26+
options.sourceRoot = util.toFileUri(rootDir);
27+
function createCompile(build, emitError) {
28+
var opts = _.clone(options);
29+
opts.inlineSources = !!build;
30+
opts.noFilesystemLookup = true;
31+
var ts = tsb.create(opts, null, null, function (err) { return reporter(err.toString()); });
32+
return function (token) {
33+
var utf8Filter = util.filter(function (data) { return /(\/|\\)test(\/|\\).*utf8/.test(data.path); });
34+
var tsFilter = util.filter(function (data) { return /\.ts$/.test(data.path); });
35+
var noDeclarationsFilter = util.filter(function (data) { return !(/\.d\.ts$/.test(data.path)); });
36+
var input = es.through();
37+
var output = input
38+
.pipe(utf8Filter)
39+
.pipe(bom())
40+
.pipe(utf8Filter.restore)
41+
.pipe(tsFilter)
42+
.pipe(util.loadSourcemaps())
43+
.pipe(ts(token))
44+
.pipe(build ? reloadTypeScriptNodeModule() : es.through())
45+
.pipe(noDeclarationsFilter)
46+
.pipe(build ? nls() : es.through())
47+
.pipe(noDeclarationsFilter.restore)
48+
.pipe(sourcemaps.write('.', {
49+
addComment: false,
50+
includeContent: !!build,
51+
sourceRoot: options.sourceRoot
52+
}))
53+
.pipe(tsFilter.restore)
54+
.pipe(reporter.end(emitError));
55+
return es.duplex(input, output);
56+
};
57+
}
58+
function compileTask(out, build) {
59+
return function () {
60+
var compile = createCompile(build, true);
61+
var src = es.merge(gulp.src('src/**', { base: 'src' }), gulp.src('node_modules/typescript/lib/lib.d.ts'), gulp.src('node_modules/@types/**/index.d.ts'));
62+
return src
63+
.pipe(compile())
64+
.pipe(gulp.dest(out))
65+
.pipe(monacodtsTask(out, false));
66+
};
67+
}
68+
exports.compileTask = compileTask;
69+
function watchTask(out, build) {
70+
return function () {
71+
var compile = createCompile(build);
72+
var src = es.merge(gulp.src('src/**', { base: 'src' }), gulp.src('node_modules/typescript/lib/lib.d.ts'), gulp.src('node_modules/@types/**/index.d.ts'));
73+
var watchSrc = watch('src/**', { base: 'src' });
74+
return watchSrc
75+
.pipe(util.incremental(compile, src, true))
76+
.pipe(gulp.dest(out))
77+
.pipe(monacodtsTask(out, true));
78+
};
79+
}
80+
exports.watchTask = watchTask;
81+
function reloadTypeScriptNodeModule() {
82+
var util = require('gulp-util');
83+
function log(message) {
84+
var rest = [];
85+
for (var _i = 1; _i < arguments.length; _i++) {
86+
rest[_i - 1] = arguments[_i];
87+
}
88+
util.log.apply(util, [util.colors.cyan('[memory watch dog]'), message].concat(rest));
89+
}
90+
function heapUsed() {
91+
return (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2) + ' MB';
92+
}
93+
return es.through(function (data) {
94+
this.emit('data', data);
95+
}, function () {
96+
log('memory usage after compilation finished: ' + heapUsed());
97+
// It appears we are running into some variant of
98+
// https://bugs.chromium.org/p/v8/issues/detail?id=2073
99+
//
100+
// Even though all references are dropped, some
101+
// optimized methods in the TS compiler end up holding references
102+
// to the entire TypeScript language host (>600MB)
103+
//
104+
// The idea is to force v8 to drop references to these
105+
// optimized methods, by "reloading" the typescript node module
106+
log('Reloading typescript node module...');
107+
var resolvedName = require.resolve('typescript');
108+
var originalModule = require.cache[resolvedName];
109+
delete require.cache[resolvedName];
110+
var newExports = require('typescript');
111+
require.cache[resolvedName] = originalModule;
112+
for (var prop in newExports) {
113+
if (newExports.hasOwnProperty(prop)) {
114+
originalModule.exports[prop] = newExports[prop];
115+
}
116+
}
117+
log('typescript node module reloaded.');
118+
this.emit('end');
119+
});
120+
}
121+
function monacodtsTask(out, isWatch) {
122+
var neededFiles = {};
123+
monacodts.getFilesToWatch(out).forEach(function (filePath) {
124+
filePath = path.normalize(filePath);
125+
neededFiles[filePath] = true;
126+
});
127+
var inputFiles = {};
128+
for (var filePath in neededFiles) {
129+
if (/\bsrc(\/|\\)vs\b/.test(filePath)) {
130+
// This file is needed from source => simply read it now
131+
inputFiles[filePath] = fs.readFileSync(filePath).toString();
132+
}
133+
}
134+
var setInputFile = function (filePath, contents) {
135+
if (inputFiles[filePath] === contents) {
136+
// no change
137+
return;
138+
}
139+
inputFiles[filePath] = contents;
140+
var neededInputFilesCount = Object.keys(neededFiles).length;
141+
var availableInputFilesCount = Object.keys(inputFiles).length;
142+
if (neededInputFilesCount === availableInputFilesCount) {
143+
run();
144+
}
145+
};
146+
var run = function () {
147+
var result = monacodts.run(out, inputFiles);
148+
if (!result.isTheSame) {
149+
if (isWatch) {
150+
fs.writeFileSync(result.filePath, result.content);
151+
}
152+
else {
153+
resultStream.emit('error', 'monaco.d.ts is no longer up to date. Please run gulp watch and commit the new file.');
154+
}
155+
}
156+
};
157+
var resultStream;
158+
if (isWatch) {
159+
watch('build/monaco/*').pipe(es.through(function () {
160+
run();
161+
}));
162+
}
163+
resultStream = es.through(function (data) {
164+
var filePath = path.normalize(data.path);
165+
if (neededFiles[filePath]) {
166+
setInputFile(filePath, data.contents.toString());
167+
}
168+
this.emit('data', data);
169+
});
170+
return resultStream;
171+
}

0 commit comments

Comments
 (0)