Skip to content

Commit e0d5363

Browse files
committed
Merge branch 'master' into openSameFileWithDifferentText
2 parents 9f3e5ea + 7dc66e9 commit e0d5363

File tree

1,207 files changed

+600756
-5221
lines changed

Some content is hidden

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

1,207 files changed

+600756
-5221
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ tests/cases/user/*/**/*.d.ts
7373
!tests/cases/user/zone.js/
7474
!tests/cases/user/bignumber.js/
7575
!tests/cases/user/discord.js/
76-
tests/baselines/reference/dt
76+
tests/baselines/reference/dt
77+
.failed-tests

Gulpfile.js

Lines changed: 72 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ const insert = require("gulp-insert");
1010
const { append } = require("gulp-insert");
1111
const sourcemaps = require("gulp-sourcemaps");
1212
const del = require("del");
13-
const browserify = require("browserify");
14-
const through2 = require("through2");
1513
const fold = require("travis-fold");
1614
const rename = require("gulp-rename");
17-
const convertMap = require("convert-source-map");
18-
const sorcery = require("sorcery");
19-
const Vinyl = require("vinyl");
2015
const mkdirp = require("./scripts/build/mkdirp");
2116
const gulp = require("./scripts/build/gulp");
2217
const getDirSize = require("./scripts/build/getDirSize");
@@ -28,7 +23,7 @@ const getDiffTool = require("./scripts/build/getDiffTool");
2823
const baselineAccept = require("./scripts/build/baselineAccept");
2924
const cmdLineOptions = require("./scripts/build/options");
3025
const exec = require("./scripts/build/exec");
31-
const _debugMode = require("./scripts/build/debugMode");
26+
const browserify = require("./scripts/build/browserify");
3227
const { libraryTargets, generateLibs } = require("./scripts/build/lib");
3328
const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests");
3429

@@ -51,7 +46,7 @@ const produceLKGJs = "scripts/produceLKG.js";
5146
const word2mdJs = "scripts/word2md.js";
5247
gulp.task("scripts", /*help*/ false, () => project.compile(scriptsProject), {
5348
aliases: [
54-
configurePrereleaseJs,
49+
configurePrereleaseJs,
5550
processDiagnosticMessagesJs,
5651
generateLocalizedDiagnosticMessagesJs,
5752
produceLKGJs,
@@ -72,7 +67,7 @@ gulp.task(
7267
"publish-nightly",
7368
"Runs `npm publish --tag next` to create a new nightly build on npm",
7469
["LKG"],
75-
() => runSequence("clean", "useDebugMode", "runtests-parallel",
70+
() => runSequence("clean", "runtests-parallel",
7671
() => exec("npm", ["publish", "--tag", "next"])));
7772

7873
const importDefinitelyTypedTestsProject = "scripts/importDefinitelyTypedTests/tsconfig.json";
@@ -139,10 +134,11 @@ gulp.task(generatedLCGFile, /*help*/ false, [generateLocalizedDiagnosticMessages
139134

140135
gulp.task("localize", /*help*/ false, [generatedLCGFile]);
141136

137+
const servicesProject = "src/services/tsconfig.json";
142138
const typescriptServicesProject = "built/local/typescriptServices.tsconfig.json";
143139
gulp.task(typescriptServicesProject, /*help*/ false, () => {
144140
// NOTE: flatten services so that we can properly strip @internal
145-
project.flatten("src/services/tsconfig.json", typescriptServicesProject, {
141+
project.flatten(servicesProject, typescriptServicesProject, {
146142
compilerOptions: {
147143
"removeComments": true,
148144
"stripInternal": true,
@@ -153,7 +149,7 @@ gulp.task(typescriptServicesProject, /*help*/ false, () => {
153149

154150
const typescriptServicesJs = "built/local/typescriptServices.js";
155151
const typescriptServicesDts = "built/local/typescriptServices.d.ts";
156-
gulp.task(typescriptServicesJs, /*help*/ false, ["lib", "generate-diagnostics", typescriptServicesProject], () =>
152+
gulp.task(typescriptServicesJs, /*help*/ false, ["lib", "generate-diagnostics", typescriptServicesProject], () =>
157153
project.compile(typescriptServicesProject, { dts: files => files.pipe(convertConstEnums()) }),
158154
{ aliases: [typescriptServicesDts] });
159155

@@ -187,6 +183,10 @@ const tscProject = "src/tsc/tsconfig.json";
187183
const tscJs = "built/local/tsc.js";
188184
gulp.task(tscJs, /*help*/ false, [typescriptServicesJs], () => project.compile(tscProject, { typescript: "built" }));
189185

186+
const tscReleaseProject = "src/tsc/tsconfig.release.json";
187+
const tscReleaseJs = "built/local/tsc.release.js";
188+
gulp.task(tscReleaseJs, /*help*/ false, () => project.compile(tscReleaseProject));
189+
190190
const cancellationTokenProject = "src/cancellationToken/tsconfig.json";
191191
const cancellationTokenJs = "built/local/cancellationToken.js";
192192
gulp.task(cancellationTokenJs, /*help*/ false, [typescriptServicesJs], () => project.compile(cancellationTokenProject, { typescript: "built" }));
@@ -226,7 +226,7 @@ gulp.task(tsserverlibraryProject, /*help*/ false, () => {
226226
const tsserverlibraryJs = "built/local/tsserverlibrary.js";
227227
const tsserverlibraryDts = "built/local/tsserverlibrary.d.ts";
228228
gulp.task(tsserverlibraryJs, /*help*/ false, [typescriptServicesJs, tsserverlibraryProject], () =>
229-
project.compile(tsserverlibraryProject, {
229+
project.compile(tsserverlibraryProject, {
230230
dts: files => files
231231
.pipe(convertConstEnums())
232232
.pipe(append("\nexport = ts;\nexport as namespace ts;")),
@@ -254,21 +254,21 @@ gulp.task(specMd, /*help*/ false, [word2mdJs], () =>
254254
exec("cscript", ["//nologo", word2mdJs, path.resolve(specMd), path.resolve("doc/TypeScript Language Specification.docx")]));
255255

256256
gulp.task(
257-
"generate-spec",
258-
"Generates a Markdown version of the Language Specification",
257+
"generate-spec",
258+
"Generates a Markdown version of the Language Specification",
259259
[specMd]);
260260

261-
gulp.task("produce-LKG", /*help*/ false, ["scripts", "local", cancellationTokenJs, typingsInstallerJs, watchGuardJs], () => {
261+
gulp.task("produce-LKG", /*help*/ false, ["scripts", "local", cancellationTokenJs, typingsInstallerJs, watchGuardJs, tscReleaseJs], () => {
262262
const expectedFiles = [
263-
tscJs,
264-
typescriptServicesJs,
265-
tsserverJs,
266-
typescriptJs,
267-
typescriptDts,
268-
typescriptServicesDts,
269-
tsserverlibraryDts,
270-
tsserverlibraryDts,
271-
typingsInstallerJs,
263+
tscReleaseJs,
264+
typescriptServicesJs,
265+
tsserverJs,
266+
typescriptJs,
267+
typescriptDts,
268+
typescriptServicesDts,
269+
tsserverlibraryDts,
270+
tsserverlibraryDts,
271+
typingsInstallerJs,
272272
cancellationTokenJs
273273
].concat(libraryTargets);
274274
const missingFiles = expectedFiles
@@ -287,9 +287,9 @@ gulp.task("produce-LKG", /*help*/ false, ["scripts", "local", cancellationTokenJ
287287
});
288288

289289
gulp.task(
290-
"LKG",
291-
"Makes a new LKG out of the built js files",
292-
() => runSequence("clean-built", "dontUseDebugMode", "produce-LKG"));
290+
"LKG",
291+
"Makes a new LKG out of the built js files",
292+
() => runSequence("clean-built", "produce-LKG"));
293293

294294
// Task to build the tests infrastructure using the built compiler
295295
const testRunnerProject = "src/testRunner/tsconfig.json";
@@ -301,11 +301,6 @@ gulp.task(
301301
"Builds the test infrastructure using the built compiler",
302302
[runJs]);
303303

304-
gulp.task(
305-
"tests-debug",
306-
"Builds the test sources and automation in debug mode",
307-
() => runSequence("useDebugMode", "tests"));
308-
309304
gulp.task(
310305
"runtests-parallel",
311306
"Runs all the tests in parallel using the built run.js file. Optional arguments are: --t[ests]=category1|category2|... --d[ebug]=true.",
@@ -325,77 +320,17 @@ gulp.task("clean:" + webTestServerJs, /*help*/ false, () => project.clean(webTes
325320

326321
const bundlePath = path.resolve("built/local/bundle.js");
327322

328-
// TODO(rbuckton): Clean up browserify logic
329323
gulp.task(
330324
"browserify",
331325
"Runs browserify on run.js to produce a file suitable for running tests in the browser",
332326
[runJs],
333-
(done) => {
334-
/** @type {*} */
335-
let originalMap;
336-
/** @type {string} */
337-
let prebundledContent;
338-
browserify(gulp.src([runJs])
339-
.pipe(newer(bundlePath))
340-
.pipe(sourcemaps.init({ loadMaps: true }))
341-
.pipe(through2.obj((file, enc, next) => {
342-
if (originalMap) {
343-
throw new Error("Should only recieve one file!");
344-
}
345-
log(`Saving sourcemaps for ${file.path}`);
346-
originalMap = file.sourceMap;
347-
prebundledContent = file.contents.toString();
348-
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
349-
originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s)));
350-
// browserify names input files this when they are streamed in, so this is what it puts in the sourcemap
351-
originalMap.file = "built/local/_stream_0.js";
352-
353-
next(/*err*/ undefined, file.contents);
354-
}))
355-
.on("error", err => {
356-
return done(err);
357-
}), { debug: true, basedir: __dirname }) // Attach error handler to inner stream
358-
.bundle((err, contents) => {
359-
if (err) {
360-
if (err.message.match(/Cannot find module '.*_stream_0.js'/)) {
361-
return done(); // Browserify errors when we pass in no files when `newer` filters the input, we should count that as a success, though
362-
}
363-
return done(err);
364-
}
365-
const stringContent = contents.toString();
366-
const file = new Vinyl({ contents, path: bundlePath });
367-
log(`Fixing sourcemaps for ${file.path}`);
368-
// assumes contents is a Buffer, since that's what browserify yields
369-
const maps = convertMap.fromSource(stringContent).toObject();
370-
delete maps.sourceRoot;
371-
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
372-
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
373-
file.contents = new Buffer(convertMap.removeComments(stringContent));
374-
const chain = sorcery.loadSync(bundlePath, {
375-
content: {
376-
"built/local/_stream_0.js": prebundledContent,
377-
[bundlePath]: stringContent
378-
},
379-
sourcemaps: {
380-
"built/local/_stream_0.js": originalMap,
381-
[bundlePath]: maps,
382-
"node_modules/source-map-support/source-map-support.js": undefined,
383-
}
384-
});
385-
const finalMap = chain.apply();
386-
file.sourceMap = finalMap;
387-
388-
const stream = through2.obj((file, enc, callback) => {
389-
return callback(/*err*/ undefined, file);
390-
});
391-
stream.pipe(sourcemaps.write(".", { includeContent: false }))
392-
.pipe(gulp.dest("."))
393-
.on("end", done)
394-
.on("error", done);
395-
stream.write(file);
396-
stream.end();
397-
});
398-
});
327+
() => gulp.src([runJs], { base: "built/local" })
328+
.pipe(newer(bundlePath))
329+
.pipe(sourcemaps.init({ loadMaps: true }))
330+
.pipe(browserify())
331+
.pipe(rename("bundle.js"))
332+
.pipe(sourcemaps.write(".", /**@type {*}*/({ includeContent: false, destPath: "built/local" })))
333+
.pipe(gulp.dest("built/local")));
399334

400335
gulp.task(
401336
"runtests-browser",
@@ -530,12 +465,45 @@ gulp.task(
530465
"Runs 'local'",
531466
["local"]);
532467

533-
// TODO(rbuckton): Investigate restoring gulp.watch() functionality.
534-
// gulp.task(
535-
// "watch",
536-
// "Watches the src/ directory for changes and executes runtests-parallel.",
537-
// [],
538-
// () => gulp.watch("src/**/*.*", ["runtests-parallel"]));
468+
gulp.task(
469+
"watch-diagnostics",
470+
/*help*/ false,
471+
[processDiagnosticMessagesJs],
472+
() => gulp.watch([diagnosticMessagesJson], [diagnosticInformationMapTs, builtGeneratedDiagnosticMessagesJson]));
473+
474+
gulp.task(
475+
"watch-lib",
476+
/*help*/ false,
477+
() => gulp.watch(["src/lib/**/*"], ["lib"]));
478+
479+
gulp.task(
480+
"watch-tsc",
481+
/*help*/ false,
482+
["watch-diagnostics", "watch-lib", typescriptServicesJs],
483+
() => project.watch(tscProject, { typescript: "built" }));
484+
485+
gulp.task(
486+
"watch-services",
487+
/*help*/ false,
488+
["watch-diagnostics", "watch-lib", typescriptServicesJs],
489+
() => project.watch(servicesProject, { typescript: "built" }));
490+
491+
gulp.task(
492+
"watch-server",
493+
/*help*/ false,
494+
["watch-diagnostics", "watch-lib", typescriptServicesJs],
495+
() => project.watch(tsserverProject, { typescript: "built" }));
496+
497+
gulp.task(
498+
"watch-local",
499+
/*help*/ false,
500+
["watch-lib", "watch-tsc", "watch-services", "watch-server"]);
501+
502+
gulp.task(
503+
"watch",
504+
"Watches for changes to the build inputs for built/local/run.js executes runtests-parallel.",
505+
[typescriptServicesJs],
506+
() => project.watch(testRunnerProject, { typescript: "built" }, ["runtests-parallel"]));
539507

540508
gulp.task("clean-built", /*help*/ false, ["clean:" + diagnosticInformationMapTs], () => del(["built"]));
541509
gulp.task(

0 commit comments

Comments
 (0)