Skip to content

Commit 9e2d765

Browse files
committed
Hack something together to test esbuild
1 parent 2ceb74c commit 9e2d765

File tree

9 files changed

+618
-25
lines changed

9 files changed

+618
-25
lines changed

Gulpfile.js

+44-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const cmdLineOptions = require("./scripts/build/options");
1919
const copyright = "CopyrightNotice.txt";
2020
const cleanTasks = [];
2121

22-
const testRunner = "./built/local/testRunner/runner.js";
22+
const testRunner = "./built/local/testRunner.js";
2323

2424
const buildScripts = () => buildProject("scripts");
2525
task("scripts", buildScripts);
@@ -94,9 +94,44 @@ const localize = async () => {
9494
}
9595
};
9696

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+
98132

99-
task("moduleBuild", parallel(generateLibs, series(buildScripts, localize, buildAll)));
133+
const buildSrc = () => buildProject("src");
134+
task("buildSrc", series(preBundle, bundleAll, buildSrc));
100135

101136
const apiExtractor = async () => {
102137
async function runApiExtractor(configPath) {
@@ -114,17 +149,17 @@ const apiExtractor = async () => {
114149
await runApiExtractor("./src/tsserverlibrary/api-extractor.json");
115150
};
116151

117-
task("api-extractor", series(task("moduleBuild"), apiExtractor));
152+
task("api-extractor", series(buildSrc, apiExtractor));
118153

119154
const buildDebugTools = () => buildProject("src/debug");
120155
const cleanDebugTools = () => cleanProject("src/debug");
121156
cleanTasks.push(cleanDebugTools);
122157

123158
// 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 */));
125160

126161
const buildTsc = () => buildProject("src/tsc");
127-
task("tsc", series(lkgPreBuild, buildTsc));
162+
task("tsc", series(preBundle, bundleTsc));
128163
task("tsc").description = "Builds the command-line compiler";
129164

130165
const cleanTsc = () => cleanProject("src/tsc");
@@ -244,7 +279,7 @@ task("dynamicImportCompat", buildDynamicImportCompat);
244279
const buildServerMain = () => buildProject("src/tsserver", cmdLineOptions);
245280
const buildServer = series(buildDynamicImportCompat, buildServerMain);
246281
buildServer.displayName = "buildServer";
247-
task("tsserver", series(preBuild, buildServer));
282+
task("tsserver", series(preBundle, bundleServer));
248283
task("tsserver").description = "Builds the language server";
249284
task("tsserver").flags = {
250285
" --built": "Compile using the built version of the compiler."
@@ -461,7 +496,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
461496
preTest.displayName = "preTest";
462497

463498
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
465500
task("runtests").description = "Runs the tests using the built run.js file.";
466501
task("runtests").flags = {
467502
"-t --tests=<regex>": "Pattern for tests to run.",
@@ -480,7 +515,7 @@ task("runtests").flags = {
480515
};
481516

482517
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
484519
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
485520
task("runtests-parallel").flags = {
486521
" --light": "Run tests in light mode (fewer verifications, but tests run faster).",

0 commit comments

Comments
 (0)