Monday 15 July 2013

node.js - Compacting node_modules for client-side deployment -


I'm Node.js. I implement the client-side application in JavaScript. Because I'm deploying software on many machines, I want to reduce the size of the distribution package. In particular, I would like to remove any unnecessary files from node_modules.

For starters, this dependency tree means cutting and sorting, which can do for me npm but I also do all package.json files And I would like to extract any other files which are not necessary for deployment. Multiple tests in multiple packages, multiple versions of the file (minified, browser, etc.) and are liked. I just need JavaScript files that are actually used by the running app. Otherwise I would distribute some 100 KB files that were not actually used.

I know but my app is running in a normal GS environment, not a browser, so I want to keep the modules separate and load them with the requirement .

I'm thinking of writing a grunting plugin that uses dependency trees, pulls the required JavaScript files at runtime and writes them to a tree's structure so that they Required to load (without modifying package.json ) but I would like to ensure that no one is dealing with it before Before me Did not do this.

FWIW:. My use case is a bit unusual because we are developing one. Like the standard nodejs deployment and unlike, we want to reduce the size of our distribution, which includes any generic JS module. But unlike Browserify , we support general JSS so that we can keep the module structure instead of adding everything to a larger file.

Basically all of the package.json , readme, test files etc. From node_module , but place an essential javascript file in a composition that can be used by a normal JS module loader.

No comments:

Post a Comment