Skip to content

Instantly share code, notes, and snippets.

@doublecompile
Created September 5, 2023 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doublecompile/c7a9ae3cfc5ca0618c914ad709e8fd9a to your computer and use it in GitHub Desktop.
Save doublecompile/c7a9ae3cfc5ca0618c914ad709e8fd9a to your computer and use it in GitHub Desktop.
projen-bundle-esm.ts
// How to use esbuild with Projen to output an ESM library.
const { bundleTask, outfile } = project.bundler.addBundle("./src/handler.mts", {
target: "node18",
platform: "node",
watchTask: false,
});
const [{ exec: bundleCommand = "" }] = bundleTask.steps;
bundleTask.reset(
bundleCommand
.replace("esbuild", "esbuild --format=esm")
.replace(outfile, outfile.replace(".js", ".mjs"))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment