Skip to content

Commit b6ac01a

Browse files
committed
Add dts bundling
1 parent 468c3e5 commit b6ac01a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+7959
-7878
lines changed

.gitignore

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,86 @@
1-
node_modules/
2-
.node_modules/
3-
built/*
4-
tests/cases/rwc/*
5-
tests/cases/test262/*
6-
tests/cases/perf/*
7-
!tests/cases/webharness/compilerToString.js
8-
test-args.txt
9-
~*.docx
10-
\#*\#
11-
.\#*
12-
tests/baselines/local/*
13-
tests/baselines/local.old/*
14-
tests/services/baselines/local/*
15-
tests/baselines/prototyping/local/*
16-
tests/baselines/rwc/*
17-
tests/baselines/test262/*
18-
tests/baselines/reference/projectOutput/*
19-
tests/baselines/local/projectOutput/*
20-
tests/baselines/reference/testresults.tap
21-
tests/services/baselines/prototyping/local/*
22-
tests/services/browser/typescriptServices.js
23-
src/harness/*.js
24-
src/compiler/diagnosticInformationMap.generated.ts
25-
src/compiler/diagnosticMessages.generated.json
26-
src/parser/diagnosticInformationMap.generated.ts
27-
src/parser/diagnosticMessages.generated.json
28-
rwc-report.html
29-
*.swp
30-
build.json
31-
*.actual
32-
tests/webTestServer.js
33-
tests/webTestServer.js.map
34-
tests/webhost/*.d.ts
35-
tests/webhost/webtsc.js
36-
tests/cases/**/*.js
37-
!tests/cases/docker/*.js/
38-
tests/cases/**/*.js.map
39-
*.config
40-
scripts/eslint/built/
41-
scripts/debug.bat
42-
scripts/run.bat
43-
scripts/**/*.js
44-
scripts/**/*.js.map
45-
coverage/
46-
internal/
47-
**/.DS_Store
48-
.settings
49-
**/.vs
50-
**/.vscode/*
51-
!**/.vscode/tasks.json
52-
!**/.vscode/settings.template.json
53-
!**/.vscode/launch.template.json
54-
!**/.vscode/extensions.json
55-
!tests/cases/projects/projectOption/**/node_modules
56-
!tests/cases/projects/NodeModulesSearch/**/*
57-
!tests/baselines/reference/project/nodeModules*/**/*
58-
.idea
59-
yarn.lock
60-
yarn-error.log
61-
.parallelperf.*
62-
tests/cases/user/*/package-lock.json
63-
tests/cases/user/*/node_modules/
64-
tests/cases/user/*/**/*.js
65-
tests/cases/user/*/**/*.js.map
66-
tests/cases/user/*/**/*.d.ts
67-
!tests/cases/user/zone.js/
68-
!tests/cases/user/bignumber.js/
69-
!tests/cases/user/discord.js/
70-
tests/baselines/reference/dt
71-
.failed-tests
72-
TEST-results.xml
73-
package-lock.json
74-
tests/cases/user/npm/npm
75-
tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
76-
tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
77-
tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
78-
tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
79-
tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
80-
tests/cases/user/create-react-app/create-react-app
81-
tests/cases/user/fp-ts/fp-ts
82-
tests/cases/user/webpack/webpack
83-
tests/cases/user/puppeteer/puppeteer
84-
tests/cases/user/axios-src/axios-src
85-
tests/cases/user/prettier/prettier
86-
.eslintcache
1+
node_modules/
2+
.node_modules/
3+
built/*
4+
tests/cases/rwc/*
5+
tests/cases/test262/*
6+
tests/cases/perf/*
7+
!tests/cases/webharness/compilerToString.js
8+
test-args.txt
9+
~*.docx
10+
\#*\#
11+
.\#*
12+
tests/baselines/local/*
13+
tests/baselines/local.old/*
14+
tests/services/baselines/local/*
15+
tests/baselines/prototyping/local/*
16+
tests/baselines/rwc/*
17+
tests/baselines/test262/*
18+
tests/baselines/reference/projectOutput/*
19+
tests/baselines/local/projectOutput/*
20+
tests/baselines/reference/testresults.tap
21+
tests/services/baselines/prototyping/local/*
22+
tests/services/browser/typescriptServices.js
23+
src/harness/*.js
24+
src/compiler/diagnosticInformationMap.generated.ts
25+
src/compiler/diagnosticMessages.generated.json
26+
src/parser/diagnosticInformationMap.generated.ts
27+
src/parser/diagnosticMessages.generated.json
28+
rwc-report.html
29+
*.swp
30+
build.json
31+
*.actual
32+
tests/webTestServer.js
33+
tests/webTestServer.js.map
34+
tests/webhost/*.d.ts
35+
tests/webhost/webtsc.js
36+
tests/cases/**/*.js
37+
!tests/cases/docker/*.js/
38+
tests/cases/**/*.js.map
39+
*.config
40+
scripts/eslint/built/
41+
scripts/debug.bat
42+
scripts/run.bat
43+
scripts/**/*.js
44+
scripts/**/*.js.map
45+
coverage/
46+
internal/
47+
**/.DS_Store
48+
.settings
49+
**/.vs
50+
**/.vscode/*
51+
!**/.vscode/tasks.json
52+
!**/.vscode/settings.template.json
53+
!**/.vscode/launch.template.json
54+
!**/.vscode/extensions.json
55+
!tests/cases/projects/projectOption/**/node_modules
56+
!tests/cases/projects/NodeModulesSearch/**/*
57+
!tests/baselines/reference/project/nodeModules*/**/*
58+
.idea
59+
yarn.lock
60+
yarn-error.log
61+
.parallelperf.*
62+
tests/cases/user/*/package-lock.json
63+
tests/cases/user/*/node_modules/
64+
tests/cases/user/*/**/*.js
65+
tests/cases/user/*/**/*.js.map
66+
tests/cases/user/*/**/*.d.ts
67+
!tests/cases/user/zone.js/
68+
!tests/cases/user/bignumber.js/
69+
!tests/cases/user/discord.js/
70+
tests/baselines/reference/dt
71+
.failed-tests
72+
TEST-results.xml
73+
package-lock.json
74+
tests/cases/user/npm/npm
75+
tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
76+
tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
77+
tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
78+
tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
79+
tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
80+
tests/cases/user/create-react-app/create-react-app
81+
tests/cases/user/fp-ts/fp-ts
82+
tests/cases/user/webpack/webpack
83+
tests/cases/user/puppeteer/puppeteer
84+
tests/cases/user/axios-src/axios-src
85+
tests/cases/user/prettier/prettier
86+
.eslintcache

Gulpfile.mjs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ const buildSrc = () => buildProject("src");
125125

126126
task("build-src", series(preSrc, buildSrc));
127127

128+
/**
129+
* @param {string} entrypoint
130+
* @param {string} output
131+
*/
132+
async function runDtsBundler(entrypoint, output) {
133+
await exec(process.execPath, [
134+
"./scripts/dtsBundler.mjs",
135+
"--entrypoint",
136+
entrypoint,
137+
"--output",
138+
output,
139+
]);
140+
}
141+
128142
/** @type {string | undefined} */
129143
let copyrightHeader;
130144
function getCopyrightHeader() {
@@ -267,6 +281,7 @@ const esbuildServices = esbuildTask("./src/typescript/typescript.ts", "./built/l
267281
const writeServicesCJSShim = () => writeCJSReexport("./built/local/typescript/typescript.js", "./built/local/typescript.js");
268282
const buildServicesProject = () => buildProject("src/typescript");
269283

284+
// TODO(jakebailey): rename this; no longer "services".
270285
const buildServices = () => {
271286
if (cmdLineOptions.bundle) return esbuildServices.build();
272287
writeServicesCJSShim();
@@ -296,6 +311,9 @@ task("watch-services").flags = {
296311
" --built": "Compile using the built version of the compiler."
297312
};
298313

314+
const dtsServices = () => runDtsBundler("./built/local/typescript/typescript.d.ts", "./built/local/typescript.d.ts");
315+
task("dts-services", series(preBuild, buildServicesProject, dtsServices));
316+
task("dts-services").description = "Builds typescript.d.ts";
299317

300318
const esbuildServer = esbuildTask("./src/tsserver/server.ts", "./built/local/tsserver.js", /* exportIsTsObject */ true);
301319
const writeServerCJSShim = () => writeCJSReexport("./built/local/tsserver/server.js", "./built/local/tsserver.js");
@@ -347,10 +365,11 @@ task("watch-min").flags = {
347365
const esbuildLssl = esbuildTask("./src/tsserverlibrary/tsserverlibrary.ts", "./built/local/tsserverlibrary.js", /* exportIsTsObject */ true);
348366
const writeLsslCJSShim = () => writeCJSReexport("./built/local/tsserverlibrary/tsserverlibrary.js", "./built/local/tsserverlibrary.js");
349367

368+
const buildLsslProject = () => buildProject("src/tsserverlibrary");
350369
const buildLssl = () => {
351370
if (cmdLineOptions.bundle) return esbuildLssl.build();
352371
writeLsslCJSShim();
353-
return buildProject("src/tsserverlibrary");
372+
return buildLsslProject();
354373
};
355374
task("lssl", series(preBuild, buildLssl));
356375
task("lssl").description = "Builds language service server library";
@@ -374,6 +393,14 @@ task("watch-lssl").flags = {
374393
" --built": "Compile using the built version of the compiler."
375394
};
376395

396+
const dtsLssl = () => runDtsBundler("./built/local/tsserverlibrary/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.d.ts");
397+
task("dts-lssl", series(preBuild, buildLsslProject, dtsLssl));
398+
task("dts-lssl").description = "Builds tsserverlibrary.d.ts";
399+
400+
// TODO(jakebailey): this is probably not efficient, but, gulp.
401+
const dts = series(preBuild, parallel(buildServicesProject, buildLsslProject), parallel(dtsServices, dtsLssl));
402+
task("dts", dts);
403+
377404
const testRunner = "./built/local/run.js";
378405
const esbuildTests = esbuildTask("./src/testRunner/_namespaces/Harness.ts", testRunner);
379406
const writeTestsCJSShim = () => writeCJSReexport("./built/local/testRunner/runner.js", testRunner);
@@ -478,7 +505,7 @@ const buildOtherOutputs = parallel(buildCancellationToken, buildTypingsInstaller
478505
task("other-outputs", series(preBuild, buildOtherOutputs));
479506
task("other-outputs").description = "Builds miscelaneous scripts and documents distributed with the LKG";
480507

481-
task("local", series(preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs)));
508+
task("local", series(preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs, dts)));
482509
task("local").description = "Builds the full compiler and services";
483510
task("local").flags = {
484511
" --built": "Compile using the built version of the compiler."
@@ -494,7 +521,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
494521
preTest.displayName = "preTest";
495522

496523
const runTests = () => runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
497-
task("runtests", series(preBuild, preTest, runTests));
524+
task("runtests", series(preBuild, preTest, dts, runTests));
498525
task("runtests").description = "Runs the tests using the built run.js file.";
499526
task("runtests").flags = {
500527
"-t --tests=<regex>": "Pattern for tests to run.",
@@ -513,7 +540,7 @@ task("runtests").flags = {
513540
};
514541

515542
const runTestsParallel = () => runConsoleTests(testRunner, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
516-
task("runtests-parallel", series(preBuild, preTest, runTestsParallel));
543+
task("runtests-parallel", series(preBuild, preTest, dts, runTestsParallel));
517544
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
518545
task("runtests-parallel").flags = {
519546
" --light": "Run tests in light mode (fewer verifications, but tests run faster).",
@@ -599,8 +626,7 @@ const produceLKG = async () => {
599626
}
600627
};
601628

602-
// TODO(jakebailey): dependencies on dts
603-
task("LKG", series(lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs), produceLKG));
629+
task("LKG", series(lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs, dts), produceLKG));
604630
task("LKG").description = "Makes a new LKG out of the built js files";
605631
task("LKG").flags = {
606632
" --built": "Compile using the built version of the compiler.",

scripts/build/options.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const parsed = minimist(process.argv.slice(2), {
3939
dirty: false,
4040
built: false,
4141
ci,
42-
bundle: true
42+
bundle: true,
4343
}
4444
});
4545

0 commit comments

Comments
 (0)