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

Add .npmignore #468

Closed
SimonSchick opened this issue Jun 7, 2018 · 6 comments
Closed

Add .npmignore #468

SimonSchick opened this issue Jun 7, 2018 · 6 comments

Comments

@SimonSchick
Copy link

SimonSchick commented Jun 7, 2018

I noticed you are shipping a large amount of files that are most likely not used by any consumers:

Misc:

node_modules/stripe/.eslintrc.js
node_modules/stripe/.travis.yml
node_modules/stripe/CHANGELOG.md
node_modules/stripe/.github/
node_modules/stripe/.github/ISSUE_TEMPLATE.md

Examples:

node_modules/stripe/examples/
node_modules/stripe/examples/webhook-signing/
node_modules/stripe/examples/webhook-signing/.eslintrc.js
node_modules/stripe/examples/webhook-signing/express.js
node_modules/stripe/examples/webhook-signing/package.json

Tests: 
node_modules/stripe/test/
node_modules/stripe/test/.eslintrc.js
node_modules/stripe/test/Error.spec.js
node_modules/stripe/test/StripeResource.spec.js
node_modules/stripe/test/Webhook.spec.js
node_modules/stripe/test/flows.spec.js
node_modules/stripe/test/mocha.opts
node_modules/stripe/test/stripe.spec.js
node_modules/stripe/test/testUtils.js
node_modules/stripe/test/utils.spec.js
node_modules/stripe/test/resources/
node_modules/stripe/test/resources/Account.spec.js
node_modules/stripe/test/resources/ApplePayDomains.spec.js
node_modules/stripe/test/resources/ApplicationFeeRefunds.spec.js
node_modules/stripe/test/resources/ApplicationFees.spec.js
node_modules/stripe/test/resources/Balance.spec.js
node_modules/stripe/test/resources/BitcoinReceivers.spec.js
node_modules/stripe/test/resources/ChargeRefunds.spec.js
node_modules/stripe/test/resources/Charges.spec.js
node_modules/stripe/test/resources/CountrySpecs.spec.js
node_modules/stripe/test/resources/Coupons.spec.js
node_modules/stripe/test/resources/CustomerCards.spec.js
node_modules/stripe/test/resources/CustomerSubscriptions.spec.js
node_modules/stripe/test/resources/Customers.spec.js
node_modules/stripe/test/resources/Disputes.spec.js
node_modules/stripe/test/resources/EphemeralKeys.spec.js
node_modules/stripe/test/resources/Events.spec.js
node_modules/stripe/test/resources/ExchangeRates.spec.js
node_modules/stripe/test/resources/FileUploads.spec.js
node_modules/stripe/test/resources/InvoiceItems.spec.js
node_modules/stripe/test/resources/Invoices.spec.js
node_modules/stripe/test/resources/IssuerFraudRecords.spec.js
node_modules/stripe/test/resources/LoginLinks.spec.js
node_modules/stripe/test/resources/OrderReturns.spec.js
node_modules/stripe/test/resources/Orders.spec.js
node_modules/stripe/test/resources/Payouts.spec.js
node_modules/stripe/test/resources/Plans.spec.js
node_modules/stripe/test/resources/Products.spec.js
node_modules/stripe/test/resources/RecipientCards.spec.js
node_modules/stripe/test/resources/Recipients.spec.js
node_modules/stripe/test/resources/Refunds.spec.js
node_modules/stripe/test/resources/SKUs.spec.js
node_modules/stripe/test/resources/Sources.spec.js
node_modules/stripe/test/resources/SubscriptionItems.spec.js
node_modules/stripe/test/resources/Subscriptions.spec.js
node_modules/stripe/test/resources/ThreeDSecure.spec.js
node_modules/stripe/test/resources/Tokens.spec.js
node_modules/stripe/test/resources/Topups.spec.js
node_modules/stripe/test/resources/TransferReversals.spec.js
node_modules/stripe/test/resources/Transfers.spec.js
node_modules/stripe/test/resources/UsageRecords.spec.js
node_modules/stripe/test/resources/data/
node_modules/stripe/test/resources/data/minimal.pdf

Adding these to the npmignore should significantly reduce the package size!

@SimonSchick SimonSchick changed the title Add npmignore Add .npmignore Jun 7, 2018
@brandur-stripe
Copy link
Contributor

Yeah, this probably makes sense. I'll try to write one as a whitelist so that we can keep a fairly minimal set of files even as we add new ones.

@SimonSchick
Copy link
Author

If you write it as a whitelist you can either use an invert glob, with the first line being /* and all subsequent ones starting with ! OR you can use https://docs.npmjs.com/files/package.json#files

@brandur-stripe
Copy link
Contributor

Excellent. Thanks!

@SimonSchick
Copy link
Author

Please note that npm automatically adds essential files such as LICENSE, README and package.json, there is no need to include these files manually.
You can verify the packaged version using npm pack which generates a tgz file with all the contents that would be published to npm.

@brandur-stripe
Copy link
Contributor

You can verify the packaged version using npm pack which generates a tgz file with all the contents that would be published to npm.

Nice! Just what I was looking for.

Please note that npm automatically adds essential files such as LICENSE, README and package.json, there is no need to include these files manually.

Thanks for the info. I think I'm still going to whitelist them anyway just to make it obvious to anyone reading the .npmignore that they'll be in the final package.

brandur-stripe pushed a commit that referenced this issue Jun 7, 2018
Adds an `.npmignore` file to the project so that the final package sent
to NPM is lighter. Tests, examples, and other resources are stripped out
(it's easy to link back to this repository to refer to these if needed).

I've written this is in an "inverted" style so that only by default
everything is blacklisted, and we add back in the files and folders that
we know we'll want.

I verified that this does the right thing by using `npm pack`. Before
the addition of `.npmignore`:

``` sh
$ npm pack && tar -zxf stripe*.tgz && ls -R package/
stripe-6.1.0.tgz
CHANGELOG.md    README.md       examples/       package.json
LICENSE         VERSION         lib/            test/

package//examples:
webhook-signing/

package//examples/webhook-signing:
express.js      package.json

package//lib:
Error.js                        StripeMethod.js                 resources/
MultipartDataGenerator.js       StripeResource.js               stripe.js
StripeMethod.basic.js           Webhooks.js                     utils.js

package//lib/resources:
Accounts.js                     EphemeralKeys.js                Recipients.js
ApplePayDomains.js              Events.js                       Refunds.js
ApplicationFeeRefunds.js        ExchangeRates.js                SKUs.js
ApplicationFees.js              FileUploads.js                  Sources.js
Balance.js                      InvoiceItems.js                 SubscriptionItems.js
BitcoinReceivers.js             Invoices.js                     Subscriptions.js
ChargeRefunds.js                IssuerFraudRecords.js           ThreeDSecure.js
Charges.js                      LoginLinks.js                   Tokens.js
CountrySpecs.js                 OrderReturns.js                 Topups.js
Coupons.js                      Orders.js                       TransferReversals.js
CustomerCards.js                Payouts.js                      Transfers.js
CustomerSubscriptions.js        Plans.js                        UsageRecords.js
Customers.js                    Products.js
Disputes.js                     RecipientCards.js

package//test:
Error.spec.js           flows.spec.js           stripe.spec.js
StripeResource.spec.js  mocha.opts              testUtils.js
Webhook.spec.js         resources/              utils.spec.js

package//test/resources:
Account.spec.js                 EphemeralKeys.spec.js           Recipients.spec.js
ApplePayDomains.spec.js         Events.spec.js                  Refunds.spec.js
ApplicationFeeRefunds.spec.js   ExchangeRates.spec.js           SKUs.spec.js
ApplicationFees.spec.js         FileUploads.spec.js             Sources.spec.js
Balance.spec.js                 InvoiceItems.spec.js            SubscriptionItems.spec.js
BitcoinReceivers.spec.js        Invoices.spec.js                Subscriptions.spec.js
ChargeRefunds.spec.js           IssuerFraudRecords.spec.js      ThreeDSecure.spec.js
Charges.spec.js                 LoginLinks.spec.js              Tokens.spec.js
CountrySpecs.spec.js            OrderReturns.spec.js            Topups.spec.js
Coupons.spec.js                 Orders.spec.js                  TransferReversals.spec.js
CustomerCards.spec.js           Payouts.spec.js                 Transfers.spec.js
CustomerSubscriptions.spec.js   Plans.spec.js                   UsageRecords.spec.js
Customers.spec.js               Products.spec.js                data/
Disputes.spec.js                RecipientCards.spec.js

package//test/resources/data:
minimal.pdf
```

And after:

``` sh
$ npm pack && tar -zxf stripe*.tgz && ls -R package/
stripe-6.1.0.tgz
CHANGELOG.md    LICENSE         README.md       VERSION         lib/            package.json

package//lib:
Error.js                        StripeMethod.js                 resources/
MultipartDataGenerator.js       StripeResource.js               stripe.js
StripeMethod.basic.js           Webhooks.js                     utils.js

package//lib/resources:
Accounts.js                     EphemeralKeys.js                Recipients.js
ApplePayDomains.js              Events.js                       Refunds.js
ApplicationFeeRefunds.js        ExchangeRates.js                SKUs.js
ApplicationFees.js              FileUploads.js                  Sources.js
Balance.js                      InvoiceItems.js                 SubscriptionItems.js
BitcoinReceivers.js             Invoices.js                     Subscriptions.js
ChargeRefunds.js                IssuerFraudRecords.js           ThreeDSecure.js
Charges.js                      LoginLinks.js                   Tokens.js
CountrySpecs.js                 OrderReturns.js                 Topups.js
Coupons.js                      Orders.js                       TransferReversals.js
CustomerCards.js                Payouts.js                      Transfers.js
CustomerSubscriptions.js        Plans.js                        UsageRecords.js
Customers.js                    Products.js
Disputes.js                     RecipientCards.js
```

Fixes #468.
@brandur-stripe
Copy link
Contributor

Released as 6.1.1.

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

No branches or pull requests

2 participants