angularjsnode.jsnpmcdnexternal-dependencies

What part of node modules is required in production and development?


Can I safely delete other folders in a node modules library except for the min files that I use in the project?

Eg: using angular ui-select library for dropdown

only using min files from - node_modules/dist/select.min.js, select.min.css

(thinking of using a cdn instead, as a library created in node modules is huge with extra folders like src, docs, test ..)


Solution

  • There is no guarantee that you can do this in general. However, by convention, most packages have a fully-contained unminified copy and a fully-contained minified copy. Since these files do not have other dependencies within the package, you could delete other files in the package without causing any problems.

    However, it's a good idea to ask yourself why this is necessary. If your client app only requests the minified file, then the rest of the package doesn't need to be sent to the client anyway. So the main savings is server storage, which for most packages is minimal in the context of disk space.