The following improves upon just simple cp -a in that it does not include the devDependencies, so function.zip can be 10x smaller.
cp -a
function.zip
cp package.json dist/ npm install --prefix ./dist --omit=dev