Skip to content
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

improvement behavior of files field in package.json #3166

Closed
wants to merge 1 commit into from

Conversation

pastak
Copy link

@pastak pastak commented Apr 17, 2017

Summary

This pr make improve behavior of files in package.json.

According to npm docs, files field's priority is higher than some ignoring (ex: .npmignore, .gitignore) and foo.js will be treated as both foo.js and foo.js/**.

On example project like below

.
├── README.md
├── dist
│   ├── command.js
│   ├── index.js
│   └── libs
│       └── util.js
├── package.json
├── .gitignore
├── node_modules
│   └── ....
├── src
│   ├── command.js
│   ├── index.js
│   └── libs
│       └── util.js
└── yarn.lock

and .gitignore is

dist

with package.json has {"files": ["dist"]}

Result of npm pack is

$ npm pack
example-0.1.0.tgz
$ tar -tzf example-0.1.0.tgz
package/package.json
package/README.md
package/dist/command.js
package/dist/index.js
package/dist/libs/util.js

But yarn pack is

$ yarn pack
yarn pack v0.23.2
success Wrote tarball to "/Users/pastak/works/example/example-v0.1.0.tgz".
$ tar -tzf example-v0.1.0.tgz
package
package/LICENSE
package/README.md
package/dist
package/package.json

Because of that, yarn publish will publish package with empty dist directory.

Test plan

$ cd /PATH/TO/THIS_YARN_REPO/
$ yarn build
$ cd /PATH/TO/EXMPLE_PACKAGE_DIR
$ /PATH/TO/THIS_YARN_REPO/bin/yarn pack
yarn pack v0.23.2
success Wrote tarball to "/Users/pastak/works/example/example-v0.1.0.tgz".
$ tar -tzf example-v0.1.0.tgz
package
package/LICENSE
package/README.md
package/dist/command.js
package/dist/index.js
package/dist/libs/util.js
package/package.json

@pastak pastak force-pushed the improve-files-field branch 4 times, most recently from 778e9e7 to 33ffbbd Compare April 18, 2017 03:14
@bestander
Copy link
Member

Looks like fixed in #3175

@bestander bestander closed this Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants