@schematics/angular 20.0.0 → 20.0.1

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.
@@ -121,6 +121,13 @@ function addDependenciesToPackageJson(options) {
121
121
  version: latest_versions_1.latestVersions['typescript'],
122
122
  },
123
123
  ].forEach((dependency) => (0, dependencies_1.addPackageJsonDependency)(host, dependency));
124
+ if (!options.zoneless) {
125
+ (0, dependencies_1.addPackageJsonDependency)(host, {
126
+ type: dependencies_1.NodeDependencyType.Default,
127
+ name: 'zone.js',
128
+ version: latest_versions_1.latestVersions['zone.js'],
129
+ });
130
+ }
124
131
  if (!options.skipInstall) {
125
132
  context.addTask(new tasks_1.NodePackageInstallTask());
126
133
  }
package/library/index.js CHANGED
@@ -72,7 +72,7 @@ function addDependenciesToPackageJson() {
72
72
  return host;
73
73
  };
74
74
  }
75
- function addLibToWorkspaceFile(options, projectRoot, projectName) {
75
+ function addLibToWorkspaceFile(options, projectRoot, projectName, hasZoneDependency) {
76
76
  return (0, workspace_1.updateWorkspace)((workspace) => {
77
77
  workspace.projects.add({
78
78
  name: projectName,
@@ -97,7 +97,7 @@ function addLibToWorkspaceFile(options, projectRoot, projectName) {
97
97
  builder: workspace_models_1.Builders.BuildKarma,
98
98
  options: {
99
99
  tsConfig: `${projectRoot}/tsconfig.spec.json`,
100
- polyfills: ['zone.js', 'zone.js/testing'],
100
+ polyfills: hasZoneDependency ? ['zone.js', 'zone.js/testing'] : undefined,
101
101
  },
102
102
  },
103
103
  },
@@ -139,9 +139,10 @@ function default_1(options) {
139
139
  }),
140
140
  (0, schematics_1.move)(libDir),
141
141
  ]);
142
+ const hasZoneDependency = (0, dependencies_1.getPackageJsonDependency)(host, 'zone.js') !== null;
142
143
  return (0, schematics_1.chain)([
143
144
  (0, schematics_1.mergeWith)(templateSource),
144
- addLibToWorkspaceFile(options, libDir, packageName),
145
+ addLibToWorkspaceFile(options, libDir, packageName, hasZoneDependency),
145
146
  options.skipPackageJson ? (0, schematics_1.noop)() : addDependenciesToPackageJson(),
146
147
  options.skipTsConfig ? (0, schematics_1.noop)() : updateTsConfig(packageName, './' + distRoot),
147
148
  options.skipTsConfig
@@ -163,6 +163,7 @@ function updateProjects(tree, context) {
163
163
  }
164
164
  // Use @angular/build directly if there is no devkit package usage
165
165
  if (!hasAngularDevkitUsage) {
166
+ const karmaConfigFiles = new Set();
166
167
  for (const [, target] of (0, workspace_1.allWorkspaceTargets)(workspace)) {
167
168
  switch (target.builder) {
168
169
  case workspace_models_1.Builders.Application:
@@ -176,9 +177,14 @@ function updateProjects(tree, context) {
176
177
  break;
177
178
  case workspace_models_1.Builders.Karma:
178
179
  target.builder = '@angular/build:karma';
179
- // Remove "builderMode" option since the builder will always use "application"
180
180
  for (const [, karmaOptions] of (0, workspace_1.allTargetOptions)(target)) {
181
+ // Remove "builderMode" option since the builder will always use "application"
181
182
  delete karmaOptions['builderMode'];
183
+ // Collect custom karma configurations for @angular-devkit/build-angular plugin removal
184
+ const karmaConfig = karmaOptions['karmaConfig'];
185
+ if (karmaConfig && typeof karmaConfig === 'string') {
186
+ karmaConfigFiles.add(karmaConfig);
187
+ }
182
188
  }
183
189
  break;
184
190
  case workspace_models_1.Builders.NgPackagr:
@@ -214,6 +220,29 @@ function updateProjects(tree, context) {
214
220
  existing: dependency_1.ExistingBehavior.Replace,
215
221
  }));
216
222
  }
223
+ for (const karmaConfigFile of karmaConfigFiles) {
224
+ if (!tree.exists(karmaConfigFile)) {
225
+ continue;
226
+ }
227
+ try {
228
+ const originalKarmaConfigText = tree.readText(karmaConfigFile);
229
+ const updatedKarmaConfigText = originalKarmaConfigText
230
+ .replaceAll(`require('@angular-devkit/build-angular/plugins/karma'),`, '')
231
+ .replaceAll(`require('@angular-devkit/build-angular/plugins/karma')`, '');
232
+ if (updatedKarmaConfigText.includes('@angular-devkit/build-angular/plugins')) {
233
+ throw new Error('Migration does not support found usage of "@angular-devkit/build-angular".');
234
+ }
235
+ else {
236
+ tree.overwrite(karmaConfigFile, updatedKarmaConfigText);
237
+ }
238
+ }
239
+ catch (error) {
240
+ const reason = error instanceof Error ? `Reason: ${error.message}` : '';
241
+ context.logger.warn(`Unable to update custom karma configuration file ("${karmaConfigFile}"). ` +
242
+ reason +
243
+ '\nReferences to the "@angular-devkit/build-angular" package within the file may need to be removed manually.');
244
+ }
245
+ }
217
246
  }
218
247
  return (0, schematics_1.chain)(rules);
219
248
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "20.0.0",
3
+ "version": "20.0.1",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "schematics": "./collection.json",
24
24
  "dependencies": {
25
- "@angular-devkit/core": "20.0.0",
26
- "@angular-devkit/schematics": "20.0.0",
25
+ "@angular-devkit/core": "20.0.1",
26
+ "@angular-devkit/schematics": "20.0.1",
27
27
  "jsonc-parser": "3.3.1"
28
28
  },
29
29
  "repository": {
@@ -63,9 +63,15 @@ class JSONFile {
63
63
  tabSize: 2,
64
64
  },
65
65
  });
66
- this.content = (0, jsonc_parser_1.applyEdits)(this.content, edits);
67
- this.host.overwrite(this.path, this.content);
68
- this._jsonAst = undefined;
66
+ if (edits.length > 0) {
67
+ const editedContent = (0, jsonc_parser_1.applyEdits)(this.content, edits);
68
+ // Update the file content if it changed
69
+ if (editedContent !== this.content) {
70
+ this.content = editedContent;
71
+ this.host.overwrite(this.path, editedContent);
72
+ this._jsonAst = undefined;
73
+ }
74
+ }
69
75
  }
70
76
  remove(jsonPath) {
71
77
  if (this.get(jsonPath) !== undefined) {
@@ -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: '^20.0.0',
18
18
  NgPackagr: '^20.0.0',
19
- DevkitBuildAngular: '^20.0.0',
20
- AngularBuild: '^20.0.0',
21
- AngularSSR: '^20.0.0',
19
+ DevkitBuildAngular: '^20.0.1',
20
+ AngularBuild: '^20.0.1',
21
+ AngularSSR: '^20.0.1',
22
22
  };
@@ -17,8 +17,7 @@
17
17
  "@angular/platform-browser": "<%= latestVersions.Angular %>",
18
18
  "@angular/router": "<%= latestVersions.Angular %>",
19
19
  "rxjs": "<%= latestVersions['rxjs'] %>",
20
- "tslib": "<%= latestVersions['tslib'] %>",
21
- "zone.js": "<%= latestVersions['zone.js'] %>"
20
+ "tslib": "<%= latestVersions['tslib'] %>"
22
21
  },
23
22
  "devDependencies": {
24
23
  "@angular/cli": "<%= '^' + version %>",