Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to customize output extension #281

Closed
egoist opened this issue Jul 21, 2020 · 2 comments
Closed

Allow to customize output extension #281

egoist opened this issue Jul 21, 2020 · 2 comments

Comments

@egoist
Copy link

egoist commented Jul 21, 2020

To have both ES module and CommonJS module co-exist in a Node.js package, we need to use different extensions, https://nodejs.org/api/esm.html#esm_enabling

@evanw
Copy link
Owner

evanw commented Jul 25, 2020

I added a new flag for this: --out-extension:.js=.mjs (as well as JavaScript and Go APIs). It's a mapping instead of a single value because I plan to have more file types in the future such as CSS and HTML, and you may want to customize those output extensions too. This was published in esbuild version 0.6.6.

@tonyxiao
Copy link

Is it possible to transform the file extension in require statement too? Otherwise when I try to transform esm into cjs the require statement still says require('*.js') which would of course fail if the out extension has been changed to *.cjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants