@@ -19,7 +19,7 @@ const cmdLineOptions = require("./scripts/build/options");
19
19
const copyright = "CopyrightNotice.txt" ;
20
20
const cleanTasks = [ ] ;
21
21
22
- const testRunner = "./built/local/testRunner/runner .js" ;
22
+ const testRunner = "./built/local/testRunner.js" ;
23
23
24
24
const buildScripts = ( ) => buildProject ( "scripts" ) ;
25
25
task ( "scripts" , buildScripts ) ;
@@ -94,9 +94,44 @@ const localize = async () => {
94
94
}
95
95
} ;
96
96
97
- const buildAll = ( ) => buildProject ( "src" ) ;
97
+ /**
98
+ * @param {string } entrypoint
99
+ * @param {string } outfile
100
+ */
101
+ async function esbuild ( entrypoint , outfile ) {
102
+ await exec ( "node_modules/esbuild/bin/esbuild" , [
103
+ entrypoint ,
104
+ "--bundle" ,
105
+ `--outfile=${ outfile } ` ,
106
+ "--platform=node" ,
107
+ "--target=node12" ,
108
+ "--sourcemap" ,
109
+ "--external:./node_modules/*" ,
110
+ "--conditions=require" ,
111
+ ] ) ;
112
+ }
113
+
114
+ const preBundle = parallel ( generateLibs , series ( buildScripts , localize , generateDiagnostics ) ) ;
115
+
116
+ const bundleTsc = ( ) => esbuild ( "./src/tsc/tsc.ts" , "./built/local/tsc.js" ) ;
117
+ const bundleTypescript = ( ) => esbuild ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" ) ;
118
+ const bundleServer = ( ) => esbuild ( "./src/tsserver/server.ts" , "./built/local/tsserver.js" ) ;
119
+ const bundleServerLibrary = ( ) => esbuild ( "./src/tsserverlibrary/tsserverlibrary.ts" , "./built/local/tsserverlibrary.js" ) ;
120
+ const bundleTests = ( ) => esbuild ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
121
+
122
+
123
+ const bundleAll = series ( [
124
+ bundleTsc ,
125
+ bundleTypescript ,
126
+ bundleServer ,
127
+ bundleServerLibrary ,
128
+ bundleTests ,
129
+ ] ) ;
130
+ task ( "bundle" , series ( preBundle , bundleAll ) ) ;
131
+
98
132
99
- task ( "moduleBuild" , parallel ( generateLibs , series ( buildScripts , localize , buildAll ) ) ) ;
133
+ const buildSrc = ( ) => buildProject ( "src" ) ;
134
+ task ( "buildSrc" , series ( preBundle , bundleAll , buildSrc ) ) ;
100
135
101
136
const apiExtractor = async ( ) => {
102
137
async function runApiExtractor ( configPath ) {
@@ -114,17 +149,17 @@ const apiExtractor = async () => {
114
149
await runApiExtractor ( "./src/tsserverlibrary/api-extractor.json" ) ;
115
150
} ;
116
151
117
- task ( "api-extractor" , series ( task ( "moduleBuild" ) , apiExtractor ) ) ;
152
+ task ( "api-extractor" , series ( buildSrc , apiExtractor ) ) ;
118
153
119
154
const buildDebugTools = ( ) => buildProject ( "src/debug" ) ;
120
155
const cleanDebugTools = ( ) => cleanProject ( "src/debug" ) ;
121
156
cleanTasks . push ( cleanDebugTools ) ;
122
157
123
158
// Pre-build steps when targeting the LKG compiler
124
- const lkgPreBuild = parallel ( generateLibs , series ( buildScripts , generateDiagnostics , buildDebugTools ) ) ;
159
+ const lkgPreBuild = parallel ( generateLibs , series ( buildScripts , generateDiagnostics /** , buildDebugTools */ ) ) ;
125
160
126
161
const buildTsc = ( ) => buildProject ( "src/tsc" ) ;
127
- task ( "tsc" , series ( lkgPreBuild , buildTsc ) ) ;
162
+ task ( "tsc" , series ( preBundle , bundleTsc ) ) ;
128
163
task ( "tsc" ) . description = "Builds the command-line compiler" ;
129
164
130
165
const cleanTsc = ( ) => cleanProject ( "src/tsc" ) ;
@@ -244,7 +279,7 @@ task("dynamicImportCompat", buildDynamicImportCompat);
244
279
const buildServerMain = ( ) => buildProject ( "src/tsserver" , cmdLineOptions ) ;
245
280
const buildServer = series ( buildDynamicImportCompat , buildServerMain ) ;
246
281
buildServer . displayName = "buildServer" ;
247
- task ( "tsserver" , series ( preBuild , buildServer ) ) ;
282
+ task ( "tsserver" , series ( preBundle , bundleServer ) ) ;
248
283
task ( "tsserver" ) . description = "Builds the language server" ;
249
284
task ( "tsserver" ) . flags = {
250
285
" --built" : "Compile using the built version of the compiler."
@@ -461,7 +496,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
461
496
preTest . displayName = "preTest" ;
462
497
463
498
const runTests = ( ) => runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , /*watchMode*/ false ) ;
464
- task ( "runtests" , series ( /*preBuild, preTest,*/ task ( "moduleBuild" ) , runTests ) ) ; // TODO(jakebailey): fix this for modules
499
+ task ( "runtests" , series ( /*preBuild, preTest,*/ bundleTests , runTests ) ) ; // TODO(jakebailey): fix this for modules
465
500
task ( "runtests" ) . description = "Runs the tests using the built run.js file." ;
466
501
task ( "runtests" ) . flags = {
467
502
"-t --tests=<regex>" : "Pattern for tests to run." ,
@@ -480,7 +515,7 @@ task("runtests").flags = {
480
515
} ;
481
516
482
517
const runTestsParallel = ( ) => runConsoleTests ( testRunner , "min" , /*runInParallel*/ cmdLineOptions . workers > 1 , /*watchMode*/ false ) ;
483
- task ( "runtests-parallel" , series ( /*preBuild, preTest,*/ task ( "moduleBuild" ) , runTestsParallel ) ) ; // TODO(jakebailey): fix this for modules
518
+ task ( "runtests-parallel" , series ( /*preBuild, preTest,*/ bundleTests , runTestsParallel ) ) ; // TODO(jakebailey): fix this for modules
484
519
task ( "runtests-parallel" ) . description = "Runs all the tests in parallel using the built run.js file." ;
485
520
task ( "runtests-parallel" ) . flags = {
486
521
" --light" : "Run tests in light mode (fewer verifications, but tests run faster)." ,
0 commit comments