feat(@angular/build): allow enabling Bazel sandbox plugin with esbuild #30654
+112
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check to confirm your PR fulfills the following requirements:
Docs have been added / updated (for bug fixes / features)User facing documentation is intentionally omitted as this will be considered internal for now.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When trying to integrate the
esbuild
based builder into Bazel withrules_js
we found that it will incorrectly follow symlinks out of the sandbox. This is because Node.js based tooling runs in the output tree to support canonical JS project directory structures. The output tree will contain symlinks outside of the sandbox. Node tooling will generally follow these symlinks, which violates the rules of Bazel sandboxing. This can manifest in a wide variety of errors. One example we encountered with Angular compilation is that the symlinked browser entry point (e.g.main.ts
) is outside of the range oftsconfig.json
when the compiler follows the symlink.Issue Number: N/A
What is the new behavior?
Setting the new
ENABLE_BAZEL_SANDBOX_PLUGIN
environment variable totrue
or1
during a build with theesbuild
based builder will now inject a special plugin to makeesbuild
compatible with Bazel builds in the output tree.Does this PR introduce a breaking change?
Other information
The plugin itself was originally written in https://github.com/aspect-build/rules_esbuild. The version container in this commit is a fork of https://github.com/aspect-build/rules_esbuild/blob/e4e49d3354cbf7087c47ac9c5f2e6fe7f5e398d3/esbuild/private/plugins/bazel-sandbox.js. I've adapted the JS file to TypeScript and made no further changes.