Skip to content

Commit 43b8ce6

Browse files
committed
Merge
2 parents e83a8ea + 009d9b4 commit 43b8ce6

File tree

4,185 files changed

+222971
-199444
lines changed

Some content is hidden

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

4,185 files changed

+222971
-199444
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ Jakefile.js
1616
.gitattributes
1717
.settings/
1818
.travis.yml
19-
.vscode/
19+
.vscode/
20+
test.config

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ matrix:
1616
branches:
1717
only:
1818
- master
19+
- release-2.5
1920

2021
install:
2122
- npm uninstall typescript --no-save

.vscode/tasks.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
"problemMatcher": [
1919
"$tsc"
2020
]
21+
},
22+
{
23+
"taskName": "tests",
24+
"showOutput": "silent",
25+
"problemMatcher": [
26+
"$tsc"
27+
]
2128
}
2229
]
2330
}

Gulpfile.ts

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import minimist = require("minimist");
2828
import browserify = require("browserify");
2929
import through2 = require("through2");
3030
import merge2 = require("merge2");
31-
import intoStream = require("into-stream");
3231
import * as os from "os";
3332
import fold = require("travis-fold");
3433
const gulp = helpMaker(originalGulp);
@@ -747,50 +746,75 @@ gulp.task(nodeServerOutFile, /*help*/ false, [servicesFile], () => {
747746

748747
import convertMap = require("convert-source-map");
749748
import sorcery = require("sorcery");
750-
declare module "convert-source-map" {
751-
export function fromSource(source: string, largeSource?: boolean): SourceMapConverter;
752-
}
749+
import Vinyl = require("vinyl");
753750

754-
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile, run], (done) => {
755-
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "../../built/local/bundle.js" }, /*useBuiltCompiler*/ true));
756-
return testProject.src()
757-
.pipe(newer("built/local/bundle.js"))
751+
const bundlePath = path.resolve("built/local/bundle.js");
752+
753+
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
754+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: bundlePath, inlineSourceMap: true }, /*useBuiltCompiler*/ true));
755+
let originalMap: any;
756+
let prebundledContent: string;
757+
browserify(testProject.src()
758+
.pipe(newer(bundlePath))
758759
.pipe(sourcemaps.init())
759760
.pipe(testProject())
760761
.pipe(through2.obj((file, enc, next) => {
761-
const originalMap = file.sourceMap;
762-
const prebundledContent = file.contents.toString();
762+
if (originalMap) {
763+
throw new Error("Should only recieve one file!");
764+
}
765+
console.log(`Saving sourcemaps for ${file.path}`);
766+
originalMap = file.sourceMap;
767+
prebundledContent = file.contents.toString();
763768
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
764769
originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s)));
765-
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
770+
// browserify names input files this when they are streamed in, so this is what it puts in the sourcemap
766771
originalMap.file = "built/local/_stream_0.js";
767772

768-
browserify(intoStream(file.contents), { debug: true })
769-
.bundle((err, res) => {
770-
// assumes file.contents is a Buffer
771-
const maps = JSON.parse(convertMap.fromSource(res.toString(), /*largeSource*/ true).toJSON());
772-
delete maps.sourceRoot;
773-
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
774-
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
775-
file.contents = new Buffer(convertMap.removeComments(res.toString()));
776-
const chain = sorcery.loadSync("built/local/bundle.js", {
777-
content: {
778-
"built/local/_stream_0.js": prebundledContent,
779-
"built/local/bundle.js": file.contents.toString()
780-
},
781-
sourcemaps: {
782-
"built/local/_stream_0.js": originalMap,
783-
"built/local/bundle.js": maps,
784-
"node_modules/source-map-support/source-map-support.js": undefined,
785-
}
786-
});
787-
const finalMap = chain.apply();
788-
file.sourceMap = finalMap;
789-
next(/*err*/ undefined, file);
790-
});
773+
next(/*err*/ undefined, file.contents);
791774
}))
792-
.pipe(sourcemaps.write(".", { includeContent: false }))
793-
.pipe(gulp.dest("src/harness"));
775+
.on("error", err => {
776+
return done(err);
777+
}), { debug: true, basedir: __dirname }) // Attach error handler to inner stream
778+
.bundle((err, contents) => {
779+
if (err) {
780+
if (err.message.match(/Cannot find module '.*_stream_0.js'/)) {
781+
return done(); // Browserify errors when we pass in no files when `newer` filters the input, we should count that as a success, though
782+
}
783+
return done(err);
784+
}
785+
const stringContent = contents.toString();
786+
const file = new Vinyl({ contents, path: bundlePath });
787+
console.log(`Fixing sourcemaps for ${file.path}`);
788+
// assumes contents is a Buffer, since that's what browserify yields
789+
const maps = convertMap.fromSource(stringContent, /*largeSource*/ true).toObject();
790+
delete maps.sourceRoot;
791+
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
792+
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
793+
file.contents = new Buffer(convertMap.removeComments(stringContent));
794+
const chain = sorcery.loadSync(bundlePath, {
795+
content: {
796+
"built/local/_stream_0.js": prebundledContent,
797+
[bundlePath]: stringContent
798+
},
799+
sourcemaps: {
800+
"built/local/_stream_0.js": originalMap,
801+
[bundlePath]: maps,
802+
"node_modules/source-map-support/source-map-support.js": undefined,
803+
}
804+
});
805+
const finalMap = chain.apply();
806+
file.sourceMap = finalMap;
807+
808+
const stream = through2.obj((file, enc, callback) => {
809+
return callback(/*err*/ undefined, file);
810+
});
811+
stream.pipe(sourcemaps.write(".", { includeContent: false }))
812+
.pipe(gulp.dest("."))
813+
.on("end", done)
814+
.on("error", done);
815+
stream.write(file);
816+
stream.end();
817+
});
794818
});
795819

796820

Jakefile.js

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ var harnessSources = harnessCoreSources.concat([
135135
"projectErrors.ts",
136136
"matchFiles.ts",
137137
"initializeTSConfig.ts",
138+
"extractMethods.ts",
138139
"printer.ts",
139140
"textChanges.ts",
140141
"telemetry.ts",
@@ -536,7 +537,6 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
536537
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
537538

538539
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
539-
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");
540540
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
541541
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
542542
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
@@ -575,22 +575,6 @@ compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].conc
575575
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
576576
});
577577

578-
compileFile(
579-
servicesFileInBrowserTest,
580-
servicesSources,
581-
[builtLocalDirectory, copyright].concat(servicesSources),
582-
/*prefixes*/[copyright],
583-
/*useBuiltCompiler*/ true,
584-
{
585-
noOutFile: false,
586-
generateDeclarations: true,
587-
preserveConstEnums: true,
588-
keepComments: true,
589-
noResolve: false,
590-
stripInternal: true,
591-
inlineSourceMap: true
592-
});
593-
594578
file(typescriptServicesDts, [servicesFile]);
595579

596580
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
@@ -737,7 +721,7 @@ compileFile(
737721
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
738722
/*prefixes*/[],
739723
/*useBuiltCompiler:*/ true,
740-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
724+
/*opts*/ { types: ["node", "mocha", "chai"], lib: "es6" });
741725

742726
var internalTests = "internal/";
743727

@@ -973,13 +957,14 @@ var nodeServerInFile = "tests/webTestServer.ts";
973957
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true, lib: "es6" });
974958

975959
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
976-
task("browserify", ["tests", run, builtLocalDirectory, nodeServerOutFile], function() {
977-
var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -d -o built/local/bundle.js';
960+
task("browserify", [], function() {
961+
// Shell out to `gulp`, since we do the work to handle sourcemaps correctly w/o inline maps there
962+
var cmd = 'gulp browserify --silent';
978963
exec(cmd);
979964
}, { async: true });
980965

981966
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], browser=[chrome|IE]");
982-
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function () {
967+
task("runtests-browser", ["browserify", nodeServerOutFile], function () {
983968
cleanTestDirs();
984969
host = "node";
985970
browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
@@ -1134,14 +1119,15 @@ task("update-sublime", ["local", serverFile], function () {
11341119

11351120
var tslintRuleDir = "scripts/tslint";
11361121
var tslintRules = [
1137-
"nextLineRule",
11381122
"booleanTriviaRule",
1139-
"typeOperatorSpacingRule",
1140-
"noInOperatorRule",
1123+
"debugAssertRule",
1124+
"nextLineRule",
1125+
"noBomRule",
11411126
"noIncrementDecrementRule",
1142-
"objectLiteralSurroundingSpaceRule",
1127+
"noInOperatorRule",
11431128
"noTypeAssertionWhitespaceRule",
1144-
"noBomRule"
1129+
"objectLiteralSurroundingSpaceRule",
1130+
"typeOperatorSpacingRule",
11451131
];
11461132
var tslintRulesFiles = tslintRules.map(function (p) {
11471133
return path.join(tslintRuleDir, p + ".ts");

lib/cancellationToken.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,3 @@ function createCancellationToken(args) {
6969
}
7070
}
7171
module.exports = createCancellationToken;
72-
73-
//# sourceMappingURL=cancellationToken.js.map

0 commit comments

Comments
 (0)