Skip to content

Always inline Angular resources regardless of compilation mode#22

Merged
hellokirk merged 1 commit into
mainfrom
rivet-angular-15
May 18, 2026
Merged

Always inline Angular resources regardless of compilation mode#22
hellokirk merged 1 commit into
mainfrom
rivet-angular-15

Conversation

@hellokirk
Copy link
Copy Markdown
Member

@hellokirk hellokirk commented May 18, 2026

Summary

In fastbuild mode, Angular resources (HTML templates) were only processed through the resource compiler (HTML → JS module with exports.content). The raw HTML files were not linked next to the component output.

This causes Angular 15's TestBed to fail with "Component not resolved: templateUrl" because it can no longer resolve external templates via XHR in jsdom test environments.

This change makes the resource linking path (previously opt-only) run in all compilation modes.

Impact on other consumers

Safe for all consumers of this repo:

  • Consumers using opt mode for tests: no change (already uses this path)
  • Consumers using fastbuild for tests: resources are now linked next to output. Existing Angular 14 tests continue to work (verified). Angular 15+ tests get fixed.
  • The resource compiler JS modules (exports.content) are no longer produced, but no known consumer imports them directly — they exist only as an intermediary for Angular's template resolution.

TODO

Using if True: with a still-present else: branch leaves dead code and obscures intent. Since resources should now always be linked, remove the conditional entirely (along with the dead else branch) and inline the link_file call directly in the loop.

Testing

Verified on the rivet repo:

  • All 15 client unit test targets pass on main (Angular 14) with this change
  • Angular 15 branch tests pass with --compilation_mode=opt (which uses this same code path)

Context

Part of the Angular 14 → 15 upgrade in Rivet (RVT-23199).

Copilot AI review requested due to automatic review settings May 18, 2026 14:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Forces Angular resource files (e.g., HTML templates) to be linked alongside the component output in every compilation mode, not just opt. This unblocks Angular 15's TestBed which can no longer resolve external templateUrl files via XHR in jsdom, fixing test failures during the Angular 14 → 15 upgrade.

Changes:

  • Replaces the compilation_mode == "opt" check on the resource-linking branch with an unconditional if True:, effectively making resource linking always execute.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread angular/rules.bzl Outdated
@hellokirk hellokirk self-assigned this May 18, 2026
@hellokirk hellokirk requested a review from Copilot May 18, 2026 15:01
@hellokirk hellokirk review requested due to automatic review settings May 18, 2026 15:02
Remove the conditional that only linked resources in opt mode.
Resources are now always linked next to the component output so
Angular's TestBed can resolve templateUrl in all compilation modes.

Previously, fastbuild mode ran a resource compiler that converted
HTML to JS modules (exports.content). This is no longer needed —
Angular resolves resources directly from the linked files.
Copy link
Copy Markdown
Member

@natessilva natessilva left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@hellokirk hellokirk merged commit cc84c6d into main May 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants