fix(schematics): declare the runtime dependencies the schematics bundle requires - #3747
fix(schematics): declare the runtime dependencies the schematics bundle requires#3747armando-navarro wants to merge 1 commit into
Conversation
…le requires The shipped schematics require jsonc-parser, @angular-devkit/core, and @angular-devkit/architect at runtime, but the published manifest never declared them. The first two resolve today only because npm hoists them from the declared @angular-devkit/schematics and @schematics/angular. Architect is worse: it is not in the package's dependency closure at all and resolves from the app's own @angular/cli install, so ng deploy breaks under pnpm's strict layout or Yarn PnP. The architect range is the comparator pair matching its 0.YYMM version scheme. A caret on a 0.x version would lock consumers to Angular 21.0.x. Also prunes the ng-packagr allowlist to the seven names actually declared, dropping ten entries for dependencies removed long ago and a duplicate @schematics/angular.
tyler-reitz
left a comment
There was a problem hiding this comment.
Approved. I checked this the direct way rather than by reading: built the package on the branch and enumerated every bare require() in dist/packages-dist/schematics/**/*.js against the dist manifest. After this change the set is fully covered, and it matches esbuild's external list at tools/build.ts:349-360 exactly, which is why the bundled-in packages need no declaration. Your hoisting claim holds too: @angular-devkit/schematics and @schematics/angular each depend on @angular-devkit/core and jsonc-parser, and neither pulls architect. 156 specs green here as well.
One thing for later: the architect cap < 0.2200.0 and core's ^21.0.0 both need a manual bump at Angular 22, and nothing tracks src/package.json ranges. The only guard on that file is the comment at src/schematics/common.ts:75 for the firebase range, so this makes a third range that goes stale quietly.
Checklist
requirecalls for all three packages in the built schematics bundles.yarn install,yarn testrun successfully?: yesDescription
Fixes #3746.
The shipped schematics
requirejsonc-parser,@angular-devkit/core, and@angular-devkit/architectat runtime, but the published manifest never declared them. The first two resolve today only because npm hoists them from the declared@angular-devkit/schematicsand@schematics/angular. Architect is not in the package's dependency closure at all and resolves from the app's own@angular/cliinstall, song deploybreaks under pnpm's isolated layout or Yarn Plug'n'Play.The architect range (
>= 0.2100.0 < 0.2200.0) is the comparator pair matching its0.YYMMversion scheme, the same shape other packages shipping architect builders use. A caret on a0.xversion would restrict consumers to Angular 21.0.x only.The change also prunes
allowedNonPeerDependenciesinsrc/ng-package.jsonto the seven names actually declared, dropping ten entries for dependencies removed long ago and a duplicate@schematics/angularentry.Refs #3694: that issue proposes moving schematic dependencies out of
dependenciesentirely. This fix runs the other way in the short term because the shipped bundles genuinely require these packages at runtime, so leaving them undeclared is a correctness bug today. The structural question of where schematic dependencies should live stays open in #3694.