aspect-build / aspect-build/rules_js
[FR]: re-introduce "managed_directories" workflow
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What is the current behavior?
Back in rules_nodejs, we had Bazel add a `managed_directories` feature so that the `node_modules` tree only has to be installed once, and can be symlinked from Bazel's copy back to the source tree.
Now that it's been removed (https://docs.google.com/document/d/1u9V5RUc7i6Urh8gGfnSurxpWA7JMRtwCi1Pr5BHeE44/edit) users just have to `pnpm install` in their source tree again, and that can drift out-of-date from the `node_modules` tree that rules_js manages behind the scenes.
Bazel itself is in the way here, however the [Aspect CLI](https://aspect.build/cli) gives us the necessary spot to add such a feature, as it can keep all the `wksp/path/to/pkg/node_modules` symlinks updated and pointing into the bazel-out tree where we create them.
### Describe the feature
Allows users to configure the build so that local tooling like editors "just works" after the first `bazel build`.
### Implementation Notes
Symlinking `node_modules` into `bazel-bin`:
* ✅ navigates into `bazel-bin` for third-party packages (if that package has been built by bazel)
* ✅ navigates into local source for pnpm project references which **do not use out/rootDir**
* ❌ navigates into `bazel-bin` for pnpm projects with out/rootDir for projects which have been built
* ❌ no navigation for pnpm projects with out/rootDir that have not been built
* ❌ `main` package.json attribute in pnpm projects with out/rootDir may cause additional issues
Generated files: imports of generated files should navigate into `bazel-bin`
* files may never be generated by the targets a user runs locally
* files may never be generated due to BWOB
### Fund our work
- [ ] Sponsor our open source work by donating a [feature bounty](https://opencollective.com/aspect-build/)
Contributor guide
Assessment
This issue has not been assessed yet.