Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
single source for libs
  • Loading branch information
rbuckton committed Jun 9, 2017
commit e9818b40ee90bc3d5befb3eaa6a06a22eb9e82e2
54 changes: 17 additions & 37 deletions Gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import merge2 = require("merge2");
import intoStream = require("into-stream");
import * as os from "os";
import fold = require("travis-fold");
import ts = require("./lib/typescript");
const gulp = helpMaker(originalGulp);
const mochaParallel = require("./scripts/mocha-parallel.js");
const {runTestsInParallel} = mochaParallel;
Expand Down Expand Up @@ -67,6 +68,21 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
}
});

function readJson(jsonPath: string): any {
const jsonText = fs.readFileSync(jsonPath).toString();
const result = ts.parseConfigFileTextToJson(jsonPath, jsonText, /*stripComments*/ true);
if (result.error) {
throw new Error(diagnosticsToString([result.error]));
}

return result.config;

function diagnosticsToString(s: ts.Diagnostic[]) {
return s.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join(ts.sys.newLine);
}
}


function exec(cmd: string, args: string[], complete: () => void = (() => { }), error: (e: any, status: number) => void = (() => { })) {
console.log(`${cmd} ${args.join(" ")}`);
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
Expand Down Expand Up @@ -105,43 +121,7 @@ const nodeModulesPathPrefix = path.resolve("./node_modules/.bin/");
const isWin = /^win/.test(process.platform);
const mocha = path.join(nodeModulesPathPrefix, "mocha") + (isWin ? ".cmd" : "");

const librarySourceMap = [
// Host libraries
"dom.generated=lib.dom.d.ts",
"dom.iterable",
"webworker.generated=lib.webworker.d.ts",
"webworker.importscripts",
"scripthost",

// Javascript libraries
"es5",
"es2015",
"es2015.core",
"es2015.collection",
"es2015.generator",
"es2015.iterable",
"es2015.promise",
"es2015.proxy",
"es2015.reflect",
"es2015.symbol",
"es2015.symbol.wellknown",
"es2016",
"es2016.array.include",
"es2017",
"es2017.object",
"es2017.sharedmemory",
"es2017.string",
"es2017.intl",
"esnext",
"esnext.asynciterable",

// Default libraries
"default.es5=lib.d.ts",
"default.es2015=lib.es6.d.ts",
"default.es2016=lib.es2016.full.d.ts",
"default.es2017=lib.es2017.full.d.ts",
"default.esnext=lib.esnext.full.d.ts",
].map(function (lib) {
const librarySourceMap = (readJson(path.resolve("./src/lib/libs.json")) as string[]).map(function (lib) {
const parts = lib.split("=", 2);
return {
sources: ["header.d.ts", parts[0] + ".d.ts"],
Expand Down
64 changes: 17 additions & 47 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,30 @@ else if (process.env.PATH !== undefined) {
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
}

function filesFromConfig(configPath) {
var configText = fs.readFileSync(configPath).toString();
var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true);
if (config.error) {
throw new Error(diagnosticsToString([config.error]));
}
const configFileContent = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));
if (configFileContent.errors && configFileContent.errors.length) {
throw new Error(diagnosticsToString(configFileContent.errors));
function readJson(jsonPath) {
var jsonText = fs.readFileSync(jsonPath).toString();
var result = ts.parseConfigFileTextToJson(jsonPath, jsonText, /*stripComments*/ true);
if (result.error) {
throw new Error(diagnosticsToString([result.error]));
}

return configFileContent.fileNames;
return result.config;

function diagnosticsToString(s) {
return s.map(function(e) { return ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine); }).join(ts.sys.newLine);
}
}

function filesFromConfig(configPath) {
var config = readJson(configPath);
var configFileContent = ts.parseJsonConfigFileContent(config, ts.sys, path.dirname(configPath));
if (configFileContent.errors && configFileContent.errors.length) {
throw new Error(diagnosticsToString(configFileContent.errors));
}

return configFileContent.fileNames;
}

function toNs(diff) {
return diff[0] * 1e9 + diff[1];
}
Expand Down Expand Up @@ -148,43 +154,7 @@ var harnessSources = harnessCoreSources.concat([
return path.join(serverDirectory, f);
}));

var librarySourceMap = [
// Host libraries
"dom.generated=lib.dom.d.ts",
"dom.iterable",
"webworker.generated=lib.webworker.d.ts",
"webworker.importscripts",
"scripthost",

// Javascript libraries
"es5",
"es2015",
"es2015.core",
"es2015.collection",
"es2015.generator",
"es2015.iterable",
"es2015.promise",
"es2015.proxy",
"es2015.reflect",
"es2015.symbol",
"es2015.symbol.wellknown",
"es2016",
"es2016.array.include",
"es2017",
"es2017.object",
"es2017.sharedmemory",
"es2017.string",
"es2017.intl",
"esnext",
"esnext.asynciterable",

// Default libraries
"default.es5=lib.d.ts",
"default.es2015=lib.es6.d.ts",
"default.es2016=lib.es2016.full.d.ts",
"default.es2017=lib.es2017.full.d.ts",
"default.esnext=lib.esnext.full.d.ts",
].map(function (lib) {
var librarySourceMap = readJson(path.resolve("./src/lib/libs.json")).map(function (lib) {
var parts = lib.split("=", 2);
return {
sources: ["header.d.ts", parts[0] + ".d.ts"],
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ts {
"dom.iterable": "lib.dom.iterable.d.ts",
"webworker": "lib.webworker.d.ts",
"scripthost": "lib.scripthost.d.ts",
// ES2015 Or ESNext By-feature options
// By-feature options
"es2015.core": "lib.es2015.core.d.ts",
"es2015.collection": "lib.es2015.collection.d.ts",
"es2015.generator": "lib.es2015.generator.d.ts",
Expand All @@ -41,10 +41,10 @@ namespace ts {
});

/* @internal */
// We only support "webworker.importscripts" when used as part of a default lib. It's not available
// on the command line.
// Internally we add some additional lib references that we only support when used as part of a
// "lib" reference directive. They are not available on the command line or in tsconfig.json.
export const libMap = cloneMap(commandLineLibMap)
.set("webworker.importscripts", "lib.webworker.importscripts.d.ts");
.set("webworker.importscripts", "lib.webworker.importscripts.d.ts");

/* @internal */
export const libs = arrayFrom(commandLineLibMap.keys());
Expand Down
36 changes: 36 additions & 0 deletions src/lib/libs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
// JavaScript only
"es5",
"es2015",
"es2016",
"es2017",
"esnext",
// Host only
"dom.generated=lib.dom.d.ts",
"dom.iterable",
"webworker.generated=lib.webworker.d.ts",
"webworker.importscripts",
"scripthost",
// By-feature options
"es2015.core",
"es2015.collection",
"es2015.generator",
"es2015.iterable",
"es2015.promise",
"es2015.proxy",
"es2015.reflect",
"es2015.symbol",
"es2015.symbol.wellknown",
"es2016.array.include",
"es2017.object",
"es2017.sharedmemory",
"es2017.string",
"es2017.intl",
"esnext.asynciterable",
// Default libraries
"default.es5=lib.d.ts",
"default.es2015=lib.es6.d.ts",
"default.es2016=lib.es2016.full.d.ts",
"default.es2017=lib.es2017.full.d.ts",
"default.esnext=lib.esnext.full.d.ts"
]