Feature request: Skip `NodejsNpmEsbuildBuilder:NpmUpdate` step when using `--build-in-source` in a js/ts "monorepo"
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### 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.
Contributor guide
Assessment
This issue has not been assessed yet.