Nice article, I didn't know about the prune. Normally I just use webpack and serverless framework and run the optimisations on webpack itself.
but the deployment package has to restrict to 500MB
I think you mean 250Mb.
From the docs, the deployment package can be:
or now up to 10Gb if you are using a container image.