diff --git a/Gulpfile.js b/Gulpfile.js index d8bf3fe867862..18128b3915992 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -3,23 +3,49 @@ const path = require("path"); const fs = require("fs"); const log = require("fancy-log"); const newer = require("gulp-newer"); -const sourcemaps = require("gulp-sourcemaps"); const del = require("del"); const rename = require("gulp-rename"); const concat = require("gulp-concat"); const merge2 = require("merge2"); const { src, dest, task, parallel, series, watch } = require("gulp"); -const { append, transform } = require("gulp-insert"); -const { prependFile } = require("./scripts/build/prepend"); +const { transform } = require("gulp-insert"); const { exec, readJson, needsUpdate, getDiffTool, getDirSize, rm } = require("./scripts/build/utils"); const { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests"); -const { buildProject, cleanProject, watchProject } = require("./scripts/build/projects"); +const { buildProject: realBuildProject, cleanProject, watchProject } = require("./scripts/build/projects"); const cmdLineOptions = require("./scripts/build/options"); +const esbuild = require("esbuild"); const copyright = "CopyrightNotice.txt"; const cleanTasks = []; -const testRunner = "./built/local/testRunner/runner.js"; + +// TODO(jakebailey): This is really gross. Waiting on: https://github.com/microsoft/TypeScript/issues/25613 +let currentlyBuilding = 0; +let oldTsconfigBase; + +/** @type {typeof realBuildProject} */ +const buildProjectWithEmit = async (...args) => { + const tsconfigBasePath = "./src/tsconfig-base.json"; + + if (currentlyBuilding === 0) { + oldTsconfigBase = fs.readFileSync(tsconfigBasePath, "utf-8"); + fs.writeFileSync(tsconfigBasePath, oldTsconfigBase.replace(`"emitDeclarationOnly": true`, `"emitDeclarationOnly": false`));; + } + + currentlyBuilding++; + + await realBuildProject(...args); + + currentlyBuilding--; + + if (currentlyBuilding === 0) { + fs.writeFileSync(tsconfigBasePath, oldTsconfigBase); + } +}; + + +const buildProject = cmdLineOptions.bundle ? realBuildProject : buildProjectWithEmit; + const buildScripts = () => buildProject("scripts"); task("scripts", buildScripts); @@ -94,11 +120,17 @@ const localize = async () => { } }; -const buildAll = () => buildProject("src"); +const preSrc = parallel(generateLibs, series(buildScripts, generateDiagnostics, localize)); +const buildSrc = () => buildProject("src"); -task("moduleBuild", parallel(generateLibs, series(buildScripts, localize, buildAll))); +// TODO(jakebailey): when should we run this? it's nice to have tests run quickly, but we also want to know if the code is broken. +// But, if we are bundling, we are running only d.ts emit, so maybe this is fast? +task("buildSrc", series(preSrc, buildSrc)); const apiExtractor = async () => { + /** + * @param {string} configPath + */ async function runApiExtractor(configPath) { await exec(process.execPath, [ "node_modules/@microsoft/api-extractor/bin/api-extractor", @@ -114,25 +146,111 @@ const apiExtractor = async () => { await runApiExtractor("./src/tsserverlibrary/api-extractor.json"); }; -task("api-extractor", series(task("moduleBuild"), apiExtractor)); +// TODO(jakebailey): Some tests depend on the extracted output. +task("api-extractor", series(preSrc, buildSrc, apiExtractor)); + +/** @type {string | undefined} */ +let copyrightHeader; +function getCopyrightHeader() { + if (copyrightHeader === undefined) { + copyrightHeader = fs.readFileSync(copyright, "utf-8"); + } + return copyrightHeader; +} + +/** + * @param {string} entrypoint + * @param {string} outfile + * @param {boolean} exportIsTsObject True if this file exports the TS object and should have relevant code injected. + */ +function esbuildTask(entrypoint, outfile, exportIsTsObject = false) { + /** @type {esbuild.BuildOptions} */ + const options = { + entryPoints: [entrypoint], + banner: { js: getCopyrightHeader() }, + bundle: true, + outfile, + platform: "node", + // TODO: also specify minimal browser targets + target: "node10", // Node 10 is the oldest benchmarker. + format: "cjs", + sourcemap: true, + external: ["./node_modules/*"], // TODO(jakebailey): does the test runner import relatively from scripts? + conditions: ["require"], + supported: { + // "const-and-let": false, // Unfortunately, no: https://github.com/evanw/esbuild/issues/297 + "object-rest-spread": false, // See: https://github.com/evanw/esbuild/releases/tag/v0.14.46 + }, + // legalComments: "none", // TODO(jakebailey): enable once we add copyright headers to our source files. + // logLevel: "info", + }; + + if (exportIsTsObject) { + options.format = "iife"; // We use an IIFE so we can inject the code below. + options.globalName = "ts"; // Name the variable ts, matching our old big bundle and so we can use the code below. + options.footer = { + // These snippets cannot appear in the actual source files, otherwise they will be rewritten + // to things like exports or requires. + js: ` + if (typeof module !== "undefined" && module.exports) { + // If we are in a CJS context, export the ts namespace. + module.exports = ts; + } + if (ts.server) { + // If we are in a server bundle, inject the dynamicImport function. + ts.server.dynamicImport = id => import(id); + } + ` + }; + } + + // TODO: these need to have better function names, for gulp. + return { + build: () => esbuild.build(options), + clean: () => del([outfile, `${outfile}.map`]), + watch: () => esbuild.build({ ...options, watch: true }), + }; +} + +/** + * Creates a function that writes a CJS module that reexports another CJS file via + * `module.exports = require("...")`. + * + * @param {string} infile Relative path from the repo root to the file to be required. + * @param {string} outfile Relative path from the repo root to the output file. + * @returns {(done: () => void) => void} A function that can be passed to gulp. + */ + function writeCJSReexport(infile, outfile) { + return (done) => { + const inRelativeToOut = infile = path.relative(path.dirname(outfile), infile); + fs.writeFileSync(outfile, `module.exports = require("./${inRelativeToOut}")`); + done(); + }; +}; + +const esbuildDebugTools = esbuildTask("./src/debug/compilerDebug.ts", "./built/local/compilerDebug.js"); -const buildDebugTools = () => buildProject("src/debug"); -const cleanDebugTools = () => cleanProject("src/debug"); +const buildDebugTools = () => cmdLineOptions.bundle ? esbuildDebugTools.build() : buildProject("src/debug"); +const cleanDebugTools = () => cmdLineOptions.bundle ? esbuildDebugTools.build() : cleanProject("src/debug"); cleanTasks.push(cleanDebugTools); // Pre-build steps when targeting the LKG compiler const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildDebugTools)); -const buildTsc = () => buildProject("src/tsc"); + +const esbuildTsc = esbuildTask("./src/tsc/tsc.ts", "./built/local/tsc.js", /* exportIsTsObject */ true); + + +const buildTsc = () => cmdLineOptions.bundle ? esbuildTsc.build() : buildProject("src/tsc"); task("tsc", series(lkgPreBuild, buildTsc)); task("tsc").description = "Builds the command-line compiler"; -const cleanTsc = () => cleanProject("src/tsc"); +const cleanTsc = () => cmdLineOptions.bundle ? esbuildTsc.clean() : cleanProject("src/tsc"); cleanTasks.push(cleanTsc); task("clean-tsc", cleanTsc); task("clean-tsc").description = "Cleans outputs for the command-line compiler"; -const watchTsc = () => watchProject("src/tsc"); +const watchTsc = () => cmdLineOptions.bundle ? esbuildTsc.watch() : watchProject("src/tsc"); task("watch-tsc", series(lkgPreBuild, parallel(watchLib, watchDiagnostics, watchTsc))); task("watch-tsc").description = "Watch for changes and rebuild the command-line compiler only."; @@ -142,107 +260,34 @@ const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagno // Pre-build steps to use based on supplied options. const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild; -const buildServices = (() => { - // TODO(jakebailey): fix this for modules - return cb => { - console.log("!!!TODO!!! buildServices"); - cb(); - }; +const esbuildServices = esbuildTask("./src/typescript/typescript.ts", "./built/local/typescript.js", /* exportIsTsObject */ true); + +const buildServices = () => cmdLineOptions.bundle ? esbuildServices.build() : buildProject("src/typescript"); - // build typescriptServices.out.js - const buildTypescriptServicesOut = () => buildProject("src/typescriptServices/tsconfig.json", cmdLineOptions); - - // create typescriptServices.js - const createTypescriptServicesJs = () => src("built/local/typescriptServices.out.js") - .pipe(newer("built/local/typescriptServices.js")) - .pipe(sourcemaps.init({ loadMaps: true })) - .pipe(prependFile(copyright)) - .pipe(rename("typescriptServices.js")) - .pipe(sourcemaps.write(".", { includeContent: false, destPath: "built/local" })) - .pipe(dest("built/local")); - - // create typescriptServices.d.ts - const createTypescriptServicesDts = () => src("built/local/typescriptServices.out.d.ts") - .pipe(newer("built/local/typescriptServices.d.ts")) - .pipe(prependFile(copyright)) - .pipe(transform(content => content.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, "$1$2enum $3 {$4"))) - .pipe(rename("typescriptServices.d.ts")) - .pipe(dest("built/local")); - - // create typescript.js - const createTypescriptJs = () => src("built/local/typescriptServices.js") - .pipe(newer("built/local/typescript.js")) - .pipe(sourcemaps.init({ loadMaps: true })) - .pipe(rename("typescript.js")) - .pipe(sourcemaps.write(".", { includeContent: false, destPath: "built/local" })) - .pipe(dest("built/local")); - - // create typescript.d.ts - const createTypescriptDts = () => src("built/local/typescriptServices.d.ts") - .pipe(newer("built/local/typescript.d.ts")) - .pipe(append("\nexport = ts;")) - .pipe(rename("typescript.d.ts")) - .pipe(dest("built/local")); - - // // create typescript_standalone.d.ts - // const createTypescriptStandaloneDts = () => src("built/local/typescriptServices.d.ts") - // .pipe(newer("built/local/typescript_standalone.d.ts")) - // .pipe(transform(content => content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'))) - // .pipe(rename("typescript_standalone.d.ts")) - // .pipe(dest("built/local")); - - return series( - buildTypescriptServicesOut, - createTypescriptServicesJs, - createTypescriptServicesDts, - createTypescriptJs, - createTypescriptDts, - // createTypescriptStandaloneDts, - ); -})(); task("services", series(preBuild, buildServices)); task("services").description = "Builds the language service"; task("services").flags = { " --built": "Compile using the built version of the compiler." }; -const cleanServices = async () => { - if (fs.existsSync("built/local/typescriptServices.tsconfig.json")) { - await cleanProject("built/local/typescriptServices.tsconfig.json"); - } - await del([ - "built/local/typescriptServices.out.js", - "built/local/typescriptServices.out.d.ts", - "built/local/typescriptServices.out.tsbuildinfo", - "built/local/typescriptServices.js", - "built/local/typescript.js", - "built/local/typescript.d.ts", - "built/local/typescript_standalone.d.ts" - ]); -}; +const cleanServices = () => cmdLineOptions.bundle ? esbuildServices.clean() : cleanProject("src/typescript"); + cleanTasks.push(cleanServices); task("clean-services", cleanServices); task("clean-services").description = "Cleans outputs for the language service"; -const watchServices = () => watch([ - "src/compiler/tsconfig.json", - "src/compiler/**/*.ts", - "src/jsTyping/tsconfig.json", - "src/jsTyping/**/*.ts", - "src/services/tsconfig.json", - "src/services/**/*.ts", -], series(preBuild, buildServices)); +// TODO(jakebailey): this is probably wrong. +const watchServices = () => cmdLineOptions.bundle ? esbuildServices.watch() : watchProject("src/typescript"); task("watch-services", series(preBuild, parallel(watchLib, watchDiagnostics, watchServices))); task("watch-services").description = "Watches for changes and rebuild language service only"; task("watch-services").flags = { " --built": "Compile using the built version of the compiler." }; -const buildDynamicImportCompat = () => buildProject("src/dynamicImportCompat", cmdLineOptions); -task("dynamicImportCompat", buildDynamicImportCompat); -const buildServerMain = () => buildProject("src/tsserver", cmdLineOptions); -const buildServer = series(buildDynamicImportCompat, buildServerMain); +const esbuildServer = esbuildTask("./src/tsserver/server.ts", "./built/local/tsserver.js", /* exportIsTsObject */ true); + +const buildServer = () => cmdLineOptions.bundle ? esbuildServer.build() : buildProject("src/tsserver"); buildServer.displayName = "buildServer"; task("tsserver", series(preBuild, buildServer)); task("tsserver").description = "Builds the language server"; @@ -250,17 +295,14 @@ task("tsserver").flags = { " --built": "Compile using the built version of the compiler." }; -const cleanDynamicImportCompat = () => cleanProject("src/dynamicImportCompat"); -const cleanServerMain = () => cleanProject("src/tsserver"); -const cleanServer = series(cleanDynamicImportCompat, cleanServerMain); +const cleanServer = () => cmdLineOptions.bundle ? esbuildServer.clean() : cleanProject("src/tsserver"); cleanServer.displayName = "cleanServer"; cleanTasks.push(cleanServer); task("clean-tsserver", cleanServer); task("clean-tsserver").description = "Cleans outputs for the language server"; -const watchDynamicImportCompat = () => watchProject("src/dynamicImportCompat", cmdLineOptions); -const watchServer = () => watchProject("src/tsserver", cmdLineOptions); -task("watch-tsserver", series(preBuild, parallel(watchLib, watchDiagnostics, watchDynamicImportCompat, watchServer))); +const watchServer = () => cmdLineOptions.bundle ? esbuildServer.watch() : watchProject("src/tsserver"); +task("watch-tsserver", series(preBuild, parallel(watchLib, watchDiagnostics, watchServer))); task("watch-tsserver").description = "Watch for changes and rebuild the language server only"; task("watch-tsserver").flags = { " --built": "Compile using the built version of the compiler." @@ -281,95 +323,45 @@ task("watch-min").flags = { " --built": "Compile using the built version of the compiler." }; -const buildLssl = (() => { - // TODO(jakebailey): fix this for modules - return cb => { - console.log("!!!TODO!!! buildLssl"); - cb(); - }; +const esbuildLssl = esbuildTask("./src/tsserverlibrary/tsserverlibrary.ts", "./built/local/tsserverlibrary.js", /* exportIsTsObject */ true); - // build tsserverlibrary.out.js - const buildServerLibraryOut = () => buildProject("src/tsserverlibrary/tsconfig.json", cmdLineOptions); - - // create tsserverlibrary.js - const createServerLibraryJs = () => src("built/local/tsserverlibrary.out.js") - .pipe(newer("built/local/tsserverlibrary.js")) - .pipe(sourcemaps.init({ loadMaps: true })) - .pipe(prependFile(copyright)) - .pipe(rename("tsserverlibrary.js")) - .pipe(sourcemaps.write(".", { includeContent: false, destPath: "built/local" })) - .pipe(dest("built/local")); - - // create tsserverlibrary.d.ts - const createServerLibraryDts = () => src("built/local/tsserverlibrary.out.d.ts") - .pipe(newer("built/local/tsserverlibrary.d.ts")) - .pipe(prependFile(copyright)) - .pipe(transform(content => content.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, "$1$2enum $3 {$4"))) - .pipe(append("\nexport = ts;\nexport as namespace ts;")) - .pipe(rename("tsserverlibrary.d.ts")) - .pipe(dest("built/local")); - - return series( - buildServerLibraryOut, - createServerLibraryJs, - createServerLibraryDts, - ); -})(); +const buildLssl = () => cmdLineOptions.bundle ? esbuildLssl.build() : buildProject("src/tsserverlibrary"); task("lssl", series(preBuild, buildLssl)); task("lssl").description = "Builds language service server library"; task("lssl").flags = { " --built": "Compile using the built version of the compiler." }; -const cleanLssl = async () => { - if (fs.existsSync("built/local/tsserverlibrary.tsconfig.json")) { - await cleanProject("built/local/tsserverlibrary.tsconfig.json"); - } - await del([ - "built/local/tsserverlibrary.out.js", - "built/local/tsserverlibrary.out.d.ts", - "built/local/tsserverlibrary.out.tsbuildinfo", - "built/local/tsserverlibrary.js", - "built/local/tsserverlibrary.d.ts", - ]); -}; +const cleanLssl = () => cmdLineOptions.bundle ? esbuildLssl.clean() : cleanProject("src/tsserverlibrary"); cleanTasks.push(cleanLssl); task("clean-lssl", cleanLssl); task("clean-lssl").description = "Clean outputs for the language service server library"; -const watchLssl = () => watch([ - "src/compiler/tsconfig.json", - "src/compiler/**/*.ts", - "src/jsTyping/tsconfig.json", - "src/jsTyping/**/*.ts", - "src/services/tsconfig.json", - "src/services/**/*.ts", - "src/server/tsconfig.json", - "src/server/**/*.ts", - "src/webServer/tsconfig.json", - "src/webServer/**/*.ts", - "src/tsserver/tsconfig.json", - "src/tsserver/**/*.ts", -], buildLssl); +// TODO(jakebailey): this is probably wrong. +const watchLssl = () => cmdLineOptions.bundle ? esbuildLssl.watch() : watchProject("src/tsserverlibrary"); + task("watch-lssl", series(preBuild, parallel(watchLib, watchDiagnostics, watchLssl))); task("watch-lssl").description = "Watch for changes and rebuild tsserverlibrary only"; task("watch-lssl").flags = { " --built": "Compile using the built version of the compiler." }; -const buildTests = () => buildProject("src/testRunner"); +const testRunner = cmdLineOptions.bundle ? "./built/local/run.js" : "./built/local/testRunner/runner.js"; +const esbuildTests = esbuildTask("./src/testRunner/_namespaces/Harness.ts", testRunner); + +const buildTests = () => cmdLineOptions.bundle ? esbuildTests.build() : buildProject("src/testRunner"); task("tests", series(preBuild, parallel(buildLssl, buildTests))); task("tests").description = "Builds the test infrastructure"; task("tests").flags = { " --built": "Compile using the built version of the compiler." }; -const cleanTests = () => cleanProject("src/testRunner"); +const cleanTests = () => cmdLineOptions.bundle ? esbuildTests.clean() : cleanProject("src/testRunner"); cleanTasks.push(cleanTests); task("clean-tests", cleanTests); task("clean-tests").description = "Cleans the outputs for the test infrastructure"; -const watchTests = () => watchProject("src/testRunner", cmdLineOptions); +const watchTests = () => cmdLineOptions.bundle ? esbuildTests.watch() : watchProject("src/testRunner"); const buildEslintRules = () => buildProject("scripts/eslint"); task("build-eslint-rules", buildEslintRules); @@ -409,16 +401,28 @@ lint.displayName = "lint"; task("lint", lint); task("lint").description = "Runs eslint on the compiler and scripts sources."; -const buildCancellationToken = () => buildProject("src/cancellationToken"); -const cleanCancellationToken = () => cleanProject("src/cancellationToken"); + +const esbuildCancellationToken = esbuildTask("./src/cancellationToken/cancellationToken.ts", "./built/local/cancellationToken.js"); + +const buildCancellationToken = () => cmdLineOptions.bundle ? esbuildCancellationToken.build() : buildProject("src/cancellationToken"); +const cleanCancellationToken = () => cmdLineOptions.bundle ? esbuildCancellationToken.clean() : cleanProject("src/cancellationToken"); cleanTasks.push(cleanCancellationToken); -const buildTypingsInstaller = () => buildProject("src/typingsInstaller"); -const cleanTypingsInstaller = () => cleanProject("src/typingsInstaller"); +const esbuildTypingsInstaller = esbuildTask("./src/typingsInstaller/nodeTypingsInstaller.ts", "./built/local/typingsInstaller.js"); + +const buildTypingsInstaller = () => { + if (cmdLineOptions.bundle) return esbuildTypingsInstaller.build(); + // TODO(jakebailey): In --bundle=false, can we emit to this directly? + writeCJSReexport("./built/typingsInstaller/nodeTypingsInstaller.js", "./built/local/typingsInstaller.js"); + return buildProject("src/typingsInstaller"); +}; +const cleanTypingsInstaller = () => cmdLineOptions.bundle ? esbuildTypingsInstaller.clean() : cleanProject("src/typingsInstaller"); cleanTasks.push(cleanTypingsInstaller); -const buildWatchGuard = () => buildProject("src/watchGuard"); -const cleanWatchGuard = () => cleanProject("src/watchGuard"); +const esbuildWatchGuard = esbuildTask("./src/typingsInstaller/nodeTypingsInstaller.ts", "./built/local/typingsInstaller.js"); + +const buildWatchGuard = () => cmdLineOptions.bundle ? esbuildWatchGuard.build() : buildProject("src/watchGuard"); +const cleanWatchGuard = () => cmdLineOptions.bundle ? esbuildWatchGuard.clean() : cleanProject("src/watchGuard"); cleanTasks.push(cleanWatchGuard); const generateTypesMap = () => src("src/server/typesMap.json") @@ -461,7 +465,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl); preTest.displayName = "preTest"; const runTests = () => runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false); -task("runtests", series(/*preBuild, preTest,*/ task("moduleBuild"), runTests)); // TODO(jakebailey): fix this for modules +task("runtests", series(preBuild, preTest, runTests)); task("runtests").description = "Runs the tests using the built run.js file."; task("runtests").flags = { "-t --tests=": "Pattern for tests to run.", @@ -480,7 +484,7 @@ task("runtests").flags = { }; const runTestsParallel = () => runConsoleTests(testRunner, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false); -task("runtests-parallel", series(/*preBuild, preTest,*/ task("moduleBuild"), runTestsParallel)); // TODO(jakebailey): fix this for modules +task("runtests-parallel", series(preBuild, preTest, runTestsParallel)); task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file."; task("runtests-parallel").flags = { " --light": "Run tests in light mode (fewer verifications, but tests run faster).", @@ -522,6 +526,8 @@ task("baseline-accept").description = "Makes the most recent test results the ne task("baseline-accept-rwc", () => baselineAccept(localRwcBaseline, refRwcBaseline)); task("baseline-accept-rwc").description = "Makes the most recent rwc test results the new baseline, overwriting the old baseline"; +// TODO(jakebailey): figure out what tsc-instrumented and such are for and what do to with them. + const buildLoggedIO = () => buildProject("src/loggedIO/tsconfig-tsc-instrumented.json"); const cleanLoggedIO = () => del("built/local/loggedIO.js"); cleanTasks.push(cleanLoggedIO); @@ -553,6 +559,9 @@ const importDefinitelyTypedTests = () => exec(process.execPath, ["scripts/import task("importDefinitelyTypedTests", series(buildImportDefinitelyTypedTests, importDefinitelyTypedTests)); task("importDefinitelyTypedTests").description = "Runs the importDefinitelyTypedTests script to copy DT's tests to the TS-internal RWC tests"; +// TODO(jakebailey): There isn't a release build anymore; figure out what to do here. +// Probably just use tsc.js. + const buildReleaseTsc = () => buildProject("src/tsc/tsconfig.release.json"); const cleanReleaseTsc = () => cleanProject("src/tsc/tsconfig.release.json"); cleanTasks.push(cleanReleaseTsc); @@ -565,7 +574,6 @@ const produceLKG = async () => { "built/local/typescriptServices.js", "built/local/typescriptServices.d.ts", "built/local/tsserver.js", - "built/local/dynamicImportCompat.js", "built/local/typescript.js", "built/local/typescript.d.ts", "built/local/tsserverlibrary.js", @@ -601,6 +609,8 @@ task("generate-spec").description = "Generates a Markdown version of the Languag task("clean", series(parallel(cleanTasks), cleanBuilt)); task("clean").description = "Cleans build outputs"; +// TODO(jakebailey): Figure out what needs to change below. + const configureNightly = () => exec(process.execPath, ["scripts/configurePrerelease.js", "dev", "package.json", "src/compiler/corePublic.ts"]); task("configure-nightly", series(buildScripts, configureNightly)); task("configure-nightly").description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing"; diff --git a/package-lock.json b/package-lock.json index d70d6613a65b8..eacf38822f931 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "chalk": "^4.1.2", "del": "^6.1.1", "diff": "^5.1.0", + "esbuild": "^0.15.8", "eslint": "^8.22.0", "eslint-formatter-autolinkable-stylish": "^1.2.0", "eslint-plugin-import": "^2.26.0", @@ -89,6 +90,41 @@ "node": "^14 || ^16 || ^17 || ^18" } }, + "node_modules/@esbuild/android-arm": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.8.tgz", + "integrity": "sha512-CyEWALmn+no/lbgbAJsbuuhT8s2J19EJGHkeyAwjbFJMrj80KJ9zuYsoAvidPTU7BgBf87r/sgae8Tw0dbOc4Q==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "dependencies": { + "esbuild-wasm": "0.15.8" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.8.tgz", + "integrity": "sha512-pE5RQsOTSERCtfZdfCT25wzo7dfhOSlhAXcsZmuvRYhendOv7djcdvtINdnDp2DAjP17WXlBB4nBO6sHLczmsg==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", @@ -2510,6 +2546,379 @@ "es6-symbol": "^3.1.1" } }, + "node_modules/esbuild": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.8.tgz", + "integrity": "sha512-Remsk2dmr1Ia65sU+QasE6svJbsHe62lzR+CnjpUvbZ+uSYo1SitiOWPRfZQkCu82YWZBBKXiD/j0i//XWMZ+Q==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.15.8", + "@esbuild/linux-loong64": "0.15.8", + "esbuild-android-64": "0.15.8", + "esbuild-android-arm64": "0.15.8", + "esbuild-darwin-64": "0.15.8", + "esbuild-darwin-arm64": "0.15.8", + "esbuild-freebsd-64": "0.15.8", + "esbuild-freebsd-arm64": "0.15.8", + "esbuild-linux-32": "0.15.8", + "esbuild-linux-64": "0.15.8", + "esbuild-linux-arm": "0.15.8", + "esbuild-linux-arm64": "0.15.8", + "esbuild-linux-mips64le": "0.15.8", + "esbuild-linux-ppc64le": "0.15.8", + "esbuild-linux-riscv64": "0.15.8", + "esbuild-linux-s390x": "0.15.8", + "esbuild-netbsd-64": "0.15.8", + "esbuild-openbsd-64": "0.15.8", + "esbuild-sunos-64": "0.15.8", + "esbuild-windows-32": "0.15.8", + "esbuild-windows-64": "0.15.8", + "esbuild-windows-arm64": "0.15.8" + } + }, + "node_modules/esbuild-android-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.8.tgz", + "integrity": "sha512-bVh8FIKOolF7/d4AMzt7xHlL0Ljr+mYKSHI39TJWDkybVWHdn6+4ODL3xZGHOxPpdRpitemXA1WwMKYBsw8dGw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "dependencies": { + "esbuild-wasm": "0.15.8" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-android-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.8.tgz", + "integrity": "sha512-ReAMDAHuo0H1h9LxRabI6gwYPn8k6WiUeyxuMvx17yTrJO+SCnIfNc/TSPFvDwtK9MiyiKG/2dBYHouT/M0BXQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.8.tgz", + "integrity": "sha512-KaKcGfJ+yto7Fo5gAj3xwxHMd1fBIKatpCHK8znTJLVv+9+NN2/tIPBqA4w5rBwjX0UqXDeIE2v1xJP+nGEXgA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.8.tgz", + "integrity": "sha512-8tjEaBgAKnXCkP7bhEJmEqdG9HEV6oLkF36BrMzpfW2rgaw0c48Zrxe+9RlfeGvs6gDF4w+agXyTjikzsS3izw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.8.tgz", + "integrity": "sha512-jaxcsGHYzn2L0/lffON2WfH4Nc+d/EwozVTP5K2v016zxMb5UQMhLoJzvLgBqHT1SG0B/mO+a+THnJCMVg15zw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.8.tgz", + "integrity": "sha512-2xp2UlljMvX8HExtcg7VHaeQk8OBU0CSl1j18B5CcZmSDkLF9p3utuMXIopG3a08fr9Hv+Dz6+seSXUow/G51w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-32": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.8.tgz", + "integrity": "sha512-9u1E54BRz1FQMl86iaHK146+4ID2KYNxL3trLZT4QLLx3M7Q9n4lGG3lrzqUatGR2cKy8c33b0iaCzsItZWkFg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.8.tgz", + "integrity": "sha512-4HxrsN9eUzJXdVGMTYA5Xler82FuZUu21bXKN42zcLHHNKCAMPUzD62I+GwDhsdgUBAUj0tRXDdsQHgaP6v0HA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.8.tgz", + "integrity": "sha512-7DVBU9SFjX4+vBwt8tHsUCbE6Vvl6y6FQWHAgyw1lybC5gULqn/WnjHYHN2/LJaZRsDBvxWT4msEgwLGq1Wd3Q==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.8.tgz", + "integrity": "sha512-1OCm7Aq0tEJT70PbxmHSGYDLYP8DKH8r4Nk7/XbVzWaduo9beCjGBB+tGZIHK6DdTQ3h00/4Tb/70YMH/bOtKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-mips64le": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.8.tgz", + "integrity": "sha512-yeFoNPVFPEzZvFYBfUQNG2TjGRaCyV1E27OcOg4LOtnGrxb2wA+mkW3luckyv1CEyd00mpAg7UdHx8nlx3ghgA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-ppc64le": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.8.tgz", + "integrity": "sha512-CEyMMUUNabXibw8OSNmBXhOIGhnjNVl5Lpseiuf00iKN0V47oqDrbo4dsHz1wH62m49AR8iG8wpDlTqfYgKbtg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-riscv64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.8.tgz", + "integrity": "sha512-OCGSOaspMUjexSCU8ZiA0UnV/NiRU+s2vIfEcAQWQ6u32R+2luyfh/4ZaY6jFbylJE07Esc/yRvb9Q5fXuClXA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-s390x": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.8.tgz", + "integrity": "sha512-RHdpdfxRTSrZXZJlFSLazFU4YwXLB5Rgf6Zr5rffqSsO4y9JybgtKO38bFwxZNlDXliYISXN/YROKrG9s7mZQA==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-netbsd-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.8.tgz", + "integrity": "sha512-VolFFRatBH09T5QMWhiohAWCOien1R1Uz9K0BRVVTBgBaVBt7eArsXTKxVhUgRf2vwu2c2SXkuP0r7HLG0eozw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-openbsd-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.8.tgz", + "integrity": "sha512-HTAPlg+n4kUeE/isQxlCfsOz0xJGNoT5LJ9oYZWFKABfVf4Ycu7Zlf5ITgOnrdheTkz8JeL/gISIOCFAoOXrSA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-sunos-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.8.tgz", + "integrity": "sha512-qMP/jR/FzcIOwKj+W+Lb+8Cfr8GZHbHUJxAPi7DUhNZMQ/6y7sOgRzlOSpRrbbUntrRZh0MqOyDhJ3Gpo6L1QA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-wasm": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.15.8.tgz", + "integrity": "sha512-Y7uCl5RNO4URjlemjdx++ukVHEMt5s5AfMWYUnMiK4Sry+pPCvQIctzXq6r6FKCyGKjX6/NGMCqR2OX6aLxj0w==", + "dev": true, + "optional": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-32": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.8.tgz", + "integrity": "sha512-RKR1QHh4iWzjUhkP8Yqi75PPz/KS+b8zw3wUrzw6oAkj+iU5Qtyj61ZDaSG3Qf2vc6hTIUiPqVTqBH0NpXFNwg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.8.tgz", + "integrity": "sha512-ag9ptYrsizgsR+PQE8QKeMqnosLvAMonQREpLw4evA4FFgOBMLEat/dY/9txbpozTw9eEOYyD3a4cE9yTu20FA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.8.tgz", + "integrity": "sha512-dbpAb0VyPaUs9mgw65KRfQ9rqiWCHpNzrJusoPu+LpEoswosjt/tFxN7cd2l68AT4qWdBkzAjDLRon7uqMeWcg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -8857,6 +9266,23 @@ "jsdoc-type-pratt-parser": "~3.1.0" } }, + "@esbuild/android-arm": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.8.tgz", + "integrity": "sha512-CyEWALmn+no/lbgbAJsbuuhT8s2J19EJGHkeyAwjbFJMrj80KJ9zuYsoAvidPTU7BgBf87r/sgae8Tw0dbOc4Q==", + "dev": true, + "optional": true, + "requires": { + "esbuild-wasm": "0.15.8" + } + }, + "@esbuild/linux-loong64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.8.tgz", + "integrity": "sha512-pE5RQsOTSERCtfZdfCT25wzo7dfhOSlhAXcsZmuvRYhendOv7djcdvtINdnDp2DAjP17WXlBB4nBO6sHLczmsg==", + "dev": true, + "optional": true + }, "@eslint/eslintrc": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", @@ -10801,6 +11227,186 @@ "es6-symbol": "^3.1.1" } }, + "esbuild": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.8.tgz", + "integrity": "sha512-Remsk2dmr1Ia65sU+QasE6svJbsHe62lzR+CnjpUvbZ+uSYo1SitiOWPRfZQkCu82YWZBBKXiD/j0i//XWMZ+Q==", + "dev": true, + "requires": { + "@esbuild/android-arm": "0.15.8", + "@esbuild/linux-loong64": "0.15.8", + "esbuild-android-64": "0.15.8", + "esbuild-android-arm64": "0.15.8", + "esbuild-darwin-64": "0.15.8", + "esbuild-darwin-arm64": "0.15.8", + "esbuild-freebsd-64": "0.15.8", + "esbuild-freebsd-arm64": "0.15.8", + "esbuild-linux-32": "0.15.8", + "esbuild-linux-64": "0.15.8", + "esbuild-linux-arm": "0.15.8", + "esbuild-linux-arm64": "0.15.8", + "esbuild-linux-mips64le": "0.15.8", + "esbuild-linux-ppc64le": "0.15.8", + "esbuild-linux-riscv64": "0.15.8", + "esbuild-linux-s390x": "0.15.8", + "esbuild-netbsd-64": "0.15.8", + "esbuild-openbsd-64": "0.15.8", + "esbuild-sunos-64": "0.15.8", + "esbuild-windows-32": "0.15.8", + "esbuild-windows-64": "0.15.8", + "esbuild-windows-arm64": "0.15.8" + } + }, + "esbuild-android-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.8.tgz", + "integrity": "sha512-bVh8FIKOolF7/d4AMzt7xHlL0Ljr+mYKSHI39TJWDkybVWHdn6+4ODL3xZGHOxPpdRpitemXA1WwMKYBsw8dGw==", + "dev": true, + "optional": true, + "requires": { + "esbuild-wasm": "0.15.8" + } + }, + "esbuild-android-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.8.tgz", + "integrity": "sha512-ReAMDAHuo0H1h9LxRabI6gwYPn8k6WiUeyxuMvx17yTrJO+SCnIfNc/TSPFvDwtK9MiyiKG/2dBYHouT/M0BXQ==", + "dev": true, + "optional": true + }, + "esbuild-darwin-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.8.tgz", + "integrity": "sha512-KaKcGfJ+yto7Fo5gAj3xwxHMd1fBIKatpCHK8znTJLVv+9+NN2/tIPBqA4w5rBwjX0UqXDeIE2v1xJP+nGEXgA==", + "dev": true, + "optional": true + }, + "esbuild-darwin-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.8.tgz", + "integrity": "sha512-8tjEaBgAKnXCkP7bhEJmEqdG9HEV6oLkF36BrMzpfW2rgaw0c48Zrxe+9RlfeGvs6gDF4w+agXyTjikzsS3izw==", + "dev": true, + "optional": true + }, + "esbuild-freebsd-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.8.tgz", + "integrity": "sha512-jaxcsGHYzn2L0/lffON2WfH4Nc+d/EwozVTP5K2v016zxMb5UQMhLoJzvLgBqHT1SG0B/mO+a+THnJCMVg15zw==", + "dev": true, + "optional": true + }, + "esbuild-freebsd-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.8.tgz", + "integrity": "sha512-2xp2UlljMvX8HExtcg7VHaeQk8OBU0CSl1j18B5CcZmSDkLF9p3utuMXIopG3a08fr9Hv+Dz6+seSXUow/G51w==", + "dev": true, + "optional": true + }, + "esbuild-linux-32": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.8.tgz", + "integrity": "sha512-9u1E54BRz1FQMl86iaHK146+4ID2KYNxL3trLZT4QLLx3M7Q9n4lGG3lrzqUatGR2cKy8c33b0iaCzsItZWkFg==", + "dev": true, + "optional": true + }, + "esbuild-linux-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.8.tgz", + "integrity": "sha512-4HxrsN9eUzJXdVGMTYA5Xler82FuZUu21bXKN42zcLHHNKCAMPUzD62I+GwDhsdgUBAUj0tRXDdsQHgaP6v0HA==", + "dev": true, + "optional": true + }, + "esbuild-linux-arm": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.8.tgz", + "integrity": "sha512-7DVBU9SFjX4+vBwt8tHsUCbE6Vvl6y6FQWHAgyw1lybC5gULqn/WnjHYHN2/LJaZRsDBvxWT4msEgwLGq1Wd3Q==", + "dev": true, + "optional": true + }, + "esbuild-linux-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.8.tgz", + "integrity": "sha512-1OCm7Aq0tEJT70PbxmHSGYDLYP8DKH8r4Nk7/XbVzWaduo9beCjGBB+tGZIHK6DdTQ3h00/4Tb/70YMH/bOtKg==", + "dev": true, + "optional": true + }, + "esbuild-linux-mips64le": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.8.tgz", + "integrity": "sha512-yeFoNPVFPEzZvFYBfUQNG2TjGRaCyV1E27OcOg4LOtnGrxb2wA+mkW3luckyv1CEyd00mpAg7UdHx8nlx3ghgA==", + "dev": true, + "optional": true + }, + "esbuild-linux-ppc64le": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.8.tgz", + "integrity": "sha512-CEyMMUUNabXibw8OSNmBXhOIGhnjNVl5Lpseiuf00iKN0V47oqDrbo4dsHz1wH62m49AR8iG8wpDlTqfYgKbtg==", + "dev": true, + "optional": true + }, + "esbuild-linux-riscv64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.8.tgz", + "integrity": "sha512-OCGSOaspMUjexSCU8ZiA0UnV/NiRU+s2vIfEcAQWQ6u32R+2luyfh/4ZaY6jFbylJE07Esc/yRvb9Q5fXuClXA==", + "dev": true, + "optional": true + }, + "esbuild-linux-s390x": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.8.tgz", + "integrity": "sha512-RHdpdfxRTSrZXZJlFSLazFU4YwXLB5Rgf6Zr5rffqSsO4y9JybgtKO38bFwxZNlDXliYISXN/YROKrG9s7mZQA==", + "dev": true, + "optional": true + }, + "esbuild-netbsd-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.8.tgz", + "integrity": "sha512-VolFFRatBH09T5QMWhiohAWCOien1R1Uz9K0BRVVTBgBaVBt7eArsXTKxVhUgRf2vwu2c2SXkuP0r7HLG0eozw==", + "dev": true, + "optional": true + }, + "esbuild-openbsd-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.8.tgz", + "integrity": "sha512-HTAPlg+n4kUeE/isQxlCfsOz0xJGNoT5LJ9oYZWFKABfVf4Ycu7Zlf5ITgOnrdheTkz8JeL/gISIOCFAoOXrSA==", + "dev": true, + "optional": true + }, + "esbuild-sunos-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.8.tgz", + "integrity": "sha512-qMP/jR/FzcIOwKj+W+Lb+8Cfr8GZHbHUJxAPi7DUhNZMQ/6y7sOgRzlOSpRrbbUntrRZh0MqOyDhJ3Gpo6L1QA==", + "dev": true, + "optional": true + }, + "esbuild-wasm": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.15.8.tgz", + "integrity": "sha512-Y7uCl5RNO4URjlemjdx++ukVHEMt5s5AfMWYUnMiK4Sry+pPCvQIctzXq6r6FKCyGKjX6/NGMCqR2OX6aLxj0w==", + "dev": true, + "optional": true + }, + "esbuild-windows-32": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.8.tgz", + "integrity": "sha512-RKR1QHh4iWzjUhkP8Yqi75PPz/KS+b8zw3wUrzw6oAkj+iU5Qtyj61ZDaSG3Qf2vc6hTIUiPqVTqBH0NpXFNwg==", + "dev": true, + "optional": true + }, + "esbuild-windows-64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.8.tgz", + "integrity": "sha512-ag9ptYrsizgsR+PQE8QKeMqnosLvAMonQREpLw4evA4FFgOBMLEat/dY/9txbpozTw9eEOYyD3a4cE9yTu20FA==", + "dev": true, + "optional": true + }, + "esbuild-windows-arm64": { + "version": "0.15.8", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.8.tgz", + "integrity": "sha512-dbpAb0VyPaUs9mgw65KRfQ9rqiWCHpNzrJusoPu+LpEoswosjt/tFxN7cd2l68AT4qWdBkzAjDLRon7uqMeWcg==", + "dev": true, + "optional": true + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", diff --git a/package.json b/package.json index bfdf548e27023..d152ce0eeeffa 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "chalk": "^4.1.2", "del": "^6.1.1", "diff": "^5.1.0", + "esbuild": "^0.15.8", "eslint": "^8.22.0", "eslint-formatter-autolinkable-stylish": "^1.2.0", "eslint-plugin-import": "^2.26.0", diff --git a/scripts/build/options.js b/scripts/build/options.js index fc237c5885584..e37b1edd6ac06 100644 --- a/scripts/build/options.js +++ b/scripts/build/options.js @@ -6,7 +6,7 @@ const ci = ["1", "true"].includes(process.env.CI); /** @type {CommandLineOptions} */ module.exports = minimist(process.argv.slice(2), { - boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci"], + boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle"], string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"], alias: { /* eslint-disable quote-props */ @@ -41,6 +41,7 @@ module.exports = minimist(process.argv.slice(2), { dirty: false, built: false, ci, + bundle: true } }); @@ -49,7 +50,7 @@ if (module.exports.built) { } /** - * @typedef TypedOptions + * @typedef CommandLineOptions * @property {boolean} dirty * @property {boolean} light * @property {boolean} colors @@ -69,7 +70,9 @@ if (module.exports.built) { * @property {boolean} failed * @property {boolean} keepFailed * @property {boolean} ci - * - * @typedef {import("minimist").ParsedArgs & TypedOptions} CommandLineOptions + * @property {boolean} bundle + * @property {string} shards + * @property {string} shardId + * @property {string} break */ void 0; diff --git a/scripts/build/prepend.js b/scripts/build/prepend.js deleted file mode 100644 index d7571efdaabdb..0000000000000 --- a/scripts/build/prepend.js +++ /dev/null @@ -1,64 +0,0 @@ -// @ts-check -const stream = require("stream"); -const ts = require("../../lib/typescript"); -const fs = require("fs"); -const { base64VLQFormatEncode } = require("./sourcemaps"); - -/** - * @param {string | ((file: import("vinyl")) => string)} data - */ -function prepend(data) { - return new stream.Transform({ - objectMode: true, - /** - * @param {string | Buffer | import("vinyl")} input - * @param {(error: Error, data?: any) => void} cb - */ - transform(input, _, cb) { - if (typeof input === "string" || Buffer.isBuffer(input)) return cb(new Error("Only Vinyl files are supported.")); - if (!input.isBuffer()) return cb(new Error("Streams not supported.")); - try { - const output = input.clone(); - const prependContent = typeof data === "function" ? data(input) : data; - output.contents = Buffer.concat([Buffer.from(prependContent, "utf8"), input.contents]); - if (input.sourceMap) { - if (typeof input.sourceMap === "string") input.sourceMap = /**@type {import("./sourcemaps").RawSourceMap}*/(JSON.parse(input.sourceMap)); - const lineStarts = /**@type {*}*/(ts).computeLineStarts(prependContent); - let prependMappings = ""; - for (let i = 1; i < lineStarts.length; i++) { - prependMappings += ";"; - } - const offset = prependContent.length - lineStarts[lineStarts.length - 1]; - if (offset > 0) { - prependMappings += base64VLQFormatEncode(offset) + ","; - } - output.sourceMap = { - version: input.sourceMap.version, - file: input.sourceMap.file, - sources: input.sourceMap.sources, - sourceRoot: input.sourceMap.sourceRoot, - mappings: prependMappings + input.sourceMap.mappings, - names: input.names, - sourcesContent: input.sourcesContent - }; - } - // eslint-disable-next-line local/boolean-trivia, no-null/no-null - return cb(null, output); - } - catch (e) { - return cb(e); - } - } - }); -} -exports.prepend = prepend; - -/** - * @param {string | ((file: import("vinyl")) => string)} file - */ -function prependFile(file) { - const data = typeof file === "string" ? fs.readFileSync(file, "utf8") : - vinyl => fs.readFileSync(file(vinyl), "utf8"); - return prepend(data); -} -exports.prependFile = prependFile; diff --git a/scripts/build/projects.js b/scripts/build/projects.js index 7346607d3bfb8..55559e9d1baf3 100644 --- a/scripts/build/projects.js +++ b/scripts/build/projects.js @@ -2,67 +2,57 @@ const { exec, Debouncer } = require("./utils"); const { resolve } = require("path"); const { findUpRoot } = require("./findUpDir"); +const cmdLineOptions = require("./options"); class ProjectQueue { /** - * @param {(projects: string[], lkg: boolean, force: boolean) => Promise} action + * @param {(projects: string[]) => Promise} action */ constructor(action) { - /** @type {{ lkg: boolean, force: boolean, projects?: string[], debouncer: Debouncer }[]} */ - this._debouncers = []; - this._action = action; + /** @type {string[] | undefined} */ + this._projects = undefined; + this._debouncer = new Debouncer(100, async () => { + const projects = this._projects; + if (projects) { + this._projects = undefined; + await action(projects); + } + }); } /** * @param {string} project - * @param {object} options */ - enqueue(project, { lkg = true, force = false } = {}) { - let entry = this._debouncers.find(entry => entry.lkg === lkg && entry.force === force); - if (!entry) { - const debouncer = new Debouncer(100, async () => { - const projects = entry.projects; - if (projects) { - entry.projects = undefined; - await this._action(projects, lkg, force); - } - }); - this._debouncers.push(entry = { lkg, force, debouncer }); - } - if (!entry.projects) entry.projects = []; - entry.projects.push(project); - return entry.debouncer.enqueue(); + enqueue(project) { + if (!this._projects) this._projects = []; + this._projects.push(project); + return this._debouncer.enqueue(); } } -const execTsc = (/** @type {boolean} */ lkg, /** @type {string[]} */ ...args) => +const execTsc = (/** @type {string[]} */ ...args) => exec(process.execPath, - [resolve(findUpRoot(), lkg ? "./lib/tsc" : "./built/local/tsc"), + [resolve(findUpRoot(), cmdLineOptions.lkg ? "./lib/tsc" : "./built/local/tsc"), "-b", ...args], { hidePrompt: true }); -const projectBuilder = new ProjectQueue((projects, lkg, force) => execTsc(lkg, ...(force ? ["--force"] : []), ...projects)); +const projectBuilder = new ProjectQueue((projects) => execTsc(...projects)); /** * @param {string} project - * @param {object} options - * @param {boolean} [options.lkg=true] - * @param {boolean} [options.force=false] */ -exports.buildProject = (project, { lkg, force } = {}) => projectBuilder.enqueue(project, { lkg, force }); +exports.buildProject = (project) => projectBuilder.enqueue(project); -const projectCleaner = new ProjectQueue((projects, lkg) => execTsc(lkg, "--clean", ...projects)); +const projectCleaner = new ProjectQueue((projects) => execTsc("--clean", ...projects)); /** * @param {string} project */ exports.cleanProject = (project) => projectCleaner.enqueue(project); -const projectWatcher = new ProjectQueue((projects) => execTsc(/*lkg*/ true, "--watch", ...projects)); +const projectWatcher = new ProjectQueue((projects) => execTsc("--watch", ...projects)); /** * @param {string} project - * @param {object} options - * @param {boolean} [options.lkg=true] */ -exports.watchProject = (project, { lkg } = {}) => projectWatcher.enqueue(project, { lkg }); +exports.watchProject = (project) => projectWatcher.enqueue(project); diff --git a/scripts/build/tests.js b/scripts/build/tests.js index 4dd76c1f62e69..f6560343476b9 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -123,17 +123,17 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode) errorStatus = exitCode; error = new Error(`Process exited with status code ${errorStatus}.`); } - else if (cmdLineOptions.ci) { - // finally, do a sanity check and build the compiler with the built version of itself - log.info("Starting sanity check build..."); - // Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them) - await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"]); - const { exitCode } = await exec("gulp", ["local", "--lkg=false"]); - if (exitCode !== 0) { - errorStatus = exitCode; - error = new Error(`Sanity check build process exited with status code ${errorStatus}.`); - } - } + // else if (cmdLineOptions.ci) { + // // finally, do a sanity check and build the compiler with the built version of itself + // log.info("Starting sanity check build..."); + // // Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them) + // await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"]); + // const { exitCode } = await exec("gulp", ["local", "--lkg=false"]); + // if (exitCode !== 0) { + // errorStatus = exitCode; + // error = new Error(`Sanity check build process exited with status code ${errorStatus}.`); + // } + // } } catch (e) { errorStatus = undefined; diff --git a/scripts/build/utils.js b/scripts/build/utils.js index 0e38a0b73d6cf..378084f8c4934 100644 --- a/scripts/build/utils.js +++ b/scripts/build/utils.js @@ -7,7 +7,6 @@ const fs = require("fs"); const path = require("path"); const log = require("fancy-log"); -const mkdirp = require("mkdirp"); const del = require("del"); const File = require("vinyl"); const ts = require("../../lib/typescript"); @@ -225,90 +224,6 @@ function getDirSize(root) { } exports.getDirSize = getDirSize; -/** - * Flattens a project with project references into a single project. - * @param {string} projectSpec The path to a tsconfig.json file or its containing directory. - * @param {string} flattenedProjectSpec The output path for the flattened tsconfig.json file. - * @param {FlattenOptions} [options] Options used to flatten a project hierarchy. - * - * @typedef FlattenOptions - * @property {string} [cwd] The path to use for the current working directory. Defaults to `process.cwd()`. - * @property {import("../../lib/typescript").CompilerOptions} [compilerOptions] Compiler option overrides. - * @property {boolean} [force] Forces creation of the output project. - * @property {string[]} [exclude] Files to exclude (relative to `cwd`) - */ -function flatten(projectSpec, flattenedProjectSpec, options = {}) { - const cwd = normalizeSlashes(options.cwd ? path.resolve(options.cwd) : process.cwd()); - const files = []; - const resolvedOutputSpec = path.resolve(cwd, flattenedProjectSpec); - const resolvedOutputDirectory = path.dirname(resolvedOutputSpec); - const resolvedProjectSpec = resolveProjectSpec(projectSpec, cwd, /*referrer*/ undefined); - const project = readJson(resolvedProjectSpec); - const skipProjects = /**@type {Set}*/(new Set()); - const skipFiles = new Set(options && options.exclude && options.exclude.map(file => normalizeSlashes(path.resolve(cwd, file)))); - recur(resolvedProjectSpec, project); - - if (options.force || needsUpdate(files, resolvedOutputSpec)) { - const config = { - extends: normalizeSlashes(path.relative(resolvedOutputDirectory, resolvedProjectSpec)), - compilerOptions: options.compilerOptions || {}, - files: files.map(file => normalizeSlashes(path.relative(resolvedOutputDirectory, file))) - }; - mkdirp.sync(resolvedOutputDirectory); - fs.writeFileSync(resolvedOutputSpec, JSON.stringify(config, undefined, 2), "utf8"); - } - - /** - * @param {string} projectSpec - * @param {object} project - */ - function recur(projectSpec, project) { - if (skipProjects.has(projectSpec)) return; - skipProjects.add(project); - if (project.references) { - for (const ref of project.references) { - const referencedSpec = resolveProjectSpec(ref.path, cwd, projectSpec); - const referencedProject = readJson(referencedSpec); - recur(referencedSpec, referencedProject); - } - } - if (project.include) { - throw new Error("Flattened project may not have an 'include' list."); - } - if (!project.files) { - throw new Error("Flattened project must have an explicit 'files' list."); - } - const projectDirectory = path.dirname(projectSpec); - for (let file of project.files) { - file = normalizeSlashes(path.resolve(projectDirectory, file)); - if (skipFiles.has(file)) continue; - skipFiles.add(file); - files.push(file); - } - } -} -exports.flatten = flatten; - -/** - * @param {string} file - */ -function normalizeSlashes(file) { - return file.replace(/\\/g, "/"); -} - -/** - * @param {string} projectSpec - * @param {string} cwd - * @param {string | undefined} referrer - * @returns {string} - */ -function resolveProjectSpec(projectSpec, cwd, referrer) { - const projectPath = normalizeSlashes(path.resolve(cwd, referrer ? path.dirname(referrer) : "", projectSpec)); - const stats = fs.statSync(projectPath); - if (stats.isFile()) return normalizeSlashes(projectPath); - return normalizeSlashes(path.resolve(cwd, projectPath, "tsconfig.json")); -} - /** * @param {string | ((file: File) => string) | { cwd?: string }} [dest] * @param {{ cwd?: string }} [opts] diff --git a/scripts/produceLKG.ts b/scripts/produceLKG.ts index e4e37df028e6f..35f0c45ea764b 100644 --- a/scripts/produceLKG.ts +++ b/scripts/produceLKG.ts @@ -62,7 +62,6 @@ async function copyScriptOutputs() { await copyWithCopyright("cancellationToken.js"); await copyWithCopyright("tsc.release.js", "tsc.js"); await copyWithCopyright("tsserver.js"); - await copyWithCopyright("dynamicImportCompat.js"); await copyFromBuiltLocal("tsserverlibrary.js"); // copyright added by build await copyFromBuiltLocal("typescript.js"); // copyright added by build await copyFromBuiltLocal("typescriptServices.js"); // copyright added by build diff --git a/src/cancellationToken/tsconfig.json b/src/cancellationToken/tsconfig.json index 76eca8f56cd66..f12034bee9d26 100644 --- a/src/cancellationToken/tsconfig.json +++ b/src/cancellationToken/tsconfig.json @@ -1,7 +1,9 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local/cancellationToken", + "outDir": "../../built/local", + "tsBuildInfoFile": "../../built/local/cancellationToken.tsbuildinfo", + "rootDir": ".", "module": "commonjs", "types": [ "node" diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 1b189bf38dd45..475bf9237b27a 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -721,7 +721,7 @@ export namespace Debug { try { if (sys && sys.require) { const basePath = getDirectoryPath(resolvePath(sys.getExecutingFilePath())); - const result = sys.require(basePath, "./compiler-debug") as RequireResult; + const result = sys.require(basePath, "./compilerDebug") as RequireResult; if (!result.error) { result.module.init(ts); extendedDebugModule = result.module; diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 6a8d8fbd53264..97e8a2fee25eb 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1466,6 +1466,13 @@ export let sys: System = (() => { const useCaseSensitiveFileNames = isFileSystemCaseSensitive(); const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync; + // If our filename is "sys.js", then we are executing unbundled on the raw tsc output. + // In that case, simulate a faked path in the directory where a bundle would normally + // appear (e.g. the directory containing lib.*.d.ts files). + // + // Note that if we ever emit as files like cjs/mjs, this check will be wrong. + const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename; + const fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); const getCurrentDirectory = memoize(() => process.cwd()); const { watchFile, watchDirectory } = createSystemWatchFunctions({ @@ -1525,14 +1532,7 @@ export let sys: System = (() => { } }, getExecutingFilePath() { - // This function previously returned a path like `built/local/tsc.js`. - // Now, with a module output, this file is now `built/local/compiler/sys.js`. - // We want to return a file that looks like the old one, so that callers - // can locate other assets like the lib.d.ts files. - // - // TODO(jakebailey): replace this function with one that returns the path - // to the lib folder (or package path)?. - return _path.join(_path.dirname(__dirname), "fake.js"); + return executingFilePath; }, getCurrentDirectory, getDirectories, @@ -1571,7 +1571,10 @@ export let sys: System = (() => { debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv as string[], arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)), tryEnableSourceMapsForHost() { try { - require("source-map-support").install(); + // Trick esbuild into not eagerly resolving a path to a JS file. + // See: https://github.com/evanw/esbuild/issues/1958 + const moduleName = "source-map-support" as const; + (require(moduleName) as typeof import("source-map-support")).install(); } catch { // Could not enable source maps. diff --git a/src/debug/_namespaces/Debug.ts b/src/debug/_namespaces/Debug.ts deleted file mode 100644 index 449c31bdaefbe..0000000000000 --- a/src/debug/_namespaces/Debug.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* Generated file to emulate the Debug namespace. */ - -export * from "../dbg"; diff --git a/src/debug/dbg.ts b/src/debug/compilerDebug.ts similarity index 95% rename from src/debug/dbg.ts rename to src/debug/compilerDebug.ts index 3b531914d532d..5eca399b0564d 100644 --- a/src/debug/dbg.ts +++ b/src/debug/compilerDebug.ts @@ -1,7 +1,3 @@ -import * as Debug from "./_namespaces/Debug"; - -/// - interface Node { kind: number; } @@ -510,9 +506,3 @@ export function formatControlFlowGraph(flowNode: FlowNode) { return s; } } - -// Export as a module. NOTE: Can't use module exports as this is built using --outFile -declare const module: { exports: {} }; -if (typeof module !== "undefined" && module.exports) { - module.exports = Debug; -} diff --git a/src/debug/tsconfig.json b/src/debug/tsconfig.json index 4f9a47f5afc6c..d4eb364738589 100644 --- a/src/debug/tsconfig.json +++ b/src/debug/tsconfig.json @@ -1,12 +1,13 @@ { "extends": "../tsconfig-base", "compilerOptions": { + "outDir": "../../built/local", + "tsBuildInfoFile": "../../built/local/debug.tsbuildinfo", + "rootDir": ".", "target": "es2019", "lib": ["es2019"], - "outDir": "../../built/local/debug" }, "files": [ - "dbg.ts", - "_namespaces/Debug.ts" + "compilerDebug.ts", ] } diff --git a/src/dynamicImportCompat/_namespaces/ts.server.ts b/src/dynamicImportCompat/_namespaces/ts.server.ts deleted file mode 100644 index 729da9c24ef35..0000000000000 --- a/src/dynamicImportCompat/_namespaces/ts.server.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* Generated file to emulate the ts.server namespace. */ - -export * from "../dynamicImportCompat"; diff --git a/src/dynamicImportCompat/_namespaces/ts.ts b/src/dynamicImportCompat/_namespaces/ts.ts deleted file mode 100644 index 91d7693414440..0000000000000 --- a/src/dynamicImportCompat/_namespaces/ts.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* Generated file to emulate the ts namespace. */ - -import * as server from "./ts.server"; -export { server }; diff --git a/src/dynamicImportCompat/dynamicImportCompat.ts b/src/dynamicImportCompat/dynamicImportCompat.ts deleted file mode 100644 index 5981d8c7e968e..0000000000000 --- a/src/dynamicImportCompat/dynamicImportCompat.ts +++ /dev/null @@ -1 +0,0 @@ -export const dynamicImport = (id: string) => import(id); \ No newline at end of file diff --git a/src/dynamicImportCompat/tsconfig.json b/src/dynamicImportCompat/tsconfig.json deleted file mode 100644 index 3abacb2133d0a..0000000000000 --- a/src/dynamicImportCompat/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "../tsconfig-base", - "compilerOptions": { - "outDir": "../../built/local/dynamicImportCompat", - "rootDir": ".", - "target": "esnext", - "module": "esnext", - "lib": ["esnext"] - }, - "files": [ - "dynamicImportCompat.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.ts" - ] -} diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index c968d1522f36d..d09bbe38b2798 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -4059,7 +4059,7 @@ export function runFourSlashTestContent(basePath: string, testType: FourSlashTes function runCode(code: string, state: TestState, fileName: string): void { // Compile and execute the test const generatedFile = ts.changeExtension(fileName, ".js"); - const wrappedCode = `(function(test, goTo, plugins, verify, edit, debug, format, cancellation, classification, completion, verifyOperationIsCancelled) {${code}\n//# sourceURL=${ts.getBaseFileName(generatedFile)}\n})`; + const wrappedCode = `(function(ts, test, goTo, config, verify, edit, debug, format, cancellation, classification, completion, verifyOperationIsCancelled, ignoreInterpolations) {${code}\n//# sourceURL=${ts.getBaseFileName(generatedFile)}\n})`; type SourceMapSupportModule = typeof import("source-map-support") & { // TODO(rbuckton): This is missing from the DT definitions and needs to be added. @@ -4093,8 +4093,8 @@ function runCode(code: string, state: TestState, fileName: string): void { const format = new FourSlashInterface.Format(state); const cancellation = new FourSlashInterface.Cancellation(state); // eslint-disable-next-line no-eval - const f = eval(wrappedCode); - f(test, goTo, config, verify, edit, debug, format, cancellation, FourSlashInterface.classification, FourSlashInterface.Completion, verifyOperationIsCancelled); + const f = (0, eval)(wrappedCode); + f(ts, test, goTo, config, verify, edit, debug, format, cancellation, FourSlashInterface.classification, FourSlashInterface.Completion, verifyOperationIsCancelled, ignoreInterpolations); } catch (err) { // ensure 'source-map-support' is triggered while we still have the handler attached by accessing `error.stack`. diff --git a/src/server/scriptVersionCache.ts b/src/server/scriptVersionCache.ts index 6c99b15ecb9e2..13a2fbe6a0a45 100644 --- a/src/server/scriptVersionCache.ts +++ b/src/server/scriptVersionCache.ts @@ -255,16 +255,16 @@ class TextChange { /** @internal */ export class ScriptVersionCache { + private static readonly changeNumberThreshold = 8; + private static readonly changeLengthThreshold = 256; + private static readonly maxVersions = 8; + private changes: TextChange[] = []; private readonly versions: LineIndexSnapshot[] = new Array(ScriptVersionCache.maxVersions); private minVersion = 0; // no versions earlier than min version will maintain change history private currentVersion = 0; - private static readonly changeNumberThreshold = 8; - private static readonly changeLengthThreshold = 256; - private static readonly maxVersions = 8; - private versionToIndex(version: number) { if (version < this.minVersion || version > this.currentVersion) { return undefined; diff --git a/src/services/_namespaces/ts.ts b/src/services/_namespaces/ts.ts index eae114fd2e834..55fca06914ebd 100644 --- a/src/services/_namespaces/ts.ts +++ b/src/services/_namespaces/ts.ts @@ -17,6 +17,7 @@ export * from "../transpile"; export * from "../services"; export * from "../transform"; export * from "../shims"; +export * from "../globalThisShim"; import * as BreakpointResolver from "./ts.BreakpointResolver"; export { BreakpointResolver }; import * as CallHierarchy from "./ts.CallHierarchy"; diff --git a/src/services/exportAsModule.ts b/src/services/exportAsModule.ts deleted file mode 100644 index 757f9f7cd34fe..0000000000000 --- a/src/services/exportAsModule.ts +++ /dev/null @@ -1,9 +0,0 @@ -import * as ts from "./_namespaces/ts"; - -// Here we expose the TypeScript services as an external module -// so that it may be consumed easily like a node module. -// @ts-ignore -/** @internal */ declare const module: { exports: {} }; -if (typeof module !== "undefined" && module.exports) { - module.exports = ts; -} diff --git a/src/services/services.ts b/src/services/services.ts index 03e2fcf8f23ee..4872a6afb52a0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -484,9 +484,9 @@ class IdentifierObject extends TokenOrIdentifierObject implements Identifier { } IdentifierObject.prototype.kind = SyntaxKind.Identifier; class PrivateIdentifierObject extends TokenOrIdentifierObject implements PrivateIdentifier { - public kind!: SyntaxKind.PrivateIdentifier; + public kind: SyntaxKind.PrivateIdentifier = SyntaxKind.PrivateIdentifier; public escapedText!: __String; - public symbol!: Symbol; + // public symbol!: Symbol; _primaryExpressionBrand: any; _memberExpressionBrand: any; _leftHandSideExpressionBrand: any; diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index eec6262c0fe9e..8c57f662a7e90 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -134,7 +134,6 @@ "transform.ts", "shims.ts", "globalThisShim.ts", - "exportAsModule.ts", "_namespaces/ts.BreakpointResolver.ts", "_namespaces/ts.ts", "_namespaces/ts.CallHierarchy.ts", diff --git a/src/testRunner/_namespaces/Harness.ts b/src/testRunner/_namespaces/Harness.ts index caf03e950ac7e..602d83e4126c3 100644 --- a/src/testRunner/_namespaces/Harness.ts +++ b/src/testRunner/_namespaces/Harness.ts @@ -11,3 +11,9 @@ export * from "../compilerRunner"; export * from "../externalCompileRunner"; export * from "../test262Runner"; export * from "../runner"; + +// If running as emitted CJS, don't start executing the tests here; instead start in runner.ts. +// If running bundled, we want this to be here so that esbuild places the tests after runner.ts. +if (!__filename.endsWith("Harness.js")) { + require("./tests"); +} diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index afce9655270a0..28bfd969836a1 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -293,4 +293,11 @@ function startTestEnvironment() { startTestEnvironment(); // This brings in all of the unittests. -import "./_namespaces/tests"; +// NOTE: if emitting CJS, uncomment this, and comment out the one in Harness.ts. +// import "./_namespaces/tests"; + +// If running as emitted CJS, we want to start the tests here after startTestEnvironment. +// If running bundled, we will do this in Harness.ts. +if (__filename.endsWith("runner.js")) { + require("./_namespaces/tests"); +} diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index d3ece6a19d613..8b167bf410e66 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -10,6 +10,7 @@ "sourceMap": true, "composite": true, "noEmitOnError": true, + "emitDeclarationOnly": false, "strictNullChecks": true, "noImplicitAny": true, diff --git a/src/tsconfig.json b/src/tsconfig.json index f70352ca5e621..79de8fdaa3a8c 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -10,7 +10,6 @@ { "path": "./watchGuard" }, { "path": "./debug" }, { "path": "./cancellationToken" }, - { "path": "./dynamicImportCompat" }, { "path": "./testRunner" }, ] } diff --git a/src/tsserver/nodeServer.ts b/src/tsserver/nodeServer.ts index 9ea213f134ec1..0f896e0e147ed 100644 --- a/src/tsserver/nodeServer.ts +++ b/src/tsserver/nodeServer.ts @@ -525,8 +525,9 @@ function startNodeSession(options: StartSessionOptions, logger: Logger, cancella } } - // TODO(jakebailey): fix this for module transform - this.installer = childProcess.fork(combinePaths(__dirname, "..", "typingsInstaller", "nodeTypingsInstaller.js"), args, { execArgv }); + // TODO(jakebailey): this is a little hacky; can we use sys? + const builtRoot = __filename.endsWith("nodeServer.js") ? combinePaths(__dirname, "..") : __dirname; + this.installer = childProcess.fork(combinePaths(builtRoot, "typingsInstaller.js"), args, { execArgv }); this.installer.on("message", m => this.handleMessage(m)); // We have to schedule this event to the next tick diff --git a/src/watchGuard/tsconfig.json b/src/watchGuard/tsconfig.json index eb1607930c8ee..2276c1ad1427b 100644 --- a/src/watchGuard/tsconfig.json +++ b/src/watchGuard/tsconfig.json @@ -1,7 +1,9 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local/watchGuard", + "outDir": "../../built/local", + "tsBuildInfoFile": "../../built/local/watchGuard.tsbuildinfo", + "rootDir": ".", "types": [ "node" ], diff --git a/src/watchGuard/watchGuard.ts b/src/watchGuard/watchGuard.ts index b66338f42eb0a..c9589e048ea6e 100644 --- a/src/watchGuard/watchGuard.ts +++ b/src/watchGuard/watchGuard.ts @@ -1,6 +1,6 @@ /// -import * as fs from "fs"; +import fs = require("fs"); if (process.argv.length < 3) { process.exit(1); diff --git a/src/webServer/webServer.ts b/src/webServer/webServer.ts index ece05e4db67cc..4e8b241b2871a 100644 --- a/src/webServer/webServer.ts +++ b/src/webServer/webServer.ts @@ -1,4 +1,3 @@ -import * as server from "./_namespaces/ts.server"; import { indent, Logger, LogLevel, ModuleImportResult, Msg, nowString, nullTypingsInstaller, protocol, ServerCancellationToken, ServerHost, Session, SessionOptions, @@ -126,16 +125,11 @@ export class MainProcessLogger extends BaseLogger { } } -// Attempt to load `dynamicImport` -if (typeof importScripts === "function") { - try { - // NOTE: importScripts is synchronous - importScripts("dynamicImportCompat.js"); - } - catch { - // ignored - } -} +/** @internal */ +// eslint-disable-next-line prefer-const +export let dynamicImport = async (_id: string): Promise => { + throw new Error("Dynamic import not implemented"); +}; /** @internal */ export function createWebSystem(host: WebHost, args: string[], getExecutingFilePath: () => string): ServerHost { @@ -144,16 +138,6 @@ export function createWebSystem(host: WebHost, args: string[], getExecutingFileP // Later we could map ^memfs:/ to do something special if we want to enable more functionality like module resolution or something like that const getWebPath = (path: string) => startsWith(path, directorySeparator) ? path.replace(directorySeparator, getExecutingDirectoryPath()) : undefined; - const dynamicImport = async (id: string): Promise => { - const serverDynamicImport: ((id: string) => Promise) | undefined = (server as any).dynamicImport; - // Use syntactic dynamic import first, if available - if (serverDynamicImport) { - return serverDynamicImport(id); - } - - throw new Error("Dynamic import not implemented"); - }; - return { args, newLine: "\r\n", // This can be configured by clients