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

A request for shrinking the size of crassa #18

Open
DaleyThom opened this issue Jun 12, 2020 · 0 comments
Open

A request for shrinking the size of crassa #18

DaleyThom opened this issue Jun 12, 2020 · 0 comments

Comments

@DaleyThom
Copy link

DaleyThom commented Jun 12, 2020

Hi, @ghondar

According to npm’s installation rule, it parses the package.json based on the libraries’s declaration order, to construct the node_modules tree. For the libraries that have not been installed in the project, node_modules tree can share them by putting them at the top level of the tree. For the libraries that have been installed, it checks whether their specified version constraints are compatible with the installed ones. If yes, npm ignores them, otherwise, npm will put such duplicated libraries in the subfolders (npm’s sandboxes).

We installed and analyzed the crassa, and found that it is large in size. crassa’s node_modules tree has installed 2218 libraries. 1332 out of 2218 libraries are shared at the top level of the tree, while 886 libraries are the duplicated in the sandboxes. We further checked the duplicated libraries, and listed the them as follows (format: library name, version number, the number of installations on the node_modules tree). For example, “extend-shallow, 2.0.1, 58” denotes that library extend-shallow 2.0.1 has been installed 58 times in this project.

click for details
extend-shallow, 2.0.1, 58
kind-of, 3.2.2, 43
debug, 2.6.9, 29
ms, 2.0.0, 29
isobject, 3.0.1, 24
kind-of, 6.0.3, 21
define-property, 0.2.5, 18
is-accessor-descriptor, 1.0.0, 17
is-data-descriptor, 1.0.0, 17
is-descriptor, 1.0.2, 17
define-property, 1.0.0, 16
kind-of, 5.1.0, 16
is-number, 3.0.0, 16
array-unique, 0.3.2, 15
arr-diff, 4.0.0, 15
source-map, 0.6.1, 15
is-data-descriptor, 0.1.4, 14
is-descriptor, 0.1.6, 14
braces, 2.3.2, 14
extglob, 2.0.4, 14
is-accessor-descriptor, 0.1.6, 14
micromatch, 3.1.10, 14
fill-range, 4.0.0, 14
expand-brackets, 2.1.4, 14
pify, 3.0.0, 10
slash, 2.0.0, 9
is-extglob, 2.1.1, 9
is-glob, 4.0.1, 9
ansi-regex, 4.1.0, 8
bn.js, 4.11.9, 7
strip-ansi, 5.2.0, 7
jest-resolve, 24.9.0, 6
normalize-path, 3.0.0, 6
anymatch, 2.0.0, 6
npm-run-path, 2.0.2, 5
ansi-regex, 3.0.0, 5
strip-ansi, 4.0.0, 5
debug, 3.2.6, 5
camelcase, 5.3.1, 5
glob-parent, 3.1.0, 5
is-glob, 3.1.0, 5
postcss-selector-parser, 5.0.0, 4
readable-stream, 3.6.0, 4
pify, 2.3.0, 4
execa, 1.0.0, 4
get-stream, 4.1.0, 4
normalize-path, 2.1.1, 4
chokidar, 2.1.8, 4
commander, 2.20.3, 4
cssesc, 2.0.0, 4
supports-color, 6.1.0, 4
p-locate, 2.0.0, 3
p-try, 1.0.0, 3
braces, 3.0.2, 3
fill-range, 7.0.1, 3
is-number, 7.0.0, 3
to-regex-range, 5.0.1, 3
babel-plugin-dynamic-import-node, 2.3.3, 3
callsites, 3.1.0, 3
string-width, 3.1.0, 3
make-dir, 1.3.0, 3
find-up, 2.1.0, 3
locate-path, 2.0.0, 3
inherits, 2.0.3, 3
p-limit, 1.3.0, 3
dot-prop, 5.2.0, 3
is-obj, 2.0.0, 3
postcss-selector-parser, 3.1.2, 3

So many duplicated libraries could cause potential problems, such as: slower installs, exploding bundle sizes, and so on.

Based on npm’s installation rules, we comprehensively analyzed the compatibilities of all the transitive dependencies’ version ranges and the topological structure of your node_modules tree. We suggested crassa add the following duplicated libraries with their compatible versions into the package.json file (as shown in the attachment), which help to refactor the project’s node_modules tree. After cleaning the local installation environment and re-installing crassa based on the revised package.json file, we found that the node_modules tree totally installs 1741 libraries, including the 1332 ones at the top level, 409 ones in the sandboxes. As such, the revised package.json file reduces 477 duplicated libraries for crassa. In this manner, reducing 2558 files (from 34530 to 31972) and 678 folders (from 5497 to 4819) in total. Note that, all the added directed dependencies in package.json file are deduced based on the original node_modules tree, which will not miss any required dependencies.

click for details
"extend-shallow": "2.0.1",
"debug": "2.6.9",
"isobject": "3.0.1",
"array-unique": "0.3.2",
"kind-of": "6.0.2",
"is-number": "3.0.0",
"braces": "2.3.2",
"is-extglob": "2.1.1",
"define-property": "1.0.0",
"source-map": "0.6.1",
"is-extendable": "1.0.1",
"is-descriptor": "0.1.0",
"micromatch": "3.1.10",
"ansi-regex": "4.1.0",
"pify": "3.0.0",
"strip-ansi": "5.2.0",
"is-glob": "4.0.1",
"anymatch": "2.0.0",
"glob-parent": "3.1.0",
"normalize-path": "3.0.0",
"npm-run-path": "2.0.0",
"supports-color": "6.1.0",
"chokidar": "2.1.8",
"inherits": "2.0.3",
"get-stream": "4.0.0",
"execa": "1.0.0",
"postcss-selector-parser": "5.0.0-rc.4",
"find-up": "2.1.0",
"slash": "2.0.0",
"is-obj": "2.0.0",
"dot-prop": "5.2.0"
Would you like to adopt this suggestion to shrink the project’s size?

Thank you for your attention.
Best regards.
package.zip
package-lock.zip

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

1 participant