Open cdriesler opened 6 months ago
hi @cdriesler thanks for raising the issue.
Reason for the dev dependencies getting removed is the underlying npm install
or npm update
command is always run with the --production
flag. I believe it made sense for nodejs
runtimes because node_modules
dir is included in the lambda function artifact. But for typescript or when using esbuild
with --build-in-source
, the effect of --production
results in the inconvenience you saw.
This seems like a reasonable use case to keep the dev dependencies in the node_modules
dir in the source dir. I will bring that to the team for discussion and prioritization.
Seems like your team discussions went nowhere and we're all still suffering this annoying behavior.
Description:
I'm using the
--build-in-source
flag to build a number of js/ts-based resources that share code in a "monorepo" shaped project. It has greatly simplified our ability to share and bundle code between lambdas withBuildMethod: esbuild
. The project looks something like:We use npm
workspaces
inpackage.json
to share code and types.This may be expected behavior, but I've noticed that each time I run
sam build --build-in-source
(with or without--cached
) our rootnode_modules
loses all packages (includingtypescript
) that are only specified indevDependencies
. I have to re-runnpm ci
after eachsam build
in order to restore types and typescript commands.Is there something that can be done to keep them around? Or, if this is expected/required, are there best practices for how to keep our
devDependencies
around?Steps to reproduce:
npm i
ornpm ci
to installdependencies
anddevDependencies
specified inpackage.json
sam build --build-in-source
and build a resource withBuildMethod: esbuild
Observed result:
My
devDependencies
are no longer in my project'snode_modules
. Specificallytypescript
, which is only ever specified there.Expected result:
My
devDependencies
remain in my project'snode_modules
.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)