-
Notifications
You must be signed in to change notification settings - Fork 734
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
Not working with ESM on Node 10 #252
Comments
I've never used ESM, so I am not sure. Pretty hard to imagine why it thinks that. E.g. see the end of http://moment.github.io/luxon/node/luxon.js I'd take a fix to the toolchain that helped here, but I have no idea how to help myself |
Aren't ESM modules an experimental feature of node 10? |
Yes, and soon moving to harmony flag. Let's be prepared! :) NB: I've been using them for weeks by now and they work seamlessly (only pain in the ass is you can't import .json as you used to require .json ...). |
That's actually a very good thing if you ask me. JSON files are not modules in any way and this was leading to a lot of potential problems when you were requiring modules in the blind. Anyway, yes, ESM is just around the corner. Why is it not working? Isn't doing this enough to support ESM?
Line 11 in 19b6c26
|
@ericmorand definitely: but Line 59 in 19b6c26
|
Oh yes, good one. |
Yes, we link to the built one, where the relevant code is: exports.DateTime = DateTime;
exports.Duration = Duration;
exports.Interval = Interval;
exports.Info = Info;
exports.Zone = Zone;
exports.FixedOffsetZone = FixedOffsetZone;
exports.IANAZone = IANAZone;
exports.LocalZone = LocalZone;
exports.Settings = Settings; |
Maybe .mjs extension is required? |
Well, even if that's true, I can't just export that or it will break versions of Node that don't support it. What we need is something like:
No idea if 2 is possible, but I'm unclear on what the path forward is supposed to be otherwise. How are libraries expected to provide these modules? |
You can set the main to |
You might also consider using https://github.com/standard-things/esm to remove the need for duplication and some pre-publish build steps. |
Ah, that's the kind of answer I was looking for. I'll get to this, but if someone wants to give it a shot, that would be great |
@pho3nixf1re is that a default behaviour when esm is enabled? |
There is nothing formal about it. If you use native node imports then |
Hi 👋! Node core, Node Module WG member, and creator of
There is no set time for Node to move from The |
FWIW, you can set |
Partial fix for not being able to do e.g. `import {DateTime} from "luxon"`. This *still* won't work, but `import {DateTime} from "my/own/luxon/src/luxon.js" will. See moment#252
I'm on a later version of node, but I found that I had really strange intermittent issues with luxon,
or
or (this time DateTime is fine, but Info is not)
I solved it in one file with: import luxon from 'luxon';
const { DateTime, Settings } = luxon; and yet in another file in the same project I have this, with no issues:
Versions are:
relevant |
Any movement on this? I am getting the same errors. I tried @AGBrown suggestion but it didnt work for me. @pho3nixf1re's suggestion seems like the simplest fix for luxon. Or alternatively you cold rename all the /src .js files to .mjs |
Hey, any chance to have luxon work with Node ESM modules?
The text was updated successfully, but these errors were encountered: