-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package individually doesnt include node_modules and package.json #86
Comments
I'd say you have to declare externals if you want to have your modules added as externals modules to your zip. Otherwise, all the code is bundle as one js file, isn't it ? It shouldn't fail, as long as you have no native dependencies in your modules - ie only javascript depencies that are bundable by esbuild |
lets say I have 20+ restapi in because I was using |
just use the external key of the config if you need, otherwise a single bundle should do. "I check another issue say need to add include to each http event, so i need to manually add all include to those 20+ API..." this is a workaround only needed if you want to have specific bundle size on each lambda. But it's a workaround, and may not be advisable in your own case. The bottom line is this package will work with individual packaging, but will not optimize the bundle size for each lambda, period. (or until the other ticket is addressed by maintainer or contributor) |
thanks for the answer. |
Hey @yeukfei02, we released the individually packaging fix in v1.8.0, could you please verify that it resolves your issue. |
hey i just try in one of my project, I use with serverless framework and run
thanks. |
hey @yeukfei02 . could you post here your |
serverless version: |
Interesting. Would it be a problem for you to attach or link the zip'ed package for this function ? I'd like to check how the serverless_sdk is imported in the bundle. Other question, in your handler's code, do you |
package.json
my handler.ts didnot import any sls sdk..i believe when i run its ok. i am still using |
serverless esbuild did not include node_modules nor package.json because you did not declare any externals. This is intended behavior. The is no dependencies to add to the bundle if you don't declare them in externals (the same goes for serverless-webpack, but you might be using node_externals plugin that takes ALL your dependencies as externals). Same goes for your prisma schema. You have to declare it otherwise it won't be picked up as it's not a js/ts file. the serverless_sdk is added automatically to your code by serverless because you must be using their hosted dashboard and metrics. |
yes I use thanks. |
+1 I had the same issue as OP. I was unable to include the package.json at all using the documented method for packaging e.g.
Specifying externals, did include the node_modules correctly, but still no package.json In my use case the lack of a package.json meant the lambda was not executing as an esm module. Fortunately i was able to add P.S. Love the plugin. So much faster than webpack |
Hi,
this is a nice lib.
but I try this lib with the serverless framework, I face some problem:
serverless.yml
I didn't set anything in
custom
..inside the.serverless
folder I don't see anynode_modules
+package.json
file.If I deploy this lambda func to aws, I guess will fail?
How can I make
node_modules
+package.json
file included in each lambda func zip?Thanks!
The text was updated successfully, but these errors were encountered: