Hi, I use `serverless-bundle` and I want to exclud...
# help
m
Hi, I use
serverless-bundle
and I want to exclude all node modules from generated js files in zip (cause I package all dependencies in a layer). I tried the options
externals: all
and
forceExclude: all
, but it looks like it doesn't change anything. Any idea how to achieve that?
After few more tests, it looks like the
externals: all
option is not working as expected in my case ; I tried adding all dependencies in externals, and the generated Zip file is finally much smaller
I think that's because I use a mono-repo architecture, but all dependencies are installed in the root package.json
I had to specify both node_modules folder in my Webpack config (before switching to serverless-bundle)
Copy code
externals: [
  nodeExternals({
    modulesDir: resolve(__dirname, 'node_modules'),
    additionalModuleDirs: [resolve(process.cwd(), 'node_modules')]
  })
]
t
Yeah we don't support specifying all right now
You can maybe read from package.json
m
Good idea, thanks 🙂
I also opened a PR on serverless-bundle (maybe not the best solution, if someone has another idea 😉) https://github.com/AnomalyInnovations/serverless-bundle/pull/280/files