-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add support as ECMAScript module (e.g add type: module
to package.json
; .js
file extension to relative imports)
#1265
Comments
We had tried adding |
Thanks for the info @Pauan. Hopefully this is something that can be enabled soon. Fwiw, patching in Noting in case anyone else wants to test amCharts with ESM & Jest:
and that's it - working on the latest versions of Jest and amCharts at the time of writing. |
Thank you for this flow ! @davidjb 💯 |
Question
"type": "module"
Could
"type": "module"
be added to amCharts'package.json
? As I understand it, the package is entirely ES modules so adding this flag tells Node that this package's.js
files are all ESM (ref: https://nodejs.org/api/packages.html#type).This would assist with importing amCharts directly in supported environments, such as testing with Jest. I know there's a setup process (#1223 (comment)) for configuring Jest/Babel transformations, but with the addition of
"type": "module"
, transformations aren't required and amCharts5 can be used directly (I manually edited amCharts'package.json
to test). This is provided Node is run with Jest/ESM support ala https://jestjs.io/docs/ecmascript-modules.Example test running successfully with manual modification of
package.json
: https://gist.github.com/davidjb/6c6492848dc924a9551b1e2d97f8a847File extensions in imports
Full direct support as an ES module in Node would require the addition of file extensions to relative imports in the codebase (as per https://nodejs.org/api/esm.html#mandatory-file-extensions) - to my knowledge, this shouldn't affect any build tools or be a breaking change - but is a large change regardless.
Fwiw, Jest's resolver doesn't have an issue with missing file extensions and only needs
"type": "module"
to work as it is today.Environment (if applicable)
Additional context
The text was updated successfully, but these errors were encountered: