-
Notifications
You must be signed in to change notification settings - Fork 44
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
Make npm package ES6 module friendly #246
Comments
Note ongoing proposal in ECMAScript to enable import of JSON modules |
Closing. Import attributes are still under development and may still change, but the feature is already supported in Node.js and Deno. The following works out of the box with Node.js v20.10.0 or above: import specs from 'web-specs' with { type: 'json' }; Older versions of Node.js rather use import specs from 'web-specs' assert { type: 'json' }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The NPM package only contains the
index.json
file. That file can easily be retrieved withrequire
:However, I believe that there is no easy to achieve the same thing in a project that uses
import
statement (in other words, when the project enables ECMASCript modules). The following does not work:For that to work, the entry point of the package needs to be a JS file, not a JSON one.
The text was updated successfully, but these errors were encountered: