luxon: Not working with ESM on Node 10
Hey, any chance to have luxon work with Node ESM modules?
import { DateTime } from 'luxon';
^^^^^^^^
SyntaxError: The requested module 'luxon' does not provide an export named 'DateTime'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:89:21)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 18 (4 by maintainers)
Hi 👋!
Node core, Node Module WG member, and creator of
esm
here. I just wanted to pop in and sayThere is no set time for Node to move from
--experimental-modules
to an unflagged implementation. There is also no guarantee on what the final implementation will look like. While the.mjs
extension will be used to disambiguate. The extension may not be-the-only-way to disambiguate. There are several ongoing discussions in the working group about what ESM support will look like in Node. Many possible outcomes are incompatible with the current WIP implementation.The
esm
loader lets you write ESM today and migrate to whatever the ESM of tomorrow will be. So you can useesm
and ship ES modules that are consumable by CJS and compatible with code coverage, bundlers, APM, unit test, and mocking libraries. As Node’s support story solidifies you can tweak, and migrate gradually over.You can set the main to
index
and provide both anindex.js
andindex.mjs
. Then ESM will pick up the mjs one and the rest of us will use js.@ericmorand definitely: but
main
entry inpackage.json
is not linkingsrc/luxon.js
(source) butbuild/node
(transpiled). Here: https://github.com/moment/luxon/blob/19b6c26063498806266ab8b00bfae4d6754e7569/package.json#L59