Skip to content

Commit 708c6b0

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 a5ae9f0 commit 708c6b0

33 files changed

+929
-399
lines changed

Gulpfile.mjs

Lines changed: 247 additions & 175 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/localization.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const localizationDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"].map(f => f.toLowerCase());

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: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from "path";
33
import glob from "glob";
44
import url from "url";
55
import del from "del";
6+
import { localizationDirectories } from "./build/localization.mjs";
67

78
const __filename = url.fileURLToPath(new URL(import.meta.url));
89
const __dirname = path.dirname(__filename);
@@ -29,15 +30,9 @@ async function copyLibFiles() {
2930
}
3031

3132
async function copyLocalizedDiagnostics() {
32-
const dir = await fs.readdir(source);
33-
const ignoredFolders = ["enu"];
34-
35-
for (const d of dir) {
33+
for (const d of localizationDirectories) {
3634
const fileName = path.join(source, d);
37-
if (
38-
fs.statSync(fileName).isDirectory() &&
39-
ignoredFolders.indexOf(d) < 0
40-
) {
35+
if (fs.statSync(fileName).isDirectory()) {
4136
await fs.copy(fileName, path.join(dest, d));
4237
}
4338
}
@@ -48,21 +43,18 @@ async function copyTypesMap() {
4843
}
4944

5045
async function copyScriptOutputs() {
51-
await copyWithCopyright("cancellationToken.js");
52-
await copyWithCopyright("tsc.release.js", "tsc.js");
53-
await copyWithCopyright("tsserver.js");
54-
await copyWithCopyright("dynamicImportCompat.js");
55-
await copyFromBuiltLocal("tsserverlibrary.js"); // copyright added by build
56-
await copyFromBuiltLocal("typescript.js"); // copyright added by build
57-
await copyFromBuiltLocal("typescriptServices.js"); // copyright added by build
58-
await copyWithCopyright("typingsInstaller.js");
59-
await copyWithCopyright("watchGuard.js");
46+
await copyFromBuiltLocal("cancellationToken.js");
47+
await copyFromBuiltLocal("tsc.js");
48+
await copyFromBuiltLocal("tsserver.js");
49+
await copyFromBuiltLocal("tsserverlibrary.js");
50+
await copyFromBuiltLocal("typescript.js");
51+
await copyFromBuiltLocal("typingsInstaller.js");
52+
await copyFromBuiltLocal("watchGuard.js");
6053
}
6154

6255
async function copyDeclarationOutputs() {
63-
await copyFromBuiltLocal("tsserverlibrary.d.ts"); // copyright added by build
64-
await copyFromBuiltLocal("typescript.d.ts"); // copyright added by build
65-
await copyFromBuiltLocal("typescriptServices.d.ts"); // copyright added by build
56+
await copyWithCopyright("tsserverlibrary.d.ts");
57+
await copyWithCopyright("typescript.d.ts");
6658
}
6759

6860
async function writeGitAttributes() {

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"

0 commit comments

Comments
 (0)