-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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 ESM files to be used in Node.js #10479
Conversation
We could include the file twice - once with |
Would be safer to have the files with both names. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The *.mjs and *.mts need to be added to filed section of the main package.json to be included in the releases.
thanks. good catch! I've just updated that |
@benmccann @LeeLenaleee @kurkle @etimberg Hi. How about just add |
@dangreen that sounds like better option, avoiding duplicate files. Can be done for v4. |
It's definitely the better long-term option. But I was assuming v4 isn't on the horizon. This change can be done in a backwards-compatible manner in the meantime until v4 is started. Are there any plans for v4? |
Yes, v4 is planned after 3.9 is out. |
I'd be ok going with this in 3.9 and going for type=module in v4. |
Hello! I don't think this PR works as intended. Issue 1 The tests were done with
Issue 2
The solution so node can consume ESM is to use the exports field, which you discussed earlier. However, the risk is that it will break more things than it will solve. I'm not sure about the exact syntax, but something like:
I would also like to say a HUGE thanks to the awesome work put into this project. Big thanks! ❤️ [1] https://stackoverflow.com/a/42817320/1378453 |
Thanks @mlandalv for the details. I looked at issue 1 on Node and could not find a way to have commonjs and esm in the same package without The 2nd issue needs to be fixed. |
This is a bug fix to better allow using Chart.js in Node.js. Node.js will only load ESM files if they have an
.mjs
extension or the package has"type": "module"
. The latter would be a breaking change. However, this change should be invisible to users (unless they are doingimport Chart from 'Chart.js/dist/chart.esm.js'
, which is undocumented and I would argue unsupported).