Skip to content

Module conversion #46567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 17 additions & 5 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const { buildProject, cleanProject, watchProject } = require("./scripts/build/pr
const cmdLineOptions = require("./scripts/build/options");

const copyright = "CopyrightNotice.txt";
const testRootFile = "built/local/testRunner/Harness.js";
const testRootBundle = "built/local/run.js";
const testRoot = testRootBundle; // use testRootFile to run directly from the module files
const cleanTasks = [];

const buildScripts = () => buildProject("scripts");
Expand Down Expand Up @@ -125,6 +128,7 @@ const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagno
const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;

const buildServices = (() => {
return cb => { console.log("!!!TODO!!! buildServices"); cb(); };
// build typescriptServices.out.js
const buildTypescriptServicesOut = () => buildProject("src/typescriptServices/tsconfig.json", cmdLineOptions);

Expand Down Expand Up @@ -249,6 +253,7 @@ task("watch-min").flags = {
};

const buildLssl = (() => {
return cb => { console.log("!!!TODO!!! buildLssl"); cb(); };
// build tsserverlibrary.out.js
const buildServerLibraryOut = () => buildProject("src/tsserverlibrary/tsconfig.json", cmdLineOptions);

Expand Down Expand Up @@ -318,7 +323,14 @@ task("watch-lssl").flags = {
" --built": "Compile using the built version of the compiler."
};

const buildTests = () => buildProject("src/testRunner");
const buildTests = series(
() => buildProject("src/testRunner"),
() => exec("npx", [
"esbuild", "--bundle", "--format=cjs", "--platform=node", "--target=node12",
"--legal-comments=none",
`--outfile=${testRootBundle}`, testRootFile,
]),
);
task("tests", series(preBuild, parallel(buildLssl, buildTests)));
task("tests").description = "Builds the test infrastructure";
task("tests").flags = {
Expand Down Expand Up @@ -442,7 +454,7 @@ preTest.displayName = "preTest";

const postTest = (done) => cmdLineOptions.lint ? lint(done) : done();

const runTests = () => runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
const runTests = () => runConsoleTests(testRoot, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
task("runtests", series(preBuild, preTest, runTests, postTest));
task("runtests").description = "Runs the tests using the built run.js file.";
task("runtests").flags = {
Expand All @@ -462,7 +474,7 @@ task("runtests").flags = {
" --shardId": "1-based ID of this shard (default: 1)",
};

const runTestsParallel = () => runConsoleTests("built/local/run.js", "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
const runTestsParallel = () => runConsoleTests(testRoot, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
task("runtests-parallel", series(preBuild, preTest, runTestsParallel, postTest));
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
task("runtests-parallel").flags = {
Expand Down Expand Up @@ -611,10 +623,10 @@ task("publish-nightly").description = "Runs `npm publish --tag next` to create a
// write some kind of trigger file that indicates build completion that we could listen for instead.
const watchRuntests = () => watch(["built/local/*.js", "tests/cases/**/*.ts", "tests/cases/**/tsconfig.json"], { delay: 5000 }, async () => {
if (cmdLineOptions.tests || cmdLineOptions.failed) {
await runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true);
await runConsoleTests(testRoot, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true);
}
else {
await runConsoleTests("built/local/run.js", "min", /*runInParallel*/ true, /*watchMode*/ true);
await runConsoleTests(testRoot, "min", /*runInParallel*/ true, /*watchMode*/ true);
}
});
task("watch", series(preBuild, preTest, parallel(watchLib, watchDiagnostics, watchServices, watchLssl, watchTests, watchRuntests)));
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"convert-source-map": "latest",
"del": "5.1.0",
"diff": "^4.0.2",
"esbuild": "^0.13.8",
"eslint": "7.12.1",
"eslint-formatter-autolinkable-stylish": "1.1.4",
"eslint-plugin-import": "2.22.1",
Expand Down
2 changes: 2 additions & 0 deletions scripts/bisect-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//!!! should this be updated or removed?

/**
* You should have ts-node installed globally before executing this, probably!
* Otherwise you'll need to compile this script before you start bisecting!
Expand Down
34 changes: 17 additions & 17 deletions scripts/processDiagnosticMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ function main(): void {
}
}

const outputFilesDir = path.dirname(inputFilePath);
const thisFilePathRel = path.relative(process.cwd(), outputFilesDir);

const infoFileOutput = buildInfoFileOutput(diagnosticMessages, "./diagnosticInformationMap.generated.ts", thisFilePathRel);
const infoFileOutput = buildInfoFileOutput(diagnosticMessages, inputFilePath);
checkForUniqueCodes(diagnosticMessages);
writeFile("diagnosticInformationMap.generated.ts", infoFileOutput);

Expand All @@ -59,28 +56,31 @@ function checkForUniqueCodes(diagnosticTable: InputDiagnosticMessageTable) {
});
}

function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, inputFilePathRel: string, thisFilePathRel: string): string {
let result =
"// <auto-generated />\r\n" +
"// generated from '" + inputFilePathRel + "' by '" + thisFilePathRel.replace(/\\/g, "/") + "'\r\n" +
"/* @internal */\r\n" +
"namespace ts {\r\n" +
" function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean, reportsDeprecated?: {}): DiagnosticMessage {\r\n" +
" return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated };\r\n" +
" }\r\n" +
" export const Diagnostics = {\r\n";
function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, inputFilePathRel: string): string {
const result = [
"// <auto-generated />",
`// generated from '${inputFilePathRel}'`,
"",
"import { DiagnosticCategory, DiagnosticMessage } from \"./ts\";",
"",
"function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean, reportsDeprecated?: {}): DiagnosticMessage {",
" return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated };",
"}",
"",
"export const Diagnostics = {",
];
messageTable.forEach(({ code, category, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated }, name) => {
const propName = convertPropertyName(name);
const argReportsUnnecessary = reportsUnnecessary ? `, /*reportsUnnecessary*/ ${reportsUnnecessary}` : "";
const argElidedInCompatabilityPyramid = elidedInCompatabilityPyramid ? `${!reportsUnnecessary ? ", /*reportsUnnecessary*/ undefined" : ""}, /*elidedInCompatabilityPyramid*/ ${elidedInCompatabilityPyramid}` : "";
const argReportsDeprecated = reportsDeprecated ? `${!argElidedInCompatabilityPyramid ? ", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined" : ""}, /*reportsDeprecated*/ ${reportsDeprecated}` : "";

result += ` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}${argElidedInCompatabilityPyramid}${argReportsDeprecated}),\r\n`;
result.push(` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}${argElidedInCompatabilityPyramid}${argReportsDeprecated}),`);
});

result += " };\r\n}";
result.push("};");

return result;
return result.join("\r\n");
}

function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable): string {
Expand Down
4 changes: 2 additions & 2 deletions src/cancellationToken/cancellationToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="node"/>

import fs = require("fs");
import * as fs from "fs";

interface ServerCancellationToken {
isCancellationRequested(): boolean;
Expand Down Expand Up @@ -62,7 +62,7 @@ function createCancellationToken(args: string[]): ServerCancellationToken {
}
else {
return {
isCancellationRequested: () => pipeExists(cancellationPipeName!), // TODO: GH#18217
isCancellationRequested: () => pipeExists(cancellationPipeName!),
setRequest: (_requestId: number): void => void 0,
resetRequest: (_requestId: number): void => void 0
};
Expand Down
Loading