Skip to content

fix(angular): error on unresolved templateUrl/styleUrl instead of silent passthrough#336

Merged
Brooooooklyn merged 2 commits into
voidzero-dev:mainfrom
mvanhorn:fix/314-loud-resource-resolution-failure
Jun 7, 2026
Merged

fix(angular): error on unresolved templateUrl/styleUrl instead of silent passthrough#336
Brooooooklyn merged 2 commits into
voidzero-dev:mainfrom
mvanhorn:fix/314-loud-resource-resolution-failure

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Jun 4, 2026

Summary

An unresolved templateUrl or styleUrl now produces a hard error diagnostic (COMPONENT_RESOURCE_NOT_FOUND, naming the component class and the resource) instead of a silent passthrough. The diagnostic flows through the existing result.diagnostics -> NAPI result.errors path, so vite/esbuild builds fail loudly rather than shipping a class without its ɵcmp/ɵfac.

Why this matters

#314: when resource resolution fails, OXC returned the source unchanged - "the build 'succeeds,' ng dev/build prints no warning, and the breakage only shows up at runtime as an uninstantiable component." ngc raises a clear diagnostic in the same situation.

Two changes in crates/oxc_angular_compiler/src/component/transform.rs:

  • the unresolved-templateUrl branch upgrades its vague warning ("Template URL '...' not found in resolved resources") to an error carrying the ngc-style code, the class name, and an explicit note that the component was emitted without its compiled definition
  • resolve_styles now reports styleUrls that were missing from the provided resources (previously dropped silently), and each missing one surfaces the same COMPONENT_RESOURCE_NOT_FOUND error; when no resources are passed at all, style behavior is unchanged

This covers the loud-failure bar from the issue's "Required work" item 1. Item 2 (graceful folding of unresolvable ${...} template-literal references) is a separate codepath and is left for a follow-up so this stays reviewable.

Testing

  • New unresolved_templateurl_is_a_hard_error and unresolved_styleurl_is_a_hard_error regression tests in class_metadata_resources_test.rs assert has_errors(), the error code, and that the message names the class and resource
  • test_multi_component_external_template_unique_const_names now supplies its declared fab.css resource - under the new semantics its previously half-resolved fixture correctly errored, which is the behavior change working as intended
  • Full cargo test -p oxc_angular_compiler: 2700 passed, 0 failed; cargo fmt --check clean
  • The existing NAPI test should handle external template URLs with warning already asserts result.errors.length > 0 for the unresolved case and is unaffected (all diagnostics map to errors)

Fixes #314

@Brooooooklyn
Copy link
Copy Markdown
Member

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16bbfe11ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_angular_compiler/src/component/transform.rs Outdated
@mvanhorn
Copy link
Copy Markdown
Contributor Author

mvanhorn commented Jun 6, 2026

Good catch - this was real. Fixed in fd9d335: resolve_template now reports a missing templateUrl to the caller instead of falling back to the inline template when resources were provided, so the COMPONENT_RESOURCE_NOT_FOUND error fires for that shape too. Added a regression test (templateUrl + inline template + resources without the URL => diagnostic, inline not compiled). When no resource resolver is provided at all, the inline fallback is unchanged.

@Brooooooklyn Brooooooklyn merged commit d9143e6 into voidzero-dev:main Jun 7, 2026
9 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.

fix(transform): surface a diagnostic when templateUrl/inline-template resolution fails (currently bails silently)

2 participants