should function building take this long? just over...
# help
s
should function building take this long? just over 2 minutes to build these functions, and they’re pretty tiny 😕 this is about how slow Serverless Framework was when I was using
serverless-webpack
..then I switched to
serverless-esbuild
and it would rip through 70+ functions in less than 15-20 seconds
f
Hey @Sam Hulick, are you setting
bundle.nodeModules
in default function props?
s
yeah
since there’s no stack-level
setDefaultFunctionProps
it’s a tough call.. I several functions in the
API
stack rely on knex. almost all of them
but in Serverless Framework, I had declared knex as
external
(which would include it in node_modules) and it was still fast
f
I think the slowness is caused by
nodeModules
getting installed per Lambda function.
@Ross Coundon ran into the same issue a while back
Let me take a look at this issue today!
s
thank you! just so I’m clear..
externalModules
just excludes the dependency completely, and
nodeModules
will throw it into node_modules in the Lambda ZIP, rather than bundle it into the code via esbuild, right?
f
Yup
s
maybe a workaround would be to just put
knex
and
pg
into a Lambda layer then, and use
externalModules
those two packages are rarely updated
f
SST would create a empty fold, put a
package.json
in there with just
knex
as dependency, and runs
npm/yarn install
, and bundle the
node_modules
with the function
Currently SST is doing it once PER lambda
s
I see. yeah, that would explain the time it takes
I’ll try the Lambda layer route for now. and I’ll sub to that issue to keep tabs on any updates
f
Soudns good!