serverless-webpack icon indicating copy to clipboard operation
serverless-webpack copied to clipboard

Specify file patterns to be removed from module dependencies

Open nbransby opened this issue 7 years ago • 3 comments

This is a Feature Proposal

Description

Is it possible to specify file patterns to be removed from module dependencies on individual packaging? Switching to yarn has already considerably decreased my zip size (thank you for that) but I have a number of node modules I am using that include a large amount of files that are not actually needed.

For example punycode2 does not .npmignore its test folder which houses 15mb of test data. My current solution (workaround) is to delete these files from the yarn cache which means wherever they are installed those files are not present but obviously that is not a very portable solution.

Additional Data

  • Serverless-Webpack Version you're using: 5.2.0
  • Webpack version you're using: 4.16.0
  • Serverless Framework Version you're using: 1.28.0
  • Operating System: Windows 10
  • Stack Trace (if available):

nbransby avatar Jul 16 '18 07:07 nbransby

I've tried to use modclean with a hook on before:webpack:package:packExternalModules for doing this too, but it doesn't seem to work... The node_modules that are uploaded still have everything that was removed with modclean

cryptiklemur avatar Aug 03 '18 18:08 cryptiklemur

You should use after:webpack:package:packExternalModules. packageExternal modules executes a npm install, so before would be too early. However, I'm planning to add some kind of exclude pattern (there is already some older PR)

HyperBrain avatar Aug 04 '18 10:08 HyperBrain

I tried that too, and the size of my uploads didnt change. Deployed code still had stuff that modclean is supposed to remove too

cryptiklemur avatar Aug 04 '18 17:08 cryptiklemur