Skip to content

Commit

Permalink
Hack something together to test esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Sep 13, 2022
1 parent 2ceb74c commit 9e2d765
Show file tree
Hide file tree
Showing 9 changed files with 618 additions and 25 deletions.
53 changes: 44 additions & 9 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const cmdLineOptions = require("./scripts/build/options");
const copyright = "CopyrightNotice.txt";
const cleanTasks = [];

const testRunner = "./built/local/testRunner/runner.js";
const testRunner = "./built/local/testRunner.js";

const buildScripts = () => buildProject("scripts");
task("scripts", buildScripts);
Expand Down Expand Up @@ -94,9 +94,44 @@ const localize = async () => {
}
};

const buildAll = () => buildProject("src");
/**
* @param {string} entrypoint
* @param {string} outfile
*/
async function esbuild(entrypoint, outfile) {
await exec("node_modules/esbuild/bin/esbuild", [
entrypoint,
"--bundle",
`--outfile=${outfile}`,
"--platform=node",
"--target=node12",
"--sourcemap",
"--external:./node_modules/*",
"--conditions=require",
]);
}

const preBundle = parallel(generateLibs, series(buildScripts, localize, generateDiagnostics));

const bundleTsc = () => esbuild("./src/tsc/tsc.ts", "./built/local/tsc.js");
const bundleTypescript = () => esbuild("./src/typescript/typescript.ts", "./built/local/typescript.js");
const bundleServer = () => esbuild("./src/tsserver/server.ts", "./built/local/tsserver.js");
const bundleServerLibrary = () => esbuild("./src/tsserverlibrary/tsserverlibrary.ts", "./built/local/tsserverlibrary.js");
const bundleTests = () => esbuild("./src/testRunner/_namespaces/Harness.ts", testRunner);


const bundleAll = series([
bundleTsc,
bundleTypescript,
bundleServer,
bundleServerLibrary,
bundleTests,
]);
task("bundle", series(preBundle, bundleAll));


task("moduleBuild", parallel(generateLibs, series(buildScripts, localize, buildAll)));
const buildSrc = () => buildProject("src");
task("buildSrc", series(preBundle, bundleAll, buildSrc));

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

task("api-extractor", series(task("moduleBuild"), apiExtractor));
task("api-extractor", series(buildSrc, apiExtractor));

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

// Pre-build steps when targeting the LKG compiler
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildDebugTools));
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics /** , buildDebugTools */));

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

const cleanTsc = () => cleanProject("src/tsc");
Expand Down Expand Up @@ -244,7 +279,7 @@ task("dynamicImportCompat", buildDynamicImportCompat);
const buildServerMain = () => buildProject("src/tsserver", cmdLineOptions);
const buildServer = series(buildDynamicImportCompat, buildServerMain);
buildServer.displayName = "buildServer";
task("tsserver", series(preBuild, buildServer));
task("tsserver", series(preBundle, bundleServer));
task("tsserver").description = "Builds the language server";
task("tsserver").flags = {
" --built": "Compile using the built version of the compiler."
Expand Down Expand Up @@ -461,7 +496,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
preTest.displayName = "preTest";

const runTests = () => runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
task("runtests", series(/*preBuild, preTest,*/ task("moduleBuild"), runTests)); // TODO(jakebailey): fix this for modules
task("runtests", series(/*preBuild, preTest,*/ bundleTests, runTests)); // TODO(jakebailey): fix this for modules
task("runtests").description = "Runs the tests using the built run.js file.";
task("runtests").flags = {
"-t --tests=<regex>": "Pattern for tests to run.",
Expand All @@ -480,7 +515,7 @@ task("runtests").flags = {
};

const runTestsParallel = () => runConsoleTests(testRunner, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
task("runtests-parallel", series(/*preBuild, preTest,*/ task("moduleBuild"), runTestsParallel)); // TODO(jakebailey): fix this for modules
task("runtests-parallel", series(/*preBuild, preTest,*/ bundleTests, runTestsParallel)); // TODO(jakebailey): fix this for modules
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
task("runtests-parallel").flags = {
" --light": "Run tests in light mode (fewer verifications, but tests run faster).",
Expand Down
Loading

0 comments on commit 9e2d765

Please sign in to comment.