-
Notifications
You must be signed in to change notification settings - Fork 2k
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 imports of the data #16232
Conversation
This pull request has merge conflicts that must be resolved before we can merge this. |
1 similar comment
This pull request has merge conflicts that must be resolved before we can merge this. |
This pull request has merge conflicts that must be resolved before we can merge this. |
954840d
to
5681ffa
Compare
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.
LGTM, just some bike-shedding
Co-authored-by: Claas Augner <github@caugner.de>
This PR fixes #15916 and allows ESM users to directly import BCD by performing two things:
index.js
to import the data (NodeJS has always been able torequire()
JSON) and exportdata.json
by defaultimport bcd from "@mdn/browser-compat-data/NodeWrapper";
I tested to make sure this approach works using
require()
in NodeJS v18, v16, v14, v12, and even v4; and usingimport
in NodeJS v18, v16, v14, and v12, all successfully importing BCD.This is marked as a
semver-major-bump
becauseexports
is defined which may break existing setups (i.e. if users are already trying to importdata.json
directly).This closes #15775, which also offers ESM import capability, but at the cost of double the bundle size.