jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.31k stars 356 forks source link

Reduce NPM package size #155

Closed alexeyraspopov closed 4 years ago

alexeyraspopov commented 4 years ago

This pull request includes several small tweaks to package.json that reduces NPM package size and its installation time.

Moved @rollup/plugin-commonjs to devDependencies after I found a lot of warnings like

warning "idb > @rollup/plugin-commonjs@11.0.1" has unmet peer dependency "rollup@^1.20.0".
warning "idb > @rollup/plugin-commonjs > @rollup/pluginutils@3.0.6" has unmet peer dependency "rollup@^1.20.0".

Defined a list of allowed files using package.json#files so that no unnecessary files are being installed. Below you can see the difference

Before (72 files, 298.4 kB) ``` ~/workspace/idb λ npm publish --dry-run npm notice npm notice 📦 idb@5.0.0 npm notice === Tarball Contents === npm notice 776B LICENSE npm notice 154B test/index.html npm notice 2.1kB build/cjs/async-iterators.js npm notice 2.1kB build/esm/async-iterators.js npm notice 3.1kB build/iife/index-min.js npm notice 3.0kB build/cjs/index.js npm notice 2.9kB build/esm/index.js npm notice 1.9kB rollup.config.js npm notice 3.6kB lib/simple-ts.js npm notice 93B with-async-ittr-cjs.js npm notice 3.7kB build/iife/with-async-ittr-min.js npm notice 79B with-async-ittr.js npm notice 7.6kB build/cjs/wrap-idb-value.js npm notice 7.5kB build/esm/wrap-idb-value.js npm notice 52B .prettierrc.json npm notice 373B generic-tsconfig.json npm notice 926B package.json npm notice 101B src/tsconfig.json npm notice 170B test/tsconfig.json npm notice 329B tsconfig.json npm notice 127B build/cjs/async-iterators.d.ts.map npm notice 127B build/esm/async-iterators.d.ts.map npm notice 2.2kB build/cjs/async-iterators.js.map npm notice 2.2kB build/esm/async-iterators.js.map npm notice 127B build/cjs/database-extras.d.ts.map npm notice 127B build/esm/database-extras.d.ts.map npm notice 1.9kB build/cjs/database-extras.js.map npm notice 1.9kB build/esm/database-extras.js.map npm notice 17.2kB build/cjs/entry.d.ts.map npm notice 17.2kB build/esm/entry.d.ts.map npm notice 1.3kB build/cjs/entry.js.map npm notice 1.3kB build/esm/entry.js.map npm notice 149B build/cjs/index.d.ts.map npm notice 149B build/esm/index.d.ts.map npm notice 147B build/cjs/index.js.map npm notice 147B build/esm/index.js.map npm notice 270B build/cjs/util.d.ts.map npm notice 270B build/esm/util.d.ts.map npm notice 235B build/cjs/util.js.map npm notice 235B build/esm/util.js.map npm notice 1.5kB build/cjs/wrap-idb-value.d.ts.map npm notice 1.5kB build/esm/wrap-idb-value.d.ts.map npm notice 5.4kB build/cjs/wrap-idb-value.js.map npm notice 5.4kB build/esm/wrap-idb-value.js.map npm notice 2.7kB changes.md npm notice 14.4kB README.md npm notice 1.2kB lib/size-report.mjs npm notice 56B build/cjs/async-iterators.d.ts npm notice 56B build/esm/async-iterators.d.ts npm notice 2.5kB src/async-iterators.ts npm notice 56B build/cjs/database-extras.d.ts npm notice 56B build/esm/database-extras.d.ts npm notice 1.8kB src/database-extras.ts npm notice 29.4kB build/cjs/entry.d.ts npm notice 29.4kB build/esm/entry.d.ts npm notice 30.3kB src/entry.ts npm notice 88B build/cjs/index.d.ts npm notice 88B build/esm/index.d.ts npm notice 53B src/index.ts npm notice 874B test/index.ts npm notice 8.6kB test/iterate.ts npm notice 55.3kB test/main.ts npm notice 5.2kB test/open.ts npm notice 240B build/cjs/util.d.ts npm notice 240B build/esm/util.d.ts npm notice 236B src/util.ts npm notice 2.1kB test/utils.ts npm notice 40B with-async-ittr-cjs.d.ts npm notice 40B with-async-ittr.d.ts npm notice 1.6kB build/cjs/wrap-idb-value.d.ts npm notice 1.6kB build/esm/wrap-idb-value.d.ts npm notice 8.8kB src/wrap-idb-value.ts npm notice === Tarball Details === npm notice name: idb npm notice version: 5.0.0 npm notice package size: 40.3 kB npm notice unpacked size: 298.4 kB npm notice shasum: 0f43f4b797fde4d5731135fa14a558763be5d693 npm notice integrity: sha512-Vfd/1rI8Qb5T2[...]lHpnXB6YCV18w== npm notice total files: 72 npm notice + idb@5.0.0 ```
After (52 files, 174.9 kB) ``` ~/workspace/idb λ npm publish --dry-run npm notice npm notice 📦 idb@5.0.0 npm notice === Tarball Contents === npm notice 776B LICENSE npm notice 2.1kB build/cjs/async-iterators.js npm notice 2.1kB build/esm/async-iterators.js npm notice 3.1kB build/iife/index-min.js npm notice 3.0kB build/cjs/index.js npm notice 2.9kB build/esm/index.js npm notice 93B with-async-ittr-cjs.js npm notice 3.7kB build/iife/with-async-ittr-min.js npm notice 79B with-async-ittr.js npm notice 7.6kB build/cjs/wrap-idb-value.js npm notice 7.5kB build/esm/wrap-idb-value.js npm notice 973B package.json npm notice 127B build/cjs/async-iterators.d.ts.map npm notice 127B build/esm/async-iterators.d.ts.map npm notice 2.2kB build/cjs/async-iterators.js.map npm notice 2.2kB build/esm/async-iterators.js.map npm notice 127B build/cjs/database-extras.d.ts.map npm notice 127B build/esm/database-extras.d.ts.map npm notice 1.9kB build/cjs/database-extras.js.map npm notice 1.9kB build/esm/database-extras.js.map npm notice 17.2kB build/cjs/entry.d.ts.map npm notice 17.2kB build/esm/entry.d.ts.map npm notice 1.3kB build/cjs/entry.js.map npm notice 1.3kB build/esm/entry.js.map npm notice 149B build/cjs/index.d.ts.map npm notice 149B build/esm/index.d.ts.map npm notice 147B build/cjs/index.js.map npm notice 147B build/esm/index.js.map npm notice 270B build/cjs/util.d.ts.map npm notice 270B build/esm/util.d.ts.map npm notice 235B build/cjs/util.js.map npm notice 235B build/esm/util.js.map npm notice 1.5kB build/cjs/wrap-idb-value.d.ts.map npm notice 1.5kB build/esm/wrap-idb-value.d.ts.map npm notice 5.4kB build/cjs/wrap-idb-value.js.map npm notice 5.4kB build/esm/wrap-idb-value.js.map npm notice 2.7kB changes.md npm notice 14.4kB README.md npm notice 56B build/cjs/async-iterators.d.ts npm notice 56B build/esm/async-iterators.d.ts npm notice 56B build/cjs/database-extras.d.ts npm notice 56B build/esm/database-extras.d.ts npm notice 29.4kB build/cjs/entry.d.ts npm notice 29.4kB build/esm/entry.d.ts npm notice 88B build/cjs/index.d.ts npm notice 88B build/esm/index.d.ts npm notice 240B build/cjs/util.d.ts npm notice 240B build/esm/util.d.ts npm notice 40B with-async-ittr-cjs.d.ts npm notice 40B with-async-ittr.d.ts npm notice 1.6kB build/cjs/wrap-idb-value.d.ts npm notice 1.6kB build/esm/wrap-idb-value.d.ts npm notice === Tarball Details === npm notice name: idb npm notice version: 5.0.0 npm notice package size: 23.4 kB npm notice unpacked size: 174.9 kB npm notice shasum: 0a8f716626164f7cdb319404ceb12aa6993d02a7 npm notice integrity: sha512-vymvDIoMJAni3[...]UF/uNaqg+iuAg== npm notice total files: 52 npm notice + idb@5.0.0 ```
jakearchibald commented 4 years ago

I've published this change as 5.0.1, along with another change that avoids publishing the test build. Thanks