@schematics/angular 21.0.0-next.4 → 21.0.0-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { NgModule, provideBrowserGlobalErrorListeners<% if(zoneless) { %>, provideZonelessChangeDetection<% } %> } from '@angular/core';
1
+ import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core';
2
2
  import { BrowserModule } from '@angular/platform-browser';
3
3
  <% if (routing) { %>
4
4
  import { AppRoutingModule } from './app-routing-module';<% } %>
@@ -13,8 +13,7 @@ import { App } from './app';
13
13
  AppRoutingModule<% } %>
14
14
  ],
15
15
  providers: [
16
- provideBrowserGlobalErrorListeners()<% if (zoneless) { %>,
17
- provideZonelessChangeDetection()<% } %>
16
+ provideBrowserGlobalErrorListeners()
18
17
  ],
19
18
  bootstrap: [App]
20
19
  })
@@ -1,5 +1,4 @@
1
- <% if(zoneless) { %>import { provideZonelessChangeDetection } from '@angular/core';
2
- <% } %>import { TestBed } from '@angular/core/testing';<% if (routing) { %>
1
+ import { TestBed } from '@angular/core/testing';<% if (routing) { %>
3
2
  import { RouterModule } from '@angular/router';<% } %>
4
3
  import { App } from './app';
5
4
 
@@ -11,8 +10,7 @@ describe('App', () => {
11
10
  ],<% } %>
12
11
  declarations: [
13
12
  App
14
- ],<% if(zoneless) { %>
15
- providers: [provideZonelessChangeDetection()]<% } %>
13
+ ],
16
14
  }).compileComponents();
17
15
  });
18
16
 
@@ -1,12 +1,12 @@
1
- import { ApplicationConfig, provideBrowserGlobalErrorListeners, <% if(!zoneless) { %>provideZoneChangeDetection<% } else { %>provideZonelessChangeDetection<% } %> } from '@angular/core';<% if (routing) { %>
1
+ import { ApplicationConfig, provideBrowserGlobalErrorListeners<% if(!zoneless) { %>, provideZoneChangeDetection<% } %> } from '@angular/core';<% if (routing) { %>
2
2
  import { provideRouter } from '@angular/router';
3
3
 
4
4
  import { routes } from './app.routes';<% } %>
5
5
 
6
6
  export const appConfig: ApplicationConfig = {
7
7
  providers: [
8
- provideBrowserGlobalErrorListeners(),
9
- <% if(zoneless) { %>provideZonelessChangeDetection()<% } else { %>provideZoneChangeDetection({ eventCoalescing: true })<% } %>,
8
+ provideBrowserGlobalErrorListeners(),<% if(!zoneless) { %>
9
+ provideZoneChangeDetection({ eventCoalescing: true }),<% } %>
10
10
  <% if (routing) {%>provideRouter(routes)<% } %>
11
11
  ]
12
12
  };
@@ -1,12 +1,10 @@
1
- <% if(zoneless) { %>import { provideZonelessChangeDetection } from '@angular/core';
2
- <% } %>import { TestBed } from '@angular/core/testing';
1
+ import { TestBed } from '@angular/core/testing';
3
2
  import { App } from './app';
4
3
 
5
4
  describe('App', () => {
6
5
  beforeEach(async () => {
7
6
  await TestBed.configureTestingModule({
8
- imports: [App],<% if(zoneless) { %>
9
- providers: [provideZonelessChangeDetection()]<% } %>
7
+ imports: [App],
10
8
  }).compileComponents();
11
9
  });
12
10
 
@@ -126,7 +126,7 @@
126
126
  "description": "Generate an application that does not use `zone.js`.",
127
127
  "x-prompt": "Do you want to create a 'zoneless' application without zone.js?",
128
128
  "type": "boolean",
129
- "default": false
129
+ "default": true
130
130
  },
131
131
  "fileNameStyleGuide": {
132
132
  "type": "string",
@@ -13,6 +13,11 @@
13
13
  "version": "21.0.0",
14
14
  "factory": "./karma/migration",
15
15
  "description": "Remove any karma configuration files that only contain the default content. The default configuration is automatically available without a specific project file."
16
+ },
17
+ "update-typescript-lib": {
18
+ "version": "21.0.0",
19
+ "factory": "./update-typescript-lib/migration",
20
+ "description": "Updates the 'lib' property in tsconfig files to use 'es2022' or a more modern version."
16
21
  }
17
22
  }
18
23
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ export default function (): Rule;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.default = default_1;
11
+ const json_file_1 = require("../../utility/json-file");
12
+ const workspace_1 = require("../../utility/workspace");
13
+ function default_1() {
14
+ return async (host, context) => {
15
+ // Workspace level tsconfig
16
+ if (host.exists('tsconfig.json')) {
17
+ updateLib(host, 'tsconfig.json');
18
+ }
19
+ const workspace = await (0, workspace_1.getWorkspace)(host);
20
+ // Find all tsconfig which are references used by builders
21
+ for (const [, project] of workspace.projects) {
22
+ for (const [targetName, target] of project.targets) {
23
+ if (!target.options) {
24
+ continue;
25
+ }
26
+ // Update all other known CLI builders that use a tsconfig
27
+ const tsConfigs = [target.options, ...Object.values(target.configurations || {})]
28
+ .filter((opt) => typeof opt?.tsConfig === 'string')
29
+ .map((opt) => opt.tsConfig);
30
+ const uniqueTsConfigs = new Set(tsConfigs);
31
+ for (const tsConfig of uniqueTsConfigs) {
32
+ if (host.exists(tsConfig)) {
33
+ updateLib(host, tsConfig);
34
+ }
35
+ else {
36
+ context.logger.warn(`'${tsConfig}' referenced in the '${targetName}' target does not exist.`);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ };
42
+ }
43
+ function updateLib(host, tsConfigPath) {
44
+ const json = new json_file_1.JSONFile(host, tsConfigPath);
45
+ const jsonPath = ['compilerOptions', 'lib'];
46
+ const lib = json.get(jsonPath);
47
+ if (!lib || !Array.isArray(lib)) {
48
+ return;
49
+ }
50
+ const esLibs = lib.filter((l) => typeof l === 'string' && l.toLowerCase().startsWith('es'));
51
+ const hasDom = lib.some((l) => typeof l === 'string' && l.toLowerCase() === 'dom');
52
+ if (esLibs.length === 0) {
53
+ return;
54
+ }
55
+ const esLibToVersion = new Map();
56
+ for (const l of esLibs) {
57
+ const version = l.toLowerCase().match(/^es(next|(\d+))$/)?.[1];
58
+ if (version) {
59
+ esLibToVersion.set(l, version === 'next' ? Infinity : Number(version));
60
+ }
61
+ }
62
+ if (esLibToVersion.size === 0) {
63
+ return;
64
+ }
65
+ const latestEsLib = [...esLibToVersion.entries()].sort(([, v1], [, v2]) => v2 - v1)[0];
66
+ const latestVersion = latestEsLib[1];
67
+ if (hasDom) {
68
+ if (latestVersion <= 2022) {
69
+ json.remove(jsonPath);
70
+ }
71
+ return;
72
+ }
73
+ // No 'dom' with 'es' libs, so update 'es' lib.
74
+ if (latestVersion < 2022) {
75
+ const newLibs = lib.filter((l) => !esLibToVersion.has(l));
76
+ newLibs.push('es2022');
77
+ json.modify(jsonPath, newLibs);
78
+ }
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "21.0.0-next.4",
3
+ "version": "21.0.0-next.5",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -22,15 +22,15 @@
22
22
  },
23
23
  "schematics": "./collection.json",
24
24
  "dependencies": {
25
- "@angular-devkit/core": "21.0.0-next.4",
26
- "@angular-devkit/schematics": "21.0.0-next.4",
25
+ "@angular-devkit/core": "21.0.0-next.5",
26
+ "@angular-devkit/schematics": "21.0.0-next.5",
27
27
  "jsonc-parser": "3.3.1"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
31
31
  "url": "https://github.com/angular/angular-cli.git"
32
32
  },
33
- "packageManager": "pnpm@10.17.0",
33
+ "packageManager": "pnpm@10.17.1",
34
34
  "engines": {
35
35
  "node": "^20.19.0 || ^22.12.0 || >=24.0.0",
36
36
  "npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
@@ -1,5 +1,3 @@
1
- import 'zone.js/node';
2
-
3
1
  import { APP_BASE_HREF } from '@angular/common';
4
2
  import { CommonEngine } from '@angular/ssr/node';
5
3
  import express from 'express';
@@ -16,7 +16,7 @@ exports.latestVersions = {
16
16
  // As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
17
17
  Angular: '^21.0.0-next.0',
18
18
  NgPackagr: '^21.0.0-next.0',
19
- DevkitBuildAngular: '^21.0.0-next.4',
20
- AngularBuild: '^21.0.0-next.4',
21
- AngularSSR: '^21.0.0-next.4',
19
+ DevkitBuildAngular: '^21.0.0-next.5',
20
+ AngularBuild: '^21.0.0-next.5',
21
+ AngularSSR: '^21.0.0-next.5',
22
22
  };
@@ -36,6 +36,7 @@ yarn-error.log
36
36
  /libpeerconnection.log
37
37
  testem.log
38
38
  /typings
39
+ __screenshots__/
39
40
 
40
41
  # System files
41
42
  .DS_Store
@@ -21,6 +21,7 @@
21
21
  ]
22
22
  },
23
23
  "private": true,
24
+ <% if (packageManagerWithVersion) { %>"packageManager": "<%= packageManagerWithVersion %>",<% } %>
24
25
  "dependencies": {
25
26
  "@angular/common": "<%= latestVersions.Angular %>",
26
27
  "@angular/compiler": "<%= latestVersions.Angular %>",
@@ -9,15 +9,40 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.default = default_1;
11
11
  const schematics_1 = require("@angular-devkit/schematics");
12
+ const node_child_process_1 = require("node:child_process");
12
13
  const latest_versions_1 = require("../utility/latest-versions");
13
14
  function default_1(options) {
14
- return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
15
- options.minimal ? (0, schematics_1.filter)((path) => !path.endsWith('editorconfig.template')) : (0, schematics_1.noop)(),
16
- (0, schematics_1.applyTemplates)({
17
- utils: schematics_1.strings,
18
- ...options,
19
- 'dot': '.',
20
- latestVersions: latest_versions_1.latestVersions,
21
- }),
22
- ]));
15
+ return () => {
16
+ const packageManager = options.packageManager;
17
+ let packageManagerWithVersion;
18
+ if (packageManager) {
19
+ let packageManagerVersion;
20
+ try {
21
+ packageManagerVersion = (0, node_child_process_1.execSync)(`${packageManager} --version`, {
22
+ encoding: 'utf8',
23
+ stdio: 'pipe',
24
+ env: {
25
+ ...process.env,
26
+ // NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
27
+ NO_UPDATE_NOTIFIER: '1',
28
+ NPM_CONFIG_UPDATE_NOTIFIER: 'false',
29
+ },
30
+ }).trim();
31
+ }
32
+ catch { }
33
+ if (packageManagerVersion) {
34
+ packageManagerWithVersion = `${packageManager}@${packageManagerVersion}`;
35
+ }
36
+ }
37
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
38
+ options.minimal ? (0, schematics_1.filter)((path) => !path.endsWith('editorconfig.template')) : (0, schematics_1.noop)(),
39
+ (0, schematics_1.applyTemplates)({
40
+ utils: schematics_1.strings,
41
+ ...options,
42
+ 'dot': '.',
43
+ latestVersions: latest_versions_1.latestVersions,
44
+ packageManagerWithVersion,
45
+ }),
46
+ ]));
47
+ };
23
48
  }
@@ -40,7 +40,10 @@
40
40
  "packageManager": {
41
41
  "description": "The package manager to use for installing dependencies.",
42
42
  "type": "string",
43
- "enum": ["npm", "yarn", "pnpm", "bun"]
43
+ "enum": ["npm", "yarn", "pnpm", "bun"],
44
+ "$default": {
45
+ "$source": "packageManager"
46
+ }
44
47
  }
45
48
  },
46
49
  "required": ["name", "version"]