From 142f87bb3e898786c93338e708e19f531e2b70a0 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:21:03 -0700 Subject: [PATCH] Add build via esbuild This configures the existing build tasks to use esbuild by defualt. If using the plain files is desired, passing `--bundle=false` will build using plain files and still produce a runnable system. --- Gulpfile.js | 306 ++++------ package-lock.json | 549 ++++++++++++++++++ package.json | 1 + scripts/build/options.js | 4 +- scripts/build/tests.js | 22 +- src/cancellationToken/tsconfig.json | 4 +- src/compiler/sys.ts | 21 +- src/debug/_namespaces/Debug.ts | 3 - src/debug/dbg.ts | 8 - src/debug/tsconfig.json | 1 - .../_namespaces/ts.server.ts | 3 - src/dynamicImportCompat/_namespaces/ts.ts | 4 - .../dynamicImportCompat.ts | 2 +- src/dynamicImportCompat/tsconfig.json | 8 +- src/harness/fourslashImpl.ts | 6 +- src/server/scriptVersionCache.ts | 8 +- src/services/_namespaces/ts.ts | 2 + src/services/exportAsModule.ts | 20 +- src/services/services.ts | 4 +- src/testRunner/_namespaces/Harness.ts | 5 + src/testRunner/runner.ts | 3 +- src/tsconfig-base.json | 1 + src/watchGuard/watchGuard.ts | 2 +- src/webServer/webServer.ts | 23 +- 24 files changed, 755 insertions(+), 255 deletions(-) delete mode 100644 src/debug/_namespaces/Debug.ts delete mode 100644 src/dynamicImportCompat/_namespaces/ts.server.ts delete mode 100644 src/dynamicImportCompat/_namespaces/ts.ts diff --git a/Gulpfile.js b/Gulpfile.js index d8bf3fe867862..0715b09f9cbb8 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -15,13 +15,12 @@ const { exec, readJson, needsUpdate, getDiffTool, getDirSize, rm } = require("./ const { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests"); const { buildProject, 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"; - -const buildScripts = () => buildProject("scripts"); +const buildScripts = () => buildProject("scripts", cmdLineOptions); task("scripts", buildScripts); task("scripts").description = "Builds files in the 'scripts' folder."; @@ -94,45 +93,92 @@ const localize = async () => { } }; -const buildAll = () => buildProject("src"); - -task("moduleBuild", parallel(generateLibs, series(buildScripts, localize, buildAll))); +// TODO(jakebailey): we need a whole-project typechecking task; probably one that runs in parallel with tests. -const apiExtractor = async () => { - async function runApiExtractor(configPath) { - await exec(process.execPath, [ - "node_modules/@microsoft/api-extractor/bin/api-extractor", - "run", - "--local", - "--config", - configPath, - ]); +/** @type {string | undefined} */ +let copyrightHeader; +function getCopyrightHeader() { + if (copyrightHeader === undefined) { + copyrightHeader = fs.readFileSync(copyright, "utf-8"); } + return copyrightHeader; +} + +/** + * @param {string} entrypoint + * @param {string} outfile + */ +function esbuildTask(entrypoint, outfile) { + /** @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: "iife", // TODO(jakebailey): figure out how to conditionally use module.exports + 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", + }; - // TODO(jakebailey): prepend copyright notice, replace const enums with regular enums - await runApiExtractor("./src/typescript/api-extractor.json"); - await runApiExtractor("./src/tsserverlibrary/api-extractor.json"); + return { + build: () => esbuild.build(options), + clean: () => del([outfile, `${outfile}.map`]), + watch: () => esbuild.build({ ...options, watch: true }), + }; +} + +// TODO(jakebailey): Add this function to the non-bundle paths which +// don't output to the correct location. (e.g., not dynamicImportCompat). + +/** + * 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(); + }; }; -task("api-extractor", series(task("moduleBuild"), apiExtractor)); +const esbuildDebugTools = esbuildTask("./src/debug/dbg.ts", "./built/local/compiler-debug.js"); -const buildDebugTools = () => buildProject("src/debug"); -const cleanDebugTools = () => cleanProject("src/debug"); +const buildDebugTools = cmdLineOptions.bundle ? esbuildDebugTools.build : () => buildProject("src/debug", cmdLineOptions); +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"); + + +const buildTsc = cmdLineOptions.bundle ? esbuildTsc.build : () => buildProject("src/tsc", cmdLineOptions); 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,96 +188,24 @@ 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"); + +const buildServices = cmdLineOptions.bundle ? esbuildServices.build : () => buildProject("src/typescript", cmdLineOptions); - // 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 = { @@ -241,7 +215,13 @@ task("watch-services").flags = { const buildDynamicImportCompat = () => buildProject("src/dynamicImportCompat", cmdLineOptions); task("dynamicImportCompat", buildDynamicImportCompat); -const buildServerMain = () => buildProject("src/tsserver", cmdLineOptions); +const cleanDynamicImportCompat = () => cleanProject("src/dynamicImportCompat"); +const watchDynamicImportCompat = () => watchProject("src/dynamicImportCompat", cmdLineOptions); + + +const esbuildServer = esbuildTask("./src/tsserver/server.ts", "./built/local/tsserver.js"); + +const buildServerMain = cmdLineOptions.bundle ? esbuildServer.build : () => buildProject("src/tsserver", cmdLineOptions); const buildServer = series(buildDynamicImportCompat, buildServerMain); buildServer.displayName = "buildServer"; task("tsserver", series(preBuild, buildServer)); @@ -250,16 +230,14 @@ task("tsserver").flags = { " --built": "Compile using the built version of the compiler." }; -const cleanDynamicImportCompat = () => cleanProject("src/dynamicImportCompat"); -const cleanServerMain = () => cleanProject("src/tsserver"); +const cleanServerMain = cmdLineOptions.bundle ? esbuildServer.clean : () => cleanProject("src/tsserver"); const cleanServer = series(cleanDynamicImportCompat, cleanServerMain); 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); +const watchServer = cmdLineOptions.bundle ? esbuildServer.watch : () => watchProject("src/tsserver", cmdLineOptions); task("watch-tsserver", series(preBuild, parallel(watchLib, watchDiagnostics, watchDynamicImportCompat, watchServer))); task("watch-tsserver").description = "Watch for changes and rebuild the language server only"; task("watch-tsserver").flags = { @@ -281,97 +259,47 @@ 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"); - // 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", cmdLineOptions); 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", cmdLineOptions); 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", cmdLineOptions); -const buildEslintRules = () => buildProject("scripts/eslint"); +const buildEslintRules = () => buildProject("scripts/eslint", cmdLineOptions); task("build-eslint-rules", buildEslintRules); task("build-eslint-rules").description = "Compiles eslint rules to js"; @@ -409,16 +337,23 @@ 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", cmdLineOptions); +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 = cmdLineOptions.bundle ? esbuildTypingsInstaller.build : () => buildProject("src/typingsInstaller", cmdLineOptions); +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", cmdLineOptions); +const cleanWatchGuard = cmdLineOptions.bundle ? esbuildWatchGuard.clean : () => cleanProject("src/watchGuard"); cleanTasks.push(cleanWatchGuard); const generateTypesMap = () => src("src/server/typesMap.json") @@ -461,7 +396,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 +415,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,11 +457,13 @@ 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"; -const buildLoggedIO = () => buildProject("src/loggedIO/tsconfig-tsc-instrumented.json"); +// 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", cmdLineOptions); const cleanLoggedIO = () => del("built/local/loggedIO.js"); cleanTasks.push(cleanLoggedIO); -const buildInstrumenter = () => buildProject("src/instrumenter"); +const buildInstrumenter = () => buildProject("src/instrumenter", cmdLineOptions); const cleanInstrumenter = () => cleanProject("src/instrumenter"); cleanTasks.push(cleanInstrumenter); @@ -544,7 +481,7 @@ const updateSublime = () => src(["built/local/tsserver.js", "built/local/tsserve task("update-sublime", updateSublime); task("update-sublime").description = "Updates the sublime plugin's tsserver"; -const buildImportDefinitelyTypedTests = () => buildProject("scripts/importDefinitelyTypedTests"); +const buildImportDefinitelyTypedTests = () => buildProject("scripts/importDefinitelyTypedTests", cmdLineOptions); const cleanImportDefinitelyTypedTests = () => cleanProject("scripts/importDefinitelyTypedTests"); cleanTasks.push(cleanImportDefinitelyTypedTests); @@ -553,6 +490,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); @@ -601,6 +541,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 32119e0319d6e..2b8148a3c0da0 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.7", "eslint": "^8.22.0", "eslint-formatter-autolinkable-stylish": "^1.2.0", "eslint-plugin-import": "^2.26.0", @@ -89,6 +90,22 @@ "node": "^14 || ^16 || ^17 || ^18" } }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.7.tgz", + "integrity": "sha512-IKznSJOsVUuyt7cDzzSZyqBEcZe+7WlBqTVXiF1OXP/4Nm387ToaXZ0fyLwI1iBlI/bzpxVq411QE2/Bt2XWWw==", + "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 +2527,362 @@ "es6-symbol": "^3.1.1" } }, + "node_modules/esbuild": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.7.tgz", + "integrity": "sha512-7V8tzllIbAQV1M4QoE52ImKu8hT/NLGlGXkiDsbEU5PS6K8Mn09ZnYoS+dcmHxOS9CRsV4IRAMdT3I67IyUNXw==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/linux-loong64": "0.15.7", + "esbuild-android-64": "0.15.7", + "esbuild-android-arm64": "0.15.7", + "esbuild-darwin-64": "0.15.7", + "esbuild-darwin-arm64": "0.15.7", + "esbuild-freebsd-64": "0.15.7", + "esbuild-freebsd-arm64": "0.15.7", + "esbuild-linux-32": "0.15.7", + "esbuild-linux-64": "0.15.7", + "esbuild-linux-arm": "0.15.7", + "esbuild-linux-arm64": "0.15.7", + "esbuild-linux-mips64le": "0.15.7", + "esbuild-linux-ppc64le": "0.15.7", + "esbuild-linux-riscv64": "0.15.7", + "esbuild-linux-s390x": "0.15.7", + "esbuild-netbsd-64": "0.15.7", + "esbuild-openbsd-64": "0.15.7", + "esbuild-sunos-64": "0.15.7", + "esbuild-windows-32": "0.15.7", + "esbuild-windows-64": "0.15.7", + "esbuild-windows-arm64": "0.15.7" + } + }, + "node_modules/esbuild-android-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.7.tgz", + "integrity": "sha512-p7rCvdsldhxQr3YHxptf1Jcd86dlhvc3EQmQJaZzzuAxefO9PvcI0GLOa5nCWem1AJ8iMRu9w0r5TG8pHmbi9w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-android-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.7.tgz", + "integrity": "sha512-L775l9ynJT7rVqRM5vo+9w5g2ysbOCfsdLV4CWanTZ1k/9Jb3IYlQ06VCI1edhcosTYJRECQFJa3eAvkx72eyQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.7.tgz", + "integrity": "sha512-KGPt3r1c9ww009t2xLB6Vk0YyNOXh7hbjZ3EecHoVDxgtbUlYstMPDaReimKe6eOEfyY4hBEEeTvKwPsiH5WZg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.7.tgz", + "integrity": "sha512-kBIHvtVqbSGajN88lYMnR3aIleH3ABZLLFLxwL2stiuIGAjGlQW741NxVTpUHQXUmPzxi6POqc9npkXa8AcSZQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.7.tgz", + "integrity": "sha512-hESZB91qDLV5MEwNxzMxPfbjAhOmtfsr9Wnuci7pY6TtEh4UDuevmGmkUIjX/b+e/k4tcNBMf7SRQ2mdNuK/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.7.tgz", + "integrity": "sha512-dLFR0ChH5t+b3J8w0fVKGvtwSLWCv7GYT2Y2jFGulF1L5HftQLzVGN+6pi1SivuiVSmTh28FwUhi9PwQicXI6Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-32": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.7.tgz", + "integrity": "sha512-v3gT/LsONGUZcjbt2swrMjwxo32NJzk+7sAgtxhGx1+ZmOFaTRXBAi1PPfgpeo/J//Un2jIKm/I+qqeo4caJvg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.7.tgz", + "integrity": "sha512-LxXEfLAKwOVmm1yecpMmWERBshl+Kv5YJ/1KnyAr6HRHFW8cxOEsEfisD3sVl/RvHyW//lhYUVSuy9jGEfIRAQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.7.tgz", + "integrity": "sha512-JKgAHtMR5f75wJTeuNQbyznZZa+pjiUHV7sRZp42UNdyXC6TiUYMW/8z8yIBAr2Fpad8hM1royZKQisqPABPvQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.7.tgz", + "integrity": "sha512-P3cfhudpzWDkglutWgXcT2S7Ft7o2e3YDMrP1n0z2dlbUZghUkKCyaWw0zhp4KxEEzt/E7lmrtRu/pGWnwb9vw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-mips64le": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.7.tgz", + "integrity": "sha512-T7XKuxl0VpeFLCJXub6U+iybiqh0kM/bWOTb4qcPyDDwNVhLUiPcGdG2/0S7F93czUZOKP57YiLV8YQewgLHKw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-ppc64le": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.7.tgz", + "integrity": "sha512-6mGuC19WpFN7NYbecMIJjeQgvDb5aMuvyk0PDYBJrqAEMkTwg3Z98kEKuCm6THHRnrgsdr7bp4SruSAxEM4eJw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-riscv64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.7.tgz", + "integrity": "sha512-uUJsezbswAYo/X7OU/P+PuL/EI9WzxsEQXDekfwpQ23uGiooxqoLFAPmXPcRAt941vjlY9jtITEEikWMBr+F/g==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-s390x": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.7.tgz", + "integrity": "sha512-+tO+xOyTNMc34rXlSxK7aCwJgvQyffqEM5MMdNDEeMU3ss0S6wKvbBOQfgd5jRPblfwJ6b+bKiz0g5nABpY0QQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-netbsd-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.7.tgz", + "integrity": "sha512-yVc4Wz+Pu3cP5hzm5kIygNPrjar/v5WCSoRmIjCPWfBVJkZNb5brEGKUlf+0Y759D48BCWa0WHrWXaNy0DULTQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-openbsd-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.7.tgz", + "integrity": "sha512-GsimbwC4FSR4lN3wf8XmTQ+r8/0YSQo21rWDL0XFFhLHKlzEA4SsT1Tl8bPYu00IU6UWSJ+b3fG/8SB69rcuEQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-sunos-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.7.tgz", + "integrity": "sha512-8CDI1aL/ts0mDGbWzjEOGKXnU7p3rDzggHSBtVryQzkSOsjCHRVe0iFYUuhczlxU1R3LN/E7HgUO4NXzGGP/Ag==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-32": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.7.tgz", + "integrity": "sha512-cOnKXUEPS8EGCzRSFa1x6NQjGhGsFlVgjhqGEbLTPsA7x4RRYiy2RKoArNUU4iR2vHmzqS5Gr84MEumO/wxYKA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.7.tgz", + "integrity": "sha512-7MI08Ec2sTIDv+zH6StNBKO+2hGUYIT42GmFyW6MBBWWtJhTcQLinKS6ldIN1d52MXIbiJ6nXyCJ+LpL4jBm3Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.7.tgz", + "integrity": "sha512-R06nmqBlWjKHddhRJYlqDd3Fabx9LFdKcjoOy08YLimwmsswlFBJV4rXzZCxz/b7ZJXvrZgj8DDv1ewE9+StMw==", + "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 +9230,13 @@ "jsdoc-type-pratt-parser": "~3.1.0" } }, + "@esbuild/linux-loong64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.7.tgz", + "integrity": "sha512-IKznSJOsVUuyt7cDzzSZyqBEcZe+7WlBqTVXiF1OXP/4Nm387ToaXZ0fyLwI1iBlI/bzpxVq411QE2/Bt2XWWw==", + "dev": true, + "optional": true + }, "@eslint/eslintrc": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", @@ -10801,6 +11181,175 @@ "es6-symbol": "^3.1.1" } }, + "esbuild": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.7.tgz", + "integrity": "sha512-7V8tzllIbAQV1M4QoE52ImKu8hT/NLGlGXkiDsbEU5PS6K8Mn09ZnYoS+dcmHxOS9CRsV4IRAMdT3I67IyUNXw==", + "dev": true, + "requires": { + "@esbuild/linux-loong64": "0.15.7", + "esbuild-android-64": "0.15.7", + "esbuild-android-arm64": "0.15.7", + "esbuild-darwin-64": "0.15.7", + "esbuild-darwin-arm64": "0.15.7", + "esbuild-freebsd-64": "0.15.7", + "esbuild-freebsd-arm64": "0.15.7", + "esbuild-linux-32": "0.15.7", + "esbuild-linux-64": "0.15.7", + "esbuild-linux-arm": "0.15.7", + "esbuild-linux-arm64": "0.15.7", + "esbuild-linux-mips64le": "0.15.7", + "esbuild-linux-ppc64le": "0.15.7", + "esbuild-linux-riscv64": "0.15.7", + "esbuild-linux-s390x": "0.15.7", + "esbuild-netbsd-64": "0.15.7", + "esbuild-openbsd-64": "0.15.7", + "esbuild-sunos-64": "0.15.7", + "esbuild-windows-32": "0.15.7", + "esbuild-windows-64": "0.15.7", + "esbuild-windows-arm64": "0.15.7" + } + }, + "esbuild-android-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.7.tgz", + "integrity": "sha512-p7rCvdsldhxQr3YHxptf1Jcd86dlhvc3EQmQJaZzzuAxefO9PvcI0GLOa5nCWem1AJ8iMRu9w0r5TG8pHmbi9w==", + "dev": true, + "optional": true + }, + "esbuild-android-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.7.tgz", + "integrity": "sha512-L775l9ynJT7rVqRM5vo+9w5g2ysbOCfsdLV4CWanTZ1k/9Jb3IYlQ06VCI1edhcosTYJRECQFJa3eAvkx72eyQ==", + "dev": true, + "optional": true + }, + "esbuild-darwin-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.7.tgz", + "integrity": "sha512-KGPt3r1c9ww009t2xLB6Vk0YyNOXh7hbjZ3EecHoVDxgtbUlYstMPDaReimKe6eOEfyY4hBEEeTvKwPsiH5WZg==", + "dev": true, + "optional": true + }, + "esbuild-darwin-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.7.tgz", + "integrity": "sha512-kBIHvtVqbSGajN88lYMnR3aIleH3ABZLLFLxwL2stiuIGAjGlQW741NxVTpUHQXUmPzxi6POqc9npkXa8AcSZQ==", + "dev": true, + "optional": true + }, + "esbuild-freebsd-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.7.tgz", + "integrity": "sha512-hESZB91qDLV5MEwNxzMxPfbjAhOmtfsr9Wnuci7pY6TtEh4UDuevmGmkUIjX/b+e/k4tcNBMf7SRQ2mdNuK/HQ==", + "dev": true, + "optional": true + }, + "esbuild-freebsd-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.7.tgz", + "integrity": "sha512-dLFR0ChH5t+b3J8w0fVKGvtwSLWCv7GYT2Y2jFGulF1L5HftQLzVGN+6pi1SivuiVSmTh28FwUhi9PwQicXI6Q==", + "dev": true, + "optional": true + }, + "esbuild-linux-32": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.7.tgz", + "integrity": "sha512-v3gT/LsONGUZcjbt2swrMjwxo32NJzk+7sAgtxhGx1+ZmOFaTRXBAi1PPfgpeo/J//Un2jIKm/I+qqeo4caJvg==", + "dev": true, + "optional": true + }, + "esbuild-linux-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.7.tgz", + "integrity": "sha512-LxXEfLAKwOVmm1yecpMmWERBshl+Kv5YJ/1KnyAr6HRHFW8cxOEsEfisD3sVl/RvHyW//lhYUVSuy9jGEfIRAQ==", + "dev": true, + "optional": true + }, + "esbuild-linux-arm": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.7.tgz", + "integrity": "sha512-JKgAHtMR5f75wJTeuNQbyznZZa+pjiUHV7sRZp42UNdyXC6TiUYMW/8z8yIBAr2Fpad8hM1royZKQisqPABPvQ==", + "dev": true, + "optional": true + }, + "esbuild-linux-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.7.tgz", + "integrity": "sha512-P3cfhudpzWDkglutWgXcT2S7Ft7o2e3YDMrP1n0z2dlbUZghUkKCyaWw0zhp4KxEEzt/E7lmrtRu/pGWnwb9vw==", + "dev": true, + "optional": true + }, + "esbuild-linux-mips64le": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.7.tgz", + "integrity": "sha512-T7XKuxl0VpeFLCJXub6U+iybiqh0kM/bWOTb4qcPyDDwNVhLUiPcGdG2/0S7F93czUZOKP57YiLV8YQewgLHKw==", + "dev": true, + "optional": true + }, + "esbuild-linux-ppc64le": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.7.tgz", + "integrity": "sha512-6mGuC19WpFN7NYbecMIJjeQgvDb5aMuvyk0PDYBJrqAEMkTwg3Z98kEKuCm6THHRnrgsdr7bp4SruSAxEM4eJw==", + "dev": true, + "optional": true + }, + "esbuild-linux-riscv64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.7.tgz", + "integrity": "sha512-uUJsezbswAYo/X7OU/P+PuL/EI9WzxsEQXDekfwpQ23uGiooxqoLFAPmXPcRAt941vjlY9jtITEEikWMBr+F/g==", + "dev": true, + "optional": true + }, + "esbuild-linux-s390x": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.7.tgz", + "integrity": "sha512-+tO+xOyTNMc34rXlSxK7aCwJgvQyffqEM5MMdNDEeMU3ss0S6wKvbBOQfgd5jRPblfwJ6b+bKiz0g5nABpY0QQ==", + "dev": true, + "optional": true + }, + "esbuild-netbsd-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.7.tgz", + "integrity": "sha512-yVc4Wz+Pu3cP5hzm5kIygNPrjar/v5WCSoRmIjCPWfBVJkZNb5brEGKUlf+0Y759D48BCWa0WHrWXaNy0DULTQ==", + "dev": true, + "optional": true + }, + "esbuild-openbsd-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.7.tgz", + "integrity": "sha512-GsimbwC4FSR4lN3wf8XmTQ+r8/0YSQo21rWDL0XFFhLHKlzEA4SsT1Tl8bPYu00IU6UWSJ+b3fG/8SB69rcuEQ==", + "dev": true, + "optional": true + }, + "esbuild-sunos-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.7.tgz", + "integrity": "sha512-8CDI1aL/ts0mDGbWzjEOGKXnU7p3rDzggHSBtVryQzkSOsjCHRVe0iFYUuhczlxU1R3LN/E7HgUO4NXzGGP/Ag==", + "dev": true, + "optional": true + }, + "esbuild-windows-32": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.7.tgz", + "integrity": "sha512-cOnKXUEPS8EGCzRSFa1x6NQjGhGsFlVgjhqGEbLTPsA7x4RRYiy2RKoArNUU4iR2vHmzqS5Gr84MEumO/wxYKA==", + "dev": true, + "optional": true + }, + "esbuild-windows-64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.7.tgz", + "integrity": "sha512-7MI08Ec2sTIDv+zH6StNBKO+2hGUYIT42GmFyW6MBBWWtJhTcQLinKS6ldIN1d52MXIbiJ6nXyCJ+LpL4jBm3Q==", + "dev": true, + "optional": true + }, + "esbuild-windows-arm64": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.7.tgz", + "integrity": "sha512-R06nmqBlWjKHddhRJYlqDd3Fabx9LFdKcjoOy08YLimwmsswlFBJV4rXzZCxz/b7ZJXvrZgj8DDv1ewE9+StMw==", + "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..841134462c5e3 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.7", "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..b1af1b7e6c5c6 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 } }); @@ -69,6 +70,7 @@ if (module.exports.built) { * @property {boolean} failed * @property {boolean} keepFailed * @property {boolean} ci + * @property {boolean} bundle * * @typedef {import("minimist").ParsedArgs & TypedOptions} CommandLineOptions */ 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/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/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/dbg.ts index 3b531914d532d..1a870b02d6f0e 100644 --- a/src/debug/dbg.ts +++ b/src/debug/dbg.ts @@ -1,5 +1,3 @@ -import * as Debug from "./_namespaces/Debug"; - /// interface Node { @@ -510,9 +508,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..2325755298768 100644 --- a/src/debug/tsconfig.json +++ b/src/debug/tsconfig.json @@ -7,6 +7,5 @@ }, "files": [ "dbg.ts", - "_namespaces/Debug.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 index 5981d8c7e968e..d02bfd3dca648 100644 --- a/src/dynamicImportCompat/dynamicImportCompat.ts +++ b/src/dynamicImportCompat/dynamicImportCompat.ts @@ -1 +1 @@ -export const dynamicImport = (id: string) => import(id); \ No newline at end of file +(globalThis as any).dynamicImport = (id: string) => import(id); diff --git a/src/dynamicImportCompat/tsconfig.json b/src/dynamicImportCompat/tsconfig.json index 3abacb2133d0a..f6529d3c91f24 100644 --- a/src/dynamicImportCompat/tsconfig.json +++ b/src/dynamicImportCompat/tsconfig.json @@ -1,15 +1,15 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local/dynamicImportCompat", + "outDir": "../../built/local", + "tsBuildInfoFile": "../../built/local/dynamicImportCompat.tsbuildinfo", "rootDir": ".", "target": "esnext", "module": "esnext", - "lib": ["esnext"] + "lib": ["esnext"], + "emitDeclarationOnly": false }, "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..fe17bc06d109f 100644 --- a/src/services/_namespaces/ts.ts +++ b/src/services/_namespaces/ts.ts @@ -17,6 +17,8 @@ export * from "../transpile"; export * from "../services"; export * from "../transform"; export * from "../shims"; +export * from "../globalThisShim"; +export * from "../exportAsModule"; 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 index 757f9f7cd34fe..eb6e51fa9c657 100644 --- a/src/services/exportAsModule.ts +++ b/src/services/exportAsModule.ts @@ -3,7 +3,19 @@ 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; -} +// /** @internal */ declare const module: { exports: {} }; +// if (typeof module !== "undefined" && module.exports) { +// module.exports = ts; +// } + +// If we are bundled with esbuild via IIFE, this is a hacky way to jump out of +// its module system and conditionally export to CJS in the bundle. +// +// We may want to do something different for this. + +// eslint-disable-next-line no-eval +// eval("(ts) => { if (typeof module !== 'undefined' && module.exports) module.exports = ts }")(ts); + +// TODO(jakebailey): remove; this is just here and ignored for now. +// eslint-disable-next-line @typescript-eslint/no-unused-expressions +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/testRunner/_namespaces/Harness.ts b/src/testRunner/_namespaces/Harness.ts index caf03e950ac7e..aff7e44d98af4 100644 --- a/src/testRunner/_namespaces/Harness.ts +++ b/src/testRunner/_namespaces/Harness.ts @@ -11,3 +11,8 @@ export * from "../compilerRunner"; export * from "../externalCompileRunner"; export * from "../test262Runner"; export * from "../runner"; + + +// Must be after runner. +// NOTE: if emitting CJS, comment this out, and uncomment the one in runner.ts. +import "./tests"; diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index afce9655270a0..0aec1a0136eed 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -293,4 +293,5 @@ 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"; diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index d3ece6a19d613..c07487870f7a9 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -10,6 +10,7 @@ "sourceMap": true, "composite": true, "noEmitOnError": true, + "emitDeclarationOnly": true, "strictNullChecks": true, "noImplicitAny": true, 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..6d24c4aab1d69 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,11 +125,21 @@ export class MainProcessLogger extends BaseLogger { } } +let dynamicImport = async (_id: string): Promise => { + throw new Error("Dynamic import not implemented"); +}; + +// eslint-disable-next-line @typescript-eslint/naming-convention +declare const __import__: (_id: string) => Promise; + // Attempt to load `dynamicImport` if (typeof importScripts === "function") { try { // NOTE: importScripts is synchronous - importScripts("dynamicImportCompat.js"); + // importScripts("dynamicImportCompat.js"); + // dynamicImport = (globalThis as any).dynamicImport; + // delete (globalThis as any).dynamicImport; + dynamicImport = __import__; } catch { // ignored @@ -144,16 +153,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