Home > OS >  How to get esbuild to export a default module vs IIFE's
How to get esbuild to export a default module vs IIFE's

Time:09-11

I want it to export this ts entry

with a export default (so I can dynamically import it in browser) not as shown below:

enter image description here

I ran esbuild like so:

"esbuild": "esbuild src/i18n/en.ts --bundle --outfile=dist/i18n/en.js",

CodePudding user response:

To specify the format of the output, esbuild has the flag --format.

To emit esm you can use --format=esm.

By default, --format=iife is used with the flags you used. See the different options (https://esbuild.github.io/api/#format) for when each option is picked by default.

  • Related