Skip to content

feat(schematics): ng-add for custom-esbuild/webpack + jest migration schematics#2241

Closed
just-jeb wants to merge 5 commits into
masterfrom
feat/schematics-bundle
Closed

feat(schematics): ng-add for custom-esbuild/webpack + jest migration schematics#2241
just-jeb wants to merge 5 commits into
masterfrom
feat/schematics-bundle

Conversation

@just-jeb
Copy link
Copy Markdown
Owner

@just-jeb just-jeb commented May 18, 2026

PR Checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Users must manually update angular.json and package.json when adding @angular-builders/custom-esbuild or @angular-builders/custom-webpack to their project. Users upgrading @angular-builders/jest across major versions have no automated migration support.

Issue Number: N/A

What is the new behavior?

Three additive schematics features. Targeted at the next major aligned with Angular 22 (not yet released) — see "Versioning" below.

Commit 1: feat(custom-esbuild): add ng-add schematic

ng add @angular-builders/custom-esbuild now:

  • Rewrites architect.build.builder in angular.json to @angular-builders/custom-esbuild:application
  • Adds @angular-builders/custom-esbuild to devDependencies in package.json
  • Schedules NodePackageInstallTask (skippable via --skipInstall)

New files: src/schematics/collection.json, src/schematics/ng-add/{index.ts,schema.json,schema.ts}, tsconfig.schematics.json. Mirrors the jest ng-add schematic from #2240.

Commit 2: feat(custom-webpack): add ng-add schematic

Same structure as commit 1, for @angular-builders/custom-webpack:

  • Rewrites architect.build.builder to @angular-builders/custom-webpack:browser
  • Adds @angular-builders/custom-webpack to devDependencies
  • Schedules NodePackageInstallTask

Commit 3: feat(jest): add ng-update migration schematics v18-v21

ng update @angular-builders/jest now applies migrations across the v18→v21 chain:

Migration Version jump What it does
v18 v17→v18 Updates tsconfig.spec.json types from jasmine to jest; emits guidance on setup file rename
v19 v18→v19 Emits guidance on the zone.js setup change to explicit setupZoneTestEnv()
v20 v19→v20 No-op (no breaking changes; completes the migration chain)
v21 v20→v21 Sets zoneless: false in angular.json for projects using the jest builder (v21 defaults to zoneless: true); warns about removed global mocks

New files: src/schematics/migrations.json, src/schematics/migrations/{v18,v19,v20,v21}/index.ts, tsconfig.schematics.json.

Implementation notes

  • All schematics compile with a separate tsconfig.schematics.json (CommonJS, Node moduleResolution) and are copied to dist/schematics/ as part of each package's build.
  • The custom-esbuild/custom-webpack schema.ts files for schematics are hand-authored (quicktype only generates the builder option schemas, not schematics schemas) and kept in sync manually.
  • tsconfig.schematics.json uses ignoreDeprecations: "6.0" to allow moduleResolution: Node, required by @angular-devkit/schematics; the repo root tsconfig uses Node16, which is incompatible with Angular's schematics runtime.
  • custom-esbuild and custom-webpack .gitignore add a !src/schematics/**/schema.json exception (those packages ignore **/schema.json globally because builder schemas are generated at build time).

Versioning

The schematics are purely additive (no existing builder behaviour changes), but they are intended to land with the v22-aligned major rather than the current 21.x line, so the ng-add/ng-update surface ships together with the Angular 22 support. Should be merged after #2240 (shared packages/jest/package.json and jest tsconfig.schematics.json edits will need a rebase).

Does this PR introduce a breaking change?

[ ] Yes
[x] No

New schematics are purely additive. No existing builder behaviour is changed.

just-jeb added 5 commits May 31, 2026 21:16
Adds an ng-add schematic so users can run `ng add @angular-builders/custom-esbuild`
to automatically configure their Angular workspace. The schematic:
- Rewrites architect.build.builder in angular.json to @angular-builders/custom-esbuild:application
- Adds @angular-builders/custom-esbuild to devDependencies in package.json
- Schedules NodePackageInstallTask (skippable via skipInstall option)

Also adds tsconfig.schematics.json for separate schematics compilation and
updates the build script to compile and copy schematics artifacts.
Adds an ng-add schematic so users can run `ng add @angular-builders/custom-webpack`
to automatically configure their Angular workspace. The schematic:
- Rewrites architect.build.builder in angular.json to @angular-builders/custom-webpack:browser
- Adds @angular-builders/custom-webpack to devDependencies in package.json
- Schedules NodePackageInstallTask (skippable via skipInstall option)

Also adds tsconfig.schematics.json for separate schematics compilation and
updates the build script to compile and copy schematics artifacts.
Adds ng-update migrations so users running `ng update @angular-builders/jest`
get automated help with the breaking changes across four major version bumps:

- v18: switch tsconfig.spec.json from jasmine to jest types; guidance on
  setup file rename (jest-preset-angular -> jest-preset-angular/setup-jest)
- v19: guidance on zone.js setup change to explicit setupZoneTestEnv() call
- v20: no-op (no breaking changes in v20)
- v21: set zoneless: false in angular.json for apps still using zone.js
  (v21 defaults to zoneless: true); warn about removed global mocks
  (styleTransform, getComputedStyle, doctype removed as Jest 30 jsdom handles them)

Adds tsconfig.schematics.json for migrations compilation, updates the build
script to compile and copy migration artifacts, and registers migrations.json
under the ng-update key in package.json.
@just-jeb just-jeb force-pushed the feat/schematics-bundle branch from 66a1217 to 31c96fd Compare May 31, 2026 19:16
@just-jeb
Copy link
Copy Markdown
Owner Author

just-jeb commented Jun 3, 2026

Superseded by #2267, which consolidates ng-add/ng-update schematics for all builders (jest, custom-esbuild, custom-webpack) in a single PR targeting release/v22.

@just-jeb just-jeb closed this Jun 3, 2026
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.

1 participant