Replies: 1 comment 1 reply
-
There is an option to bundle functions individually like this example here By entry do you mean per function handler path? If so, you can combine it with function package patterns to package those extra files you need on a per function basis? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So this is a bit tricky, the need comes from dynamic imports from
vm2
which is one of the many problematic but commonly used dependencies. Some other examples would becoffee-script
andformiable
.For more context about the problem please see evanw/esbuild#495, it essentially boils down to a requirement of copying necessary files ourselves after bundling. But at the same time I don't want to blindly copy to all entries (I have 300 lambdas), but only copy when the resolution hits a certain path. i.e. Copy
contextify.js
andsandbox.js
whenvm2
is hit at least once for the current entry.Does
serverless-esbuild
support such a per entry build hook right now? If not, is it possible to add one?Alternatives considered
onDynamicImport
but it require quite a lot of hacks for a sub-dependency to know which entry it's currently bundling, alsoserverless-esbuild
needs to allow a custom impl of esbuild.metafile
with anonEnd(...)
callback as a custom plugin, makes the packaging step including all copies from other entries. Say I have 300 lambdas, every entry will contain the copied assets of the other 299 lambas. This instantly explodes the resulting bundle from GB levels into TB levels.Update
Turns out I don't actually need to copy those files because I don't need
vm2
at all. The exact tree wasauth0
->rest-facade
->superagent-proxy
->proxy-agent
->pac-proxy-agent
->pac-resolver
->degenerator
->vm2
.Both
rest-facade
anddegenerator
already updated to make the downstream requirement optional, see auth0/node-auth0#657 (comment) for the workaround.But this question remains valid for those who actually need HTTP proxy, answers are still welcomed and I'll mark it for others if it works.
Beta Was this translation helpful? Give feedback.
All reactions