GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — build: add Bazel g3_mode flag and acceptance_g3 test target by JeanMeche · Pull Request #72216 · angular/angular

Conversation

@JeanMeche

@JeanMeche JeanMeche commented Nov 26, 2026

Copy link
Copy Markdown
Member

Summary

Adds a Bazel --//tools/bazel:g3_mode flag and g3_test transition wrapper so g3-only / 3p-only code paths and type overloads can be compiled and tested directly in this repo without waiting for a g3 sync.

How it works

  • In-memory transform in rules_angular (tools/bazel/patches/rules_angular_g3_mode.patch): When --ngG3Mode is passed, the worker wraps fs.readFile to apply the markers documented in contributing-docs/google-markers.md and uses a fresh FileCache so 3P and g3 compilations never collide. Because files stay at their original paths, there is no root_dir / relative-import rewriting and zero overhead for normal 3P builds.
  • Bazel flag & transition (tools/bazel/BUILD.bazel, tools/bazel/g3_mode.bzl, tools/defaults.bzl): g3_test transitions --//tools/bazel:g3_mode=true across the full dependency graph so @angular/core, @angular/core/testing, and specs all build consistently in g3 mode.
  • *_g3_spec.ts convention (packages/core/test/acceptance/BUILD.bazel): acceptance_g3 runs **/*_g3_spec.ts (excluded from 3P acceptance_lib, with acceptance_g3_lib and acceptance_g3_raw tagged manual). Includes a smoke test in g3_mode_g3_spec.ts verifying g3-only / 3p-only markers, OnPush default in g3, and 3p-only API stripping.

Verification

  • pnpm bazel test //packages/core/test/acceptance:acceptance //packages/core/test/acceptance:acceptance_g3 — both pass.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SkyZeroZx reacted with eyes emoji
All reactions
  • 👀 1 reaction
@angular-robot angular-robot Bot added the area: build & ci Related the build and CI infrastructure of the project label Nov 26, 2026
@ngbot ngbot Bot added this to the Backlog milestone Nov 26, 2026
@JeanMeche
JeanMeche force-pushed the test/bazel-g3-mode-target branch 2 times, most recently from 0d0d2e7 to 2ef2c7c Compare November 26, 2026 00:25
@JeanMeche
build: add Bazel g3_mode flag and acceptance_g3 test target
112c778
Adds a Bazel `--//tools/bazel:g3_mode` build setting and a `g3_test`
transition rule so Angular tests can be compiled and executed locally
and in CI with `g3-only` / `3p-only` sync markers active.

- **`tools/bazel/patches/rules_angular_g3_mode.patch`**: Supports
  `--ngG3Mode` in `rules_angular`'s compiler worker, applying
  `g3-only` / `3p-only` markers in-memory via `fs.readFile` with an
  isolated `FileCache` (zero overhead and zero cache pollution for 3P
  builds, no file copying or `root_dir` rewrites).
- **`tools/bazel/BUILD.bazel` & `tools/bazel/g3_mode.bzl`**: Defines
  `//tools/bazel:g3_mode`, `//tools/bazel:is_g3_mode`, and the `g3_test`
  transition wrapper.
- **`tools/defaults.bzl`**: Forwards `--ngG3Mode` to `ts_project` and
  `ng_project` when `is_g3_mode` is active.
- **`packages/core/test/acceptance`**: Scopes `acceptance_g3` to
  `**/*_g3_spec.ts` (excluded from 3P `acceptance_lib`) and adds a
  `g3_mode_g3_spec.ts` smoke test.
@JeanMeche
JeanMeche force-pushed the test/bazel-g3-mode-target branch from 2ef2c7c to 112c778 Compare November 26, 2026 00:26
@JeanMeche
JeanMeche requested a review from alan-agius4 November 26, 2026 00:30
@JeanMeche
JeanMeche marked this pull request as ready for review November 26, 2026 00:31
@JeanMeche

JeanMeche commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

This is something that would help us having a better confidence landing #71762.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

alan-agius4
alan-agius4 reviewed Nov 27, 2026
View reviewed changes
Comment thread packages/core/test/acceptance/g3_mode_g3_spec.ts
// Mutating a plain property without marking dirty should not update an OnPush component.
fixture.componentInstance.value = 'mutated';
await fixture.whenStable();
expect(fixture.nativeElement.textContent).toBe('initial');

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check passes in 3P mode as well. angular_jasmine_test initializes TestBed with provideZonelessChangeDetection(), so mutating a plain property does not schedule change detection and fixture.whenStable() resolves immediately without refreshing the view even for ChangeDetectionStrategy.Eager.

Checking (DefaultOnPushCmp as ɵComponentType<DefaultOnPushCmp>).ɵcmp.onPush directly (or testing DefaultOnPushCmp as a child of a host component that refreshes via a signal update) would verify that OnPush is actually active here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tools/bazel/patches/rules_angular_g3_mode.patch
// In workers, use a compiler host that leverages the persistent
// file cache. Otherwise, fall back to an uncached host.
if (worker !== null) {
+ const fileCache = g3Mode ? new FileCache() : worker.fileCache;

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two issues with how the worker caches are handled in g3Mode:

  1. Unpatched loop.mts still runs worker.fileCache.updateCache(workerInputs) unconditionally earlier in executeBuild, so g3 builds still mutate the shared 3P worker.fileCache and run updateCache twice.
  2. Because g3Mode skips populating worker.programCache while allocating a fresh FileCache and Program per request, if a worker running g3 builds crosses MAX_WORKER_MEMORY (3 GiB), evictRecentlyUsedEntriesToFreeUpSpace(programCache) in worker.mts will throw when programCache is empty and crash the worker.

Keeping a separate persistent g3FileCache on the worker and including g3Mode in getReuseHashForProject(...) would avoid both issues and preserve incremental worker caching for g3 builds.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tools/bazel/patches/rules_angular_g3_mode.patch
+ filePath.endsWith('.ts') &&
+ !filePath.endsWith('.d.ts') &&
+ !filePath.includes('/node_modules/') &&
+ !filePath.includes('/src/webmcp/') &&

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding Angular repository paths (webmcp, event_contract_defines.ts, goog.d.ts) inside a git_override patch on rules_angular will make rules_angular bumps fragile and will accumulate more exclusions as other packages adopt g3_test (for example packages/compiler-cli/index.ts and packages/zone.js/lib/zone.ts also fail to compile in 3P under --//tools/bazel:g3_mode=true).

Could we pass exclusions or a transform hook from this repository (or upstream a generic hook into rules_angular) instead of hardcoding Angular paths in the patch?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tools/bazel/patches/rules_angular_g3_mode.patch
+ continue;
+ }
+ if (in3pBlock) {
+ continue;

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping lines with continue shifts all subsequent line numbers upward in TypeScript diagnostics, source maps, and stack traces (for example by 35+ lines in r3_injector.ts). Pushing empty lines (out.push('')) instead keeps line numbers aligned 1:1 with the .ts files on disk.

Also, using \b in /^\s*\/\/\s*g3-only\b/ matches hyphenated text like // g3-only-mode or // g3-only: note and produces invalid syntax. Switching \b to (?:\s|$) and throwing with filePath if in3pBlock || inG3Block is still true at EOF would catch unclosed markers instead of silently transforming the rest of the file.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tools/bazel/g3_mode.bzl
)
runfiles = ctx.runfiles(files = [orig_exe]).merge(target[DefaultInfo].default_runfiles)
return [DefaultInfo(executable = exe, runfiles = runfiles)]

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_g3_test_impl drops RunEnvironmentInfo (needed by js_test targets that set env or env_inherit) and testing.ExecutionInfo from the wrapped target. Also, declaring exe as ctx.label.name strips orig_exe's file extension (such as .bat or .exe), which breaks execution on Windows.

Preserving orig_exe.extension under a target subdirectory and forwarding RunEnvironmentInfo and testing.ExecutionInfo when present on target would handle both cases. Also worth noting in doc that g3_mode only applies to target configuration compilations (so AOT ng_project workers in exec configuration still run the 3P compiler) and that test attributes like size or tags need to be set on g3_test directly.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/test/acceptance/BUILD.bazel
tags = ["manual"],
)

g3_test(

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since acceptance_g3 is not manual, pnpm test:ci will run it on every PR. Because angular_jasmine_test brings in //tools/testing:node, the transition rebuilds a large subgraph (core, compiler, common, platform-browser, platform-server, and tools/testing:node) in a second configuration with no cache sharing against 3P builds, and any future g3 marker added to those packages could break acceptance_g3.

Have we checked the CI wall time and RBE impact, and is running this on every PR intentional?

Also, ts_project(tags = ["manual"]) above does not forward tags to strict_deps_test, so acceptance_g3_lib_deps still runs as a non manual 3P test in CI against untransformed sources. Propagating manual to strict_deps_test in tools/defaults.bzl would keep it aligned.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread MODULE.bazel
module_name = "rules_angular",
commit = "a6e335c5a0f60eca994bf83934d3fd1b33c186f0",
patch_strip = 1,
patches = ["//tools/bazel/patches:rules_angular_g3_mode.patch"],

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add "rules_angular_g3_mode.patch" to exports_files([...]) in tools/bazel/patches/BUILD.bazel to match aspect_rules_jasmine.patch and keep it a declared Bazel target.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tools/defaults.bzl
name,
srcs = srcs,
deps = deps,
args = args + _G3_MODE_ARGS,

@alan-agius4 alan-agius4 Nov 27, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small guard: using (args or []) + _G3_MODE_ARGS (here and in ng_project below) avoids a Starlark error if a caller explicitly passes args = None.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alan-agius4 alan-agius4 alan-agius4 left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area: build & ci Related the build and CI infrastructure of the project

Projects

None yet

Milestone

Backlog

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@JeanMeche @alan-agius4
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.