-
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
fix: allow require statement in exports. #10914
Conversation
@lucien-perouze Hi.
Chart.js v4 is an ESM-only package, so you can't |
Why so ? Is there features that would break ? |
@lucien-perouze Today many packages have become ESM-only. It is important to push forward ESM adoption. |
As stated in the docs you need to require the UMD build specifically, that should work fine https://www.chartjs.org/docs/master/getting-started/integration.html#requirejs |
I don't really understand. I think its important to be ESM-first, but why is it important to not support commonjs? I think it would require something like that: https://github.com/chartjs/Chart.js/compare/master...kurkle:Chart.js:node-cjs?expand=1 |
@dangreen Is CommonJS dead / deprecated? I agree with @kurkle, that's a strange decision to actually drop support for it. From who this decision comes from and why? Maybe I'm missing some important points so any links to issues / PR would be appreciated. Chart.js is used for server-side rendering and is integrated in CJS projects so it's indeed a bad decision IMO to make such cases more complex or impossible. Is it also because of that change that we need to "fix" all plugins? Before going further adapting plugins I maintain, I would love to have more understanding about this breaking change. |
I'd be open to revert the seemingly bad decision. |
Hello first contribution on open source project and don't have a clue what's the protocol nor time to read all your docs sorry :/
But here is a really obvious quick fix for a big issue : We cannot require() your library.
As mentioned in this issue that I commented :
#10911
When specifying exports in package.json it overwrites the main attributes.
So currently there is no rule for "requiring" the module.
I simply added a default rule to package.json instead of the import one and it works like a charm.
Thank you for your work, best regards,
Lucien Perouze