-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Build: Improve setup of package.json files #15879
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
Conversation
hypest
left a comment
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.
Looks good from native mobile's point of view 👍 .
| }, | ||
| "files": [ | ||
| "arrays.js", | ||
| "index.js", |
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.
Is this module totally broken from NPM ? This seems like it would be necessary for it to work 😯
Sometimes I wonder if it's worthwhile to use a files whitelist, vs. the (apparently real) risk of neglecting to include files.
Edit:
At least on unpkg, it seems to be intact? https://unpkg.com/@wordpress/is-shallow-equal@1.3.0/index.js
How does that work?
There are some always-included files, but index.js is not one of them:
https://docs.npmjs.com/files/package.json#files
And I don't think we'd want to cherry-pick individual "always included"; either consistently assume the inherited always-included, or consistently list them all explicitly.
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.
There are some always-included
files, butindex.jsis not one of them:
It is included, not because of the name, but because it's the file in the “main” field.
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.
Certain files are always included, regardless of settings:
- package.json
- README
- CHANGES / CHANGELOG / HISTORY
- LICENSE / LICENCE
- NOTICE
- The file in the “main” field
I can remove all files listed in main. I assumed it can be confusing for those who don't know how it exactly works and it's better to whitelist all code related files. I'd be also fine with using lib folder for those packages which use CommonJS syntax.
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.
There are some always-included
files, butindex.jsis not one of them:
https://docs.npmjs.com/files/package.json#filesIt is included, not because of the name, but because it's the file in the “main” field.
Ah! I searched the page for the literal term "index", and admittedly did not read the list in detail this time around 😅 That makes sense now.
I'm on the fence about whether we include it, or allow it to be implied from main, or include it and avoid main, or include all implicit files. I agree it can be confusing for those unfamiliar with the default files (me, apparently 😆). Since generally I'm expecting these to be "the files required for runtime execution", seems reasonable to expect index.js here.
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.
Yes, I'm fine with whatever people prefer here. I can keep it as is, remove main from files. Both work for me.
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.
I merged this PR, we can revisit this later :)
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.
I merged this PR, we can revisit this later :)
Yeah, I'm not really sure what the best option is, since they all seem to have some downside. It's fine enough to move forward with.
f56ef5e to
8b48a13
Compare
Description
An alternative to #15841 where I tried:
It turned out that we can't use implementation based on new
typefield:This PR use
modulefield to achieve the same goal.In addition, it does some chores:
files,mainandreact-nativefields where applicablereact-nativeandtypefields if defined inpackage.jsonfileHow has this been tested?
npm run lint&npm run buildI also confirmed that only packages which use Babel are listed in those which are built with
npm run build:packages.