Skip to content

Commit 142f87b

Browse files
committed
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.
1 parent ae931a4 commit 142f87b

File tree

24 files changed

+755
-255
lines changed

24 files changed

+755
-255
lines changed

Gulpfile.js

Lines changed: 124 additions & 182 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 549 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"chalk": "^4.1.2",
7070
"del": "^6.1.1",
7171
"diff": "^5.1.0",
72+
"esbuild": "^0.15.7",
7273
"eslint": "^8.22.0",
7374
"eslint-formatter-autolinkable-stylish": "^1.2.0",
7475
"eslint-plugin-import": "^2.26.0",

scripts/build/options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ci = ["1", "true"].includes(process.env.CI);
66

77
/** @type {CommandLineOptions} */
88
module.exports = minimist(process.argv.slice(2), {
9-
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci"],
9+
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle"],
1010
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
1111
alias: {
1212
/* eslint-disable quote-props */
@@ -41,6 +41,7 @@ module.exports = minimist(process.argv.slice(2), {
4141
dirty: false,
4242
built: false,
4343
ci,
44+
bundle: true
4445
}
4546
});
4647

@@ -69,6 +70,7 @@ if (module.exports.built) {
6970
* @property {boolean} failed
7071
* @property {boolean} keepFailed
7172
* @property {boolean} ci
73+
* @property {boolean} bundle
7274
*
7375
* @typedef {import("minimist").ParsedArgs & TypedOptions} CommandLineOptions
7476
*/

scripts/build/tests.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,17 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode)
123123
errorStatus = exitCode;
124124
error = new Error(`Process exited with status code ${errorStatus}.`);
125125
}
126-
else if (cmdLineOptions.ci) {
127-
// finally, do a sanity check and build the compiler with the built version of itself
128-
log.info("Starting sanity check build...");
129-
// Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them)
130-
await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"]);
131-
const { exitCode } = await exec("gulp", ["local", "--lkg=false"]);
132-
if (exitCode !== 0) {
133-
errorStatus = exitCode;
134-
error = new Error(`Sanity check build process exited with status code ${errorStatus}.`);
135-
}
136-
}
126+
// else if (cmdLineOptions.ci) {
127+
// // finally, do a sanity check and build the compiler with the built version of itself
128+
// log.info("Starting sanity check build...");
129+
// // Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them)
130+
// await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"]);
131+
// const { exitCode } = await exec("gulp", ["local", "--lkg=false"]);
132+
// if (exitCode !== 0) {
133+
// errorStatus = exitCode;
134+
// error = new Error(`Sanity check build process exited with status code ${errorStatus}.`);
135+
// }
136+
// }
137137
}
138138
catch (e) {
139139
errorStatus = undefined;

src/cancellationToken/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"extends": "../tsconfig-base",
33
"compilerOptions": {
4-
"outDir": "../../built/local/cancellationToken",
4+
"outDir": "../../built/local",
5+
"tsBuildInfoFile": "../../built/local/cancellationToken.tsbuildinfo",
6+
"rootDir": ".",
57
"module": "commonjs",
68
"types": [
79
"node"

src/compiler/sys.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,13 @@ export let sys: System = (() => {
14661466
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
14671467
const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
14681468

1469+
// If our filename is "sys.js", then we are executing unbundled on the raw tsc output.
1470+
// In that case, simulate a faked path in the directory where a bundle would normally
1471+
// appear (e.g. the directory containing lib.*.d.ts files).
1472+
//
1473+
// Note that if we ever emit as files like cjs/mjs, this check will be wrong.
1474+
const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
1475+
14691476
const fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
14701477
const getCurrentDirectory = memoize(() => process.cwd());
14711478
const { watchFile, watchDirectory } = createSystemWatchFunctions({
@@ -1525,14 +1532,7 @@ export let sys: System = (() => {
15251532
}
15261533
},
15271534
getExecutingFilePath() {
1528-
// This function previously returned a path like `built/local/tsc.js`.
1529-
// Now, with a module output, this file is now `built/local/compiler/sys.js`.
1530-
// We want to return a file that looks like the old one, so that callers
1531-
// can locate other assets like the lib.d.ts files.
1532-
//
1533-
// TODO(jakebailey): replace this function with one that returns the path
1534-
// to the lib folder (or package path)?.
1535-
return _path.join(_path.dirname(__dirname), "fake.js");
1535+
return executingFilePath;
15361536
},
15371537
getCurrentDirectory,
15381538
getDirectories,
@@ -1571,7 +1571,10 @@ export let sys: System = (() => {
15711571
debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv as string[], arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)),
15721572
tryEnableSourceMapsForHost() {
15731573
try {
1574-
require("source-map-support").install();
1574+
// Trick esbuild into not eagerly resolving a path to a JS file.
1575+
// See: https://github.com/evanw/esbuild/issues/1958
1576+
const moduleName = "source-map-support" as const;
1577+
(require(moduleName) as typeof import("source-map-support")).install();
15751578
}
15761579
catch {
15771580
// Could not enable source maps.

src/debug/_namespaces/Debug.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/debug/dbg.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as Debug from "./_namespaces/Debug";
2-
31
/// <reference lib="es2019" />
42

53
interface Node {
@@ -510,9 +508,3 @@ export function formatControlFlowGraph(flowNode: FlowNode) {
510508
return s;
511509
}
512510
}
513-
514-
// Export as a module. NOTE: Can't use module exports as this is built using --outFile
515-
declare const module: { exports: {} };
516-
if (typeof module !== "undefined" && module.exports) {
517-
module.exports = Debug;
518-
}

src/debug/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
},
88
"files": [
99
"dbg.ts",
10-
"_namespaces/Debug.ts"
1110
]
1211
}

0 commit comments

Comments
 (0)