Describe your idea/feature/enhancement
We are currently making great use of the new --build-in-source flag for sharing js/ts code between several AWS resources (also written in js/ts). Our project is set up in a "monorepo" structure, something like:
packages/
package-a/
package.json
endpoints/
endpoint-a/
package.json
package.json
We use npm workspaces in the root package.json to allow resources like endpoint-a to specify modules like package-a as a dependency. The built-in SAM esbuild options can then find and bundle the code when using --build-in-source.
We've noticed, though, that overall build times have increased by quite a bit because of (what seems to be) a redundant NodejsNpmEsbuildBuilder:NpmUpdate step for each resource. In our case, all of our required dependencies have already been installed before we run sam build. This is true for all resources, because they are all also specified in the workspace's package.json.
The second step of the build for each resource (NodejsNpmEsbuildBuilder:EsbuildBundle ) represents less than 5% of the build time. If we could intelligently or explicitly skip the NpmUpdate step, our stack builds would speed up considerably.
Proposal
- Option A: An explicit flag like
--skip-dependencies to turn off SAM's management/installation of dependencies. Potentially also requiring --build-in-source. (It feels like that might be the only case where this new flag makes sense.)
- Option B: Skip redundant installs that can be asserted based on the contents of a root
package.json. This seems a bit antithetical to the way SAM thinks about resources and handles building, but may be technically possible.
Describe your idea/feature/enhancement
We are currently making great use of the new
--build-in-sourceflag for sharing js/ts code between several AWS resources (also written in js/ts). Our project is set up in a "monorepo" structure, something like:We use npm
workspacesin the rootpackage.jsonto allow resources likeendpoint-ato specify modules likepackage-aas adependency. The built-in SAM esbuild options can then find and bundle the code when using--build-in-source.We've noticed, though, that overall build times have increased by quite a bit because of (what seems to be) a redundant
NodejsNpmEsbuildBuilder:NpmUpdatestep for each resource. In our case, all of our required dependencies have already been installed before we runsam build. This is true for all resources, because they are all also specified in the workspace'spackage.json.The second step of the build for each resource (
NodejsNpmEsbuildBuilder:EsbuildBundle) represents less than 5% of the build time. If we could intelligently or explicitly skip theNpmUpdatestep, our stack builds would speed up considerably.Proposal
--skip-dependenciesto turn off SAM's management/installation of dependencies. Potentially also requiring--build-in-source. (It feels like that might be the only case where this new flag makes sense.)package.json. This seems a bit antithetical to the way SAM thinks about resources and handles building, but may be technically possible.