Created
September 5, 2023 20:57
-
-
Save doublecompile/c7a9ae3cfc5ca0618c914ad709e8fd9a to your computer and use it in GitHub Desktop.
projen-bundle-esm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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