question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPM package is bundled with useless files and is too big (3 Mo that can be reduced to 620 Ko)

See original GitHub issue

First of all: NeDB is awesome!

Big NPM package with unnecessary files

The NPM package is quite big and includes many unnecessary files (and dependencies) for a Node.js usage.

Uncompressed NPM package size is about 3 Mo and can be reduced to 620 Ko !

Here is the total size with dependencies:

 88K    async
132K    binary-search-tree
1.1M    localforage         (UNNECESSARY)
 92K    mkdirp
1.4M    nedb
184K    underscore

And the detailed size of naked NeDB package

4.0K    LICENSE
 44K    README.md
 44K    benchmarks          (USELESS)
4.0K    bower.json          (USELESS)
916K    browser-version     (USELESS)
4.0K    index.js
 96K    lib
4.0K    package.json
292K    test                (USELESS)
 20K    test_lac            (USELESS)

Potential Solutions

I’m focused on the NPM deployment so I may miss some browser deployment considerations… Let me know if it make sense…

.npmignore ?

I think NeDB can easily save 1.30 Mo by adding the following .npmignore file to the repo:

benchmarks
bower.json
browser-version
test
test_lac

PS: This has already been done in the bower.json file.

Move localforage to devDependencies ?

Now about the localforage dependency… it looks like it is already bundled into browser-version/out… Can we simply move localforage dependencies to devDependencies in package.json?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
louischatriotcommented, May 4, 2016

Thanks for the kind words 😃

So there are also standalone versions of NeDB for the browser which clock in at 292KB and 98 KB when minified: https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js and https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.min.js

That said you are right about the server version, the npm package itself could be cleaned to only include the necessary files. Will try to do it when I have the time!

0reactions
bahmutovcommented, Jun 19, 2016

You can whitelist the files quickly in package.json and check the published size, see https://glebbahmutov.com/blog/smaller-published-NPM-modules/ for example to measure NPM published size you can add script command

"scripts": {
  "size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";"
}

This will print the list of files included in published tar as well as total size

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node module size: See how I reduced it by 90% | TSH.io
Most of our projects have seen +-33% reduction of node_modules size after we've used it (176MB). Remove unnecessary files. Have you ever thought ......
Read more >
5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
In this article, I will discuss 5 techniques to reduce the JavaScript bundle size to avoid any performance bottlenecks. 1. Code Splitting with ......
Read more >
Guidelines for Environmental Infection Control in Health-Care ...
The full-text version of the guidelines appears as a web-based document at the CDC's Division of. Healthcare Quality Promotion's Infection Control website. ( ......
Read more >
The Structural Mechanics Module User's Guide
3 . The difference in stiffness along different directions can thus become very large. When an object is very thin, a shell model...
Read more >
WindPRO 2.7 User Guide - EMD International
Chapter 7, module WINDPLAN is no longer included due to low ... the WindPRO software in C:\Program files\EMD\WindPRO2.7\ by default.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found