When running on windows, 'UNIX' was incorrectly being passed into jszip as the host platform which causes it to generate a zip file which lambda doesn't unpack properly. ( I think its the \ vs / thing - the zip file looks correct when I open it in a gui tool, but using unpack unpacks a bunch of files with '\' in the filename and no actual folder structure )
On Windows, process.platform equals 'win32', therefore platformName was 'UNIX' instead of 'DOS'.
This leaded into a strange behavior on UNIX platforms.
According to jszip docs, platform option also accepts process.platform values.
I simplified the code by passing process.platform directly.
In a regex, `.` means any character, so the default exclude list will
actually exclude more than intended (any path containing `.serverless`
for example).
Instead, use `String#indexOf()`
Update the hook order because the functions need the .zip file in their resource
definition. Furthermore the zipping process / writing it to disc was optimized.
The ".serverless" directory is also added to the "default exclude array" so that it's not
considered during packaging.