-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 browser and module field support to package.json processing #2598
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
The PR itself looks good - a flag can be added later for CLI usage. @anmonteiro Do you have any idea how prevalent the browser field advanced usage form is? https://github.com/defunctzombie/package-browser-field-spec#replace-specific-files---advanced That's been my largest hangup on this to date. |
Just three example that were present in dependency tree of react, react-dom, leaflet, react-leaflet: |
Interesting. I didn't know about the advanced usage of the browser field. I have no idea how prevalent it is, but my intuition would be to solve that as needed. This PR introduces basic support for it, and we can build on it later. |
@dimvar LGTM. We'll continue to iterate on this in future PRs. |
OK, I'll import and submit the PR internally. |
Closes google#2598 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=164176438
This PR fixes #2433 by introducing a new option,
packageJsonEntryNames
, which allows specifying a list of ordered entries which the compiler should look for when resolving Node modules. The default is the single entry"main"
.When compiling for the web, however, we would pass in a list of
"browser", "main"
which tells the compiler to look for a"browser"
entry before checking the"main"
entry.This also allows people who want to consume packages that instead rely on
es2015:main
oresnext:main
to include those too in the order of precedence they prefer.