Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(@angular/build): allow enabling Bazel sandbox plugin with esbuild#30654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sbarfurth wants to merge1 commit intoangular:main
base:main
Choose a base branch
Loading
fromsbarfurth:sbarfurth/bazel-sandbox-plugin

Conversation

sbarfurth
Copy link

PR Checklist

Please check to confirm your PR fulfills the following requirements:

User facing documentation is intentionally omitted as this will be considered internal for now.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

When trying to integrate theesbuild 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 newENABLE_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?

  • Yes
  • No

Other information

The plugin itself was originally written inhttps://github.com/aspect-build/rules_esbuild. The version container in this commit is a fork ofhttps://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.

devversion reacted with hooray emoji
@devversion
Copy link
Member

For additional context: This will also be useful / needed for our usages of CLI inside Bazel for e.g. angular.dev

@sbarfurthsbarfurthforce-pushed thesbarfurth/bazel-sandbox-plugin branch fromd584b32 to04007f0CompareJuly 4, 2025 12:24
@sbarfurthsbarfurth marked this pull request as ready for reviewJuly 4, 2025 12:47
@sbarfurthsbarfurthforce-pushed thesbarfurth/bazel-sandbox-plugin branch 6 times, most recently from9338465 to8722ef6CompareJuly 7, 2025 09:22
@sbarfurth
Copy link
Author

I've had to change the original plugin to try for a.js file is a.ts file was resolved but doesn't exist in the sandbox. One example where this happens is if a.ts file is pre-compiled with something likets_project. The sandbox then only gets the output ofts_project, but thets_project rule itself depended on the.ts file. This means the.ts file will be present outside the sandbox, but it won't be linked into it. The resolution will resolve the.ts file outside the sandbox, but the path mapped back into the sandbox won't exist. Simply rewriting to.js is sufficient for this case and seems sensible enough.

Setting the new `ENABLE_BAZEL_SANDBOX_PLUGIN` environment variable to `true` or `1`during a build with the `esbuild` based builder will now inject a special plugin tomake `esbuild` compatible with Bazel builds in the output tree.When trying to integrate the `esbuild` based builder into Bazel with `rules_js` we foundthat it will incorrectly follow symlinks out of the sandbox. This is because Node.js basedtooling runs in the output tree to support canonical JS project directory structures. Theoutput tree will contain symlinks outside of the sandbox. Node tooling will generallyfollow these symlinks, which violates the rules of Bazel sandboxing. This can manifestin a wide variety of errors. One example we encountered with Angular compilationis that the symlinked browser entry point (e.g. `main.ts`) is outside of the range of`tsconfig.json` when the compiler follows the symlink.The plugin itself was originally written inhttps://github.com/aspect-build/rules_esbuild.The version container in this commit is a fork ofhttps://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.
@sbarfurthsbarfurthforce-pushed thesbarfurth/bazel-sandbox-plugin branch from8722ef6 to2ebbff4CompareJuly 7, 2025 09:59
@devversiondevversion added the action: reviewThe PR is still awaiting reviews from at least one requested reviewer labelJul 14, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@devversiondevversiondevversion approved these changes

@clydinclydinAwaiting requested review from clydin

Assignees
No one assigned
Labels
action: reviewThe PR is still awaiting reviews from at least one requested reviewerarea: @angular/builddetected: featurePR contains a feature commit
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@sbarfurth@devversion

[8]ページ先頭

©2009-2025 Movatter.jp