Unable to bundle individual packages (node_modules missing)
See original GitHub issueHi, I have some problems to be able to produce working individual packages. I don’t have node_modules in the .zip files
Here is an extract of my serverless conf serverless.yml
plugins:
- serverless-esbuild
- serverless-offline-local-authorizers-plugin
- serverless-offline
- serverless-stack-output
- serverless-prune-plugin
custom:
esbuild:
bundle: true
minify: false
sourcemap: true
packager: npm
installExtraArgs: ['--production']
exclude: ['aws-sdk', 'pg-native']
plugins: plugins.js
keepOutputDirectory: true
package:
patterns:
- '!node_modules/.prisma/client/query-engine-*'
- '!node_modules/prisma/query-engine-*'
- '!node_modules/@prisma/engines/**'
- 'node_modules/.prisma/client/query-engine-rhel-*'
individually: true
plugin.js
const { nodeExternalsPlugin } = require('esbuild-node-externals');
module.exports = [nodeExternalsPlugin()];
In the .esbuild/.build/
I have the node_modules with all the dependencies and I can see in the output of serverless deploy the Packing external modules:
completed also with all my dependencies present in the package.json
When I go to .esbuild/.serverless
in one of my individual .zip I can see that I only have the dep indicated in the pattern (i.e: .prisma/client…) and a .js with a js.map files with my function code.
If I remove the patterns conf, there only the function code.
When I trigger the functions, I have error complaining about missing modules.
The functions works when there is individual: false
Versions (please complete the following information):
- OS: Mac os M1
- serverless: 3.19.0
- esbuild: 0.14.43
- serverless-esbuild: 1.30.0
- esbuild-node-externals: 1.4.1
Issue Analytics
- State:
- Created a year ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
I’m having the same issue with
node_modules
missing in the zip artifact.In my case, I’m using
format: 'esm'
andplatform: 'node'
. I’ve debugged this and found the issue (for me) is ingetDepsFromBundle()
.I think this function should take into account the output format, not the platform.
https://github.com/floydspace/serverless-esbuild/blob/a233a1a5294ddf0875341312590f0078f468ae26/src/helper.ts#L125-L132
Sorry for not answering. I eventually not use individually:true for the past months. I’m now trying to make it work again. On node 14 everything seems to work as expected but as soon as I update to node 16, the behavior is not the same. Patterns seems broken =/
I have this in every function where I want prisma integrated:
The directives are respected concerning the .prisma and prisma directory but for the @prisma directory nothing is taken into account and I have artifact that bloat my final packages.
The @prisma directory is directly linked to the package whereas the two others are generated maybe it’s a kind of a race condition?
As it seems not fully related, I made another issue