build: require Angular 21.2 and compile with its toolchain - #3763
armando-navarro wants to merge 2 commits into
Conversation
Angular 21 is in long-term support.
… module type field ng-packagr 21.2 adds "type": "module" to the generated package.json, which breaks the CommonJS schematics bundles at require time. The build now deletes the field and its schematics-load check runs after the deletion.
tyler-reitz
left a comment
There was a problem hiding this comment.
Built both heads and ran the regression by hand. The change does what the body says. One thing to fix before merge, the rest is comment-level.
Fix first: docs/version-21-upgrade.md:82 still reads "AngularFire 21 peers @angular/* ^21.0.0", so it ships contradicting the new src/package.json, in the guide specifically about this constraint.
The load guard is Node-dependent. Re-adding "type": "module" to the built manifest and requiring the six entry points:
| Node | Result |
|---|---|
| 18.20.8 | throws ERR_REQUIRE_ESM |
| 20.20.2 / 22.15.0 / 24.14.1 | throws module is not defined in ES module scope |
| 26.7.0 | no throw; all six export {} |
It holds on CI, but engines >=24.0.0 admits 26, where loadCompiledSchematics passes silently because it only catches throws. Asserting the loaded module has exports closes that.
Concurrent writers on the built manifest. buildLibrary runs compileSchematics() (now calling dropEsModulePackageType) and replacePackageCoreVersion() in one Promise.all (tools/build.ts:454-460), and both read-modify-write dist/packages-dist/package.json. The ordering holds today only because compileSchematics is slower, and both inversions fail silently: the type field survives, or ANGULARFIRE2_VERSION ships as the version. Awaiting replacePackageCoreVersion() before the Promise.all costs nothing. Inferred from the code, not reproduced.
"Byte-identical" overstates it, though the conclusion holds. Diffing clean builds of c8aebe1 and 5b3112a: 67 files differ, all either the partial-compile version: stamp (21.0.0 to 21.2.22) or .d.ts import reordering. Public surface unchanged.
Nit: @schematics/angular stays at ^21.0.0 while its siblings move. It resolves to 21.2.23 so it's harmless, just unexplained next to the @angular-eslint note.
Checklist
yarn install,yarn testrun successfully?: yesDescription
Raises the minimum supported Angular to 21.2, the final 21.x minor line. Angular 21 is in long-term support, which receives only critical fixes and security patches, so
^21.2.0admits every 21.x release still to come. The raise is release coordination for the TransferState work (#3757), whose signal-based reading functions build onresourceFromSnapshots, absent from@angular/coreuntil 21.2.Changes
src/package.jsonmove to^21.2.0.^21.2.0,@angular-devkit/architectmoves to~0.2102.0because the 21.2 CLI needs a devkit version the old~0.2100.0range rejects (lockfile regenerated).@angular-eslintentries stay at^21.0.0, since that project's 21.x minors do not track Angular's."type": "module"field thatng-packagr21.2 adds topackage.json(a default introduced in ng-packagr#3263).ng addandng deploy.Verification
package.jsoncarries notypefield.^20.19.0 || ^22.12.0 || >=24.0.0, which CI's Node 20, 22 and 24 matrix satisfies.@angular/core21.2.18, so it needs no change to satisfy the new peer range.