-
Notifications
You must be signed in to change notification settings - Fork 44
Export ESM module #1518
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
base: main
Are you sure you want to change the base?
Export ESM module #1518
Changes from all commits
bf78289
a08010a
4c768a6
79bf6b8
a172be8
e7ec445
d352523
32fb71c
adedd3c
297d6b8
a9c5490
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "extends": "./tsconfig.base.json", | ||
| "compilerOptions": { | ||
| "module": "commonjs", | ||
| "outDir": "./out/cjs" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "extends": "./tsconfig.base.json", | ||
| "compilerOptions": { | ||
| "module": "esnext", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡
// Compiles fine under "module": "esnext"
import { thing } from './helper';
// Required by real Node ESM at runtime
import { thing } from './helper.js';Today this happens to work because
Recommend
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately that’s not true, typescript only ever creates To switch to Would you prefer that rename step to adding the nested I think I’m tending towards using that tool because of the aforementioned footgun about not being allowed to reuse the same
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not an expert on this, so thanks for pointing this out🙂 My understanding is there are two concerns here. At build time: Switching At consume time: the
Is this what you're thinking too? No preference on which one to pick.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, so I think this context-dependent mode would be confusing, and instead opted for the explict
This looks ideal, so we have build time settled. Regarding consume time, there are two technologies that must be satisfied:
I forgot to address 1. properly at first, but opted for renaming file suffixes, so we don’t have to use extra
|
||
| "outDir": "./out/esm" | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.