Make the node_modules folder more space efficient by having a --production flag to install only the files used #292
-
Title sums it all. We should have a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
How would npm determine that, exactly? |
Beta Was this translation helpful? Give feedback.
-
@destroyer22719 Appreciate the suggestion. After some discussion in a recent RFC call, I don't think there's an easy way to support this today. Unfortunately, we don't tend to know the intent of the package author; ie. potentially an author wants to ship files that aren't used at runtime (ex. licenses, static files/assets to be copied etc.) so it's hard to determine what is or isn't used or what should or should not be installed. Static code analysis of your project would also only tell you so much about usage. That said, one way to solve this issue today is, ask package authors to only ship the necessary files required for usage of that package (which may mean they end up publishing different packages for those different use cases). Another concept we have floated in this realm would be to intercept module requests and introduce a virtual file system (ex. Ultimately, I don't think we'd want to change the current behavior of |
Beta Was this translation helpful? Give feedback.
@destroyer22719 Appreciate the suggestion. After some discussion in a recent RFC call, I don't think there's an easy way to support this today. Unfortunately, we don't tend to know the intent of the package author; ie. potentially an author wants to ship files that aren't used at runtime (ex. licenses, static files/assets to be copied etc.) so it's hard to determine what is or isn't used or what should or should not be installed. Static code analysis of your project would also only tell you so much about usage.
That said, one way to solve this issue today is, ask package authors to only ship the necessary files required for usage of that package (which may mean they end up publishing diff…