Repository navigation
Support Angular 21 - #2
Merged
Merged
Conversation
The `enableTemplateSourceLocations` compiler option only exists since Angular
22.1.4. Before that, the compiler has the same feature behind
`setEnableTemplateSourceLocations()`, a function that `@angular/compiler`
exports for Angular's own tests, and the runtime writes the same attribute.
- New `ngx-source-inspector/enable-source-locations` entry point, a preload for
`ng serve` that calls that function in the process and the worker thread
that compile the templates:
NODE_OPTIONS="--import ngx-source-inspector/enable-source-locations" ng serve
It only does something for the dev server, so a production build stays clean
even when NODE_OPTIONS is set for it too.
- `ng add` looks at the installed Angular version: with the compiler option it
does what it did before, without it it only adds the provider and prints the
command above.
- The peer dependencies accept Angular 21 and 22.
CI sets up a new Angular 21 app with `ng add` and checks that `ng serve` with
the preload produces source locations and that a production build doesn't.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aminesbdev
force-pushed
the
angular-21
branch
from
October 13, 2026 12:14
57a2034 to
c2adb58
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The package only accepted Angular 22.2, because the
enableTemplateSourceLocationscompiler option only exists since 22.1.4. Angular 21 has the same feature in the compiler and the same attribute at runtime, but the only switch issetEnableTemplateSourceLocations(), a function that@angular/compilerexports for Angular's own tests.What changes
New entry point
ngx-source-inspector/enable-source-locations, a preload forng servethat calls that function in the process and in the worker thread that compile the templates:NODE_OPTIONS="--import ngx-source-inspector/enable-source-locations" ng serveIt only does something for the dev server (
ng serve,ng s,ng dev, aservetarget), so a production build stays clean even whenNODE_OPTIONSis set for it too. On Angular versions that have the compiler option it does nothing and says so.ng addlooks at the installed Angular version. With the compiler option it does what it did before. Without it, it only adds the provider and prints the command above. It doesn't touch thestartscript, since theVAR=value commandsyntax isn't portable to Windows.Peer dependencies accept
>=21.0.0 <23.0.0, and the version goes to 0.2.0.How it was checked
ng addpath.npm run check:angular-21, also run in CI: sets up a new Angular 21 app withng add, checks thatng servewith the preload produces source locations and that a production build with the sameNODE_OPTIONScontains none.<app-root> · src/app/app.html:235:7on the<h1>of the new app, and Alt+click calls the editor with that file, line and column.Not checked: Windows, and Angular 21.0, 21.1 and 22.0 to 22.1.3.
🤖 Generated with Claude Code