FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add build via esbuild · jakebailey/TypeScript@e7f8f95 · GitHub

Commit e7f8f95

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 9de9f71 commit e7f8f95

32 files changed

Lines changed: 940 additions & 399 deletions

‎Gulpfile.mjs‎

Lines changed: 241 additions & 173 deletions
Large diffs are not rendered by default.

‎package-lock.json‎

Lines changed: 574 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
@@ -67,6 +67,7 @@
6767
"chalk": "^4.1.2",
6868
"del": "^6.1.1",
6969
"diff": "^5.1.0",
70+
"esbuild": "^0.15.9",
7071
"eslint": "^8.22.0",
7172
"eslint-formatter-autolinkable-stylish": "^1.2.0",
7273
"eslint-plugin-import": "^2.26.0",

‎scripts/build/options.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import os from "os";
44
const ci = ["1", "true"].includes(process.env.CI ?? "");
55

66
const parsed = minimist(process.argv.slice(2), {
7-
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci"],
7+
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle"],
88
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
99
alias: {
1010
/* eslint-disable quote-props */
@@ -39,6 +39,7 @@ const parsed = minimist(process.argv.slice(2), {
3939
dirty: false,
4040
built: false,
4141
ci,
42+
bundle: true
4243
}
4344
});
4445

@@ -77,5 +78,7 @@ export default options;
7778
* @property {boolean} ci
7879
* @property {string} shards
7980
* @property {string} shardId
81+
* @property {string} break
82+
* @property {boolean} bundle
8083
*/
8184
void 0;

‎scripts/build/prepend.mjs‎

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

‎scripts/build/projects.mjs‎

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,57 @@
11
import { exec, Debouncer } from "./utils.mjs";
22
import { resolve } from "path";
33
import { findUpRoot } from "./findUpDir.mjs";
4-
import assert from "assert";
4+
import cmdLineOptions from "./options.mjs";
55

66
class ProjectQueue {
77
/**
8-
* @param {(projects: string[], lkg: boolean, force: boolean) => Promise<any>} action
8+
* @param {(projects: string[]) => Promise<any>} action
99
*/
1010
constructor(action) {
11-
/** @type {{ lkg: boolean, force: boolean, projects?: string[], debouncer: Debouncer }[]} */
12-
this._debouncers = [];
13-
this._action = action;
11+
/** @type {string[] | undefined} */
12+
this._projects = undefined;
13+
this._debouncer = new Debouncer(100, async () => {
14+
const projects = this._projects;
15+
if (projects) {
16+
this._projects = undefined;
17+
await action(projects);
18+
}
19+
});
1420
}
1521

1622
/**
1723
* @param {string} project
18-
* @param {{ lkg?: boolean; force?: boolean; }} options
1924
*/
20-
enqueue(project, { lkg = true, force = false } = {}) {
21-
let entry = this._debouncers.find(entry => entry.lkg === lkg && entry.force === force);
22-
if (!entry) {
23-
const debouncer = new Debouncer(100, async () => {
24-
assert(entry);
25-
const projects = entry.projects;
26-
if (projects) {
27-
entry.projects = undefined;
28-
await this._action(projects, lkg, force);
29-
}
30-
});
31-
this._debouncers.push(entry = { lkg, force, debouncer });
32-
}
33-
if (!entry.projects) entry.projects = [];
34-
entry.projects.push(project);
35-
return entry.debouncer.enqueue();
25+
enqueue(project) {
26+
if (!this._projects) this._projects = [];
27+
this._projects.push(project);
28+
return this._debouncer.enqueue();
3629
}
3730
}
3831

39-
const execTsc = (/** @type {boolean} */ lkg, /** @type {string[]} */ ...args) =>
32+
const execTsc = (/** @type {string[]} */ ...args) =>
4033
exec(process.execPath,
41-
[resolve(findUpRoot(), lkg ? "./lib/tsc" : "./built/local/tsc"),
34+
[resolve(findUpRoot(), cmdLineOptions.lkg ? "./lib/tsc" : "./built/local/tsc"),
4235
"-b", ...args],
4336
{ hidePrompt: true });
4437

45-
const projectBuilder = new ProjectQueue((projects, lkg, force) => execTsc(lkg, ...(force ? ["--force"] : []), ...projects));
38+
const projectBuilder = new ProjectQueue((projects) => execTsc(...projects));
4639

4740
/**
4841
* @param {string} project
49-
* @param {object} options
50-
* @param {boolean} [options.lkg=true]
51-
* @param {boolean} [options.force=false]
5242
*/
53-
export const buildProject = (project, { lkg, force } = {}) => projectBuilder.enqueue(project, { lkg, force });
43+
export const buildProject = (project) => projectBuilder.enqueue(project);
5444

55-
const projectCleaner = new ProjectQueue((projects, lkg) => execTsc(lkg, "--clean", ...projects));
45+
const projectCleaner = new ProjectQueue((projects) => execTsc("--clean", ...projects));
5646

5747
/**
5848
* @param {string} project
5949
*/
6050
export const cleanProject = (project) => projectCleaner.enqueue(project);
6151

62-
const projectWatcher = new ProjectQueue((projects) => execTsc(/*lkg*/ true, "--watch", ...projects));
52+
const projectWatcher = new ProjectQueue((projects) => execTsc("--watch", ...projects));
6353

6454
/**
6555
* @param {string} project
66-
* @param {object} options
67-
* @param {boolean} [options.lkg=true]
6856
*/
69-
export const watchProject = (project, { lkg } = {}) => projectWatcher.enqueue(project, { lkg });
57+
export const watchProject = (project) => projectWatcher.enqueue(project);

‎scripts/build/tests.mjs‎

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

‎scripts/produceLKG.mjs‎

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ async function copyLocalizedDiagnostics() {
3030
const dir = await fs.readdir(source);
3131
const ignoredFolders = ["enu"];
3232

33+
// TODO(jakebailey): Instead of ignoring folders, we should keep a list of
34+
// the localizationTargets somewhere that can be used by multiple modules.
35+
ignoredFolders.push(
36+
"compiler",
37+
"deprecatedCompat",
38+
"executeCommandLine",
39+
"harness",
40+
"jsTyping",
41+
"loggedIO",
42+
"server",
43+
"services",
44+
"testRunner",
45+
"tsc",
46+
"tsserver",
47+
"tsserverlibrary",
48+
"typescript",
49+
"typingsInstaller",
50+
"typingsInstallerCore",
51+
"webServer",
52+
);
53+
3354
for (const d of dir) {
3455
const fileName = path.join(source, d);
3556
if (
@@ -46,21 +67,18 @@ async function copyTypesMap() {
4667
}
4768

4869
async function copyScriptOutputs() {
49-
await copyWithCopyright("cancellationToken.js");
50-
await copyWithCopyright("tsc.release.js", "tsc.js");
51-
await copyWithCopyright("tsserver.js");
52-
await copyWithCopyright("dynamicImportCompat.js");
53-
await copyFromBuiltLocal("tsserverlibrary.js"); // copyright added by build
54-
await copyFromBuiltLocal("typescript.js"); // copyright added by build
55-
await copyFromBuiltLocal("typescriptServices.js"); // copyright added by build
56-
await copyWithCopyright("typingsInstaller.js");
57-
await copyWithCopyright("watchGuard.js");
70+
await copyFromBuiltLocal("cancellationToken.js");
71+
await copyFromBuiltLocal("tsc.js");
72+
await copyFromBuiltLocal("tsserver.js");
73+
await copyFromBuiltLocal("tsserverlibrary.js");
74+
await copyFromBuiltLocal("typescript.js");
75+
await copyFromBuiltLocal("typingsInstaller.js");
76+
await copyFromBuiltLocal("watchGuard.js");
5877
}
5978

6079
async function copyDeclarationOutputs() {
61-
await copyFromBuiltLocal("tsserverlibrary.d.ts"); // copyright added by build
62-
await copyFromBuiltLocal("typescript.d.ts"); // copyright added by build
63-
await copyFromBuiltLocal("typescriptServices.d.ts"); // copyright added by build
80+
await copyWithCopyright("tsserverlibrary.d.ts");
81+
await copyWithCopyright("typescript.d.ts");
6482
}
6583

6684
async function writeGitAttributes() {
@@ -94,16 +112,6 @@ async function copyFilesWithGlob(pattern) {
94112
console.log(`Copied ${files.length} files matching pattern ${pattern}`);
95113
}
96114

97-
/**
98-
* @param {string} path
99-
* @param {string[]} args
100-
*/
101-
async function exec(path, args = []) {
102-
const cmdLine = ["node", path, ...args].join(" ");
103-
console.log(cmdLine);
104-
childProcess.execSync(cmdLine);
105-
}
106-
107115
process.on("unhandledRejection", err => {
108116
throw err;
109117
});

‎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/debug.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ export namespace Debug {
721721
try {
722722
if (sys && sys.require) {
723723
const basePath = getDirectoryPath(resolvePath(sys.getExecutingFilePath()));
724-
const result = sys.require(basePath, "./compiler-debug") as RequireResult<ExtendedDebugModule>;
724+
const result = sys.require(basePath, "./compilerDebug") as RequireResult<ExtendedDebugModule>;
725725
if (!result.error) {
726726
result.module.init(ts);
727727
extendedDebugModule = result.module;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL