serverless-esbuild
serverless-esbuild copied to clipboard
feat(externals): add option to disable packing of external modules
Adds an additional configuration option packExternals which will disable installing & bundling modules listed as external.
This is useful for if you want to exclude externals from esbuild but you don't need them installed & packed separately. My use-case was with serverless-offline as externals can be imported normally from node_modules, leading to a faster build. Another use-case could be if you're using lambda layers.
Hi @mattjennings, thank you for your PR.
The package specified in the
excludeoption is passed toesbuildasexternal, but it is not included in the function bundle either.
we already have the option exclude, will it cover your use case?
what can we do extra is making exclude option accept boolean values, so if it is true it excludes everything set as external. I have the reason for this: having set exclude and packExternals does not make sense together (exclude would have no effect), so it is why we can keep only one option, but I need second eyes from @olup on it.
Ah yes, I hadn't considered the exclude option. I agree, finding a way to use exclude is a better idea. A boolean might be fine, otherwise maybe allowing pattern matching or * as a value to designate excluding everything.
maybe allowing pattern matching or
*as a value to designate excluding everything
also works for me 👍, please also describe it in the readme if you gonna make the fix.
@floydspace @mattjennings I've opened https://github.com/floydspace/serverless-esbuild/pull/167 for pattern matching. Could you please give it a look?