thlorenz / redeyed

Takes JavaScript code, along with a config and returns the original code with tokens wrapped and/or replaced as configured.
MIT License
25 stars 7 forks source link

Add `.npmignore` #21

Closed SimonSchick closed 3 years ago

SimonSchick commented 6 years ago

You are shipping a lot of redundant files to npm:

node_modules/redeyed/.travis.yml

node_modules/redeyed/examples/
node_modules/redeyed/examples/replace-log.js
node_modules/redeyed/examples/browser/
node_modules/redeyed/examples/browser/index.css
node_modules/redeyed/examples/browser/index.html
node_modules/redeyed/examples/browser/index.js
node_modules/redeyed/examples/browser/sample-config.js
node_modules/redeyed/examples/sources/
node_modules/redeyed/examples/sources/log.js
node_modules/redeyed/test/
node_modules/redeyed/test/redeyed-before-after-config.js
node_modules/redeyed/test/redeyed-browser.js
node_modules/redeyed/test/redeyed-comments.js
node_modules/redeyed/test/redeyed-config-with-undefineds.js
node_modules/redeyed/test/redeyed-function-config-extra-params.js
node_modules/redeyed/test/redeyed-function-config-skipping-tokens.js
node_modules/redeyed/test/redeyed-function-config.js
node_modules/redeyed/test/redeyed-incomplete.js
node_modules/redeyed/test/redeyed-keywords.js
node_modules/redeyed/test/redeyed-mixed.js
node_modules/redeyed/test/redeyed-result.js
node_modules/redeyed/test/redeyed-script-level-return.js
node_modules/redeyed/test/redeyed-shebang.js
node_modules/redeyed/test/redeyed-smoke.js
node_modules/redeyed/test/redeyed-string-config.js
node_modules/redeyed/test/redeyed-types.js
node_modules/redeyed/test/redeyed-upcoming.js
thlorenz commented 6 years ago

Please show me that they represent a large percentage of the entire package and we can add an .npmignore to remove them.

If it's not very large I'd opt to keep them around so anyone who installed it can inspect tests+examples locally to understand how redeyed works.

thlorenz commented 6 years ago

i.e. what you could do is run npm pack without the .npmignore and then run it again with the .npmignore and compare the file sizes of the resulting archive.

Please post them here and we'll make a decision.

macklinu commented 6 years ago

Currently:

❯ npm pack
npm notice
npm notice 📦  redeyed@2.1.1
npm notice === Tarball Contents ===
npm notice 872B  package.json
npm notice 105B  .travis.yml
npm notice 2.8kB config-es5.js
npm notice 4.0kB config.js
npm notice 1.1kB LICENSE
npm notice 6.3kB README.md
npm notice 9.0kB redeyed.js
npm notice 307B  examples/browser/index.css
npm notice 1.2kB examples/browser/index.html
npm notice 577B  examples/browser/index.js
npm notice 2.5kB examples/browser/sample-config.js
npm notice 1.9kB examples/replace-log.js
npm notice 258B  examples/sources/log.js
npm notice 1.4kB test/redeyed-before-after-config.js
npm notice 2.0kB test/redeyed-comments.js
npm notice 1.5kB test/redeyed-config-with-undefineds.js
npm notice 1.4kB test/redeyed-function-config-extra-params.js
npm notice 2.4kB test/redeyed-function-config-skipping-tokens.js
npm notice 4.2kB test/redeyed-function-config.js
npm notice 1.0kB test/redeyed-incomplete.js
npm notice 936B  test/redeyed-jsx.js
npm notice 1.8kB test/redeyed-keywords.js
npm notice 1.2kB test/redeyed-mixed.js
npm notice 1.9kB test/redeyed-result.js
npm notice 527B  test/redeyed-script-level-return.js
npm notice 609B  test/redeyed-shebang.js
npm notice 1.5kB test/redeyed-smoke.js
npm notice 4.2kB test/redeyed-string-config.js
npm notice 2.8kB test/redeyed-types.js
npm notice 1.3kB test/redeyed-upcoming.js
npm notice === Tarball Details ===
npm notice name:          redeyed
npm notice version:       2.1.1
npm notice filename:      redeyed-2.1.1.tgz
npm notice package size:  14.4 kB
npm notice unpacked size: 61.6 kB
npm notice shasum:        16b4f45bc27b0e3d7e098d5f7b3e63188d9d9e02
npm notice integrity:     sha512-HEXmNM7UDnGwC[...]62iX0RRFUeTcA==
npm notice total files:   30
npm notice
redeyed-2.1.1.tgz

After the following addition to package.json:

diff --git a/package.json b/package.json
index b902fff..dfce7f4 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,9 @@
   "description": "Takes JavaScript code, along with a config and returns the original code with tokens wrapped as configured.",
   "author": "Thorsten Lorenz <thlorenz@gmx.de> (thlorenz.com)",
   "main": "redeyed.js",
+  "files": [
+    "redeyed.js"
+  ],
   "scripts": {
     "test": "npm run run-test && npm run lint",
     "run-test": "tape test/*.js",
❯ npm pack
npm notice
npm notice 📦  redeyed@2.1.1
npm notice === Tarball Contents ===
npm notice 907B  package.json
npm notice 1.1kB LICENSE
npm notice 6.3kB README.md
npm notice 9.0kB redeyed.js
npm notice === Tarball Details ===
npm notice name:          redeyed
npm notice version:       2.1.1
npm notice filename:      redeyed-2.1.1.tgz
npm notice package size:  6.3 kB
npm notice unpacked size: 17.3 kB
npm notice shasum:        49f51f491dd0e705ccbf765ee2fc0e7df2b53179
npm notice integrity:     sha512-WSRg8qvnC7lBK[...]nlimfKnv/3Xng==
npm notice total files:   4
npm notice
redeyed-2.1.1.tgz

(I used npm@6.1.0 to pack these tarballs.)

thlorenz commented 6 years ago

OK, sounds reasonable .. I'll accept the above patch as a PR if you provide it @macklinu. Thanks for running through the motions here :)

I also like the files field a lot better in this case than .npmignore.

SimonSchick commented 6 years ago

Sorry for not replying, somehow managed to unsubscribe from this issue.

Yea files or .npmignore are both fine (especially for single file packages).