async function bundleSpecs(options) {
  const incremental = options.incremental ?? true;
  const write = options.write ?? true;

  const buildOptions = {
    bundle: true,
    format: "esm",
    outdir: options.outdir,
    sourcemap: true,
    target: "es2020",
    write: write,
  };

  let build = esbuild.build;
  if (incremental) {
    build = esbuild.context;
  }

  // When bundling specs for a workspace, the spec-main.js and karma-main.js
  // are bundled separately since they use a different outbase than the workspace's SpecList.js.
  await build({
    ...buildOptions,
    entryPoints: ["Specs/spec-main.js", "Specs/karma-main.js"],
  });

  return build({
    ...buildOptions,
    entryPoints: [options.specListFile],
    outbase: options.outbase,
  });
}
Bundles spec files for testing in the browser.

@param {object} options
@param {boolean} [options.incremental=false] True if builds should be generated incrementally.
@param {string} options.outbase The base path the output files are relative to.
@param {string} options.outdir The directory to place the output in.
@param {string} options.specListFile The path to the SpecList.js file
@param {boolean} [options.write=true] True if bundles generated are written to files instead of in-memory buffers.
@returns {object} The bundle generated from Specs.