@angular/core 21.0.0-next.0 → 21.0.0-next.10

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.
Files changed (106) hide show
  1. package/fesm2022/_attribute-chunk.mjs +12 -0
  2. package/fesm2022/_attribute-chunk.mjs.map +1 -0
  3. package/fesm2022/_debug_node-chunk.mjs +18469 -0
  4. package/fesm2022/_debug_node-chunk.mjs.map +1 -0
  5. package/fesm2022/_effect-chunk.mjs +423 -0
  6. package/fesm2022/_effect-chunk.mjs.map +1 -0
  7. package/fesm2022/_effect-chunk2.mjs +2951 -0
  8. package/fesm2022/_effect-chunk2.mjs.map +1 -0
  9. package/fesm2022/_not_found-chunk.mjs +39 -0
  10. package/fesm2022/_not_found-chunk.mjs.map +1 -0
  11. package/fesm2022/_resource-chunk.mjs +378 -0
  12. package/fesm2022/_resource-chunk.mjs.map +1 -0
  13. package/fesm2022/_untracked-chunk.mjs +96 -0
  14. package/fesm2022/_untracked-chunk.mjs.map +1 -0
  15. package/fesm2022/_weak_ref-chunk.mjs +10 -0
  16. package/fesm2022/_weak_ref-chunk.mjs.map +1 -0
  17. package/fesm2022/core.mjs +2499 -4185
  18. package/fesm2022/core.mjs.map +1 -1
  19. package/fesm2022/primitives-di.mjs +23 -0
  20. package/fesm2022/primitives-di.mjs.map +1 -0
  21. package/fesm2022/primitives-event-dispatch.mjs +788 -0
  22. package/fesm2022/primitives-event-dispatch.mjs.map +1 -0
  23. package/fesm2022/primitives-signals.mjs +187 -0
  24. package/fesm2022/primitives-signals.mjs.map +1 -0
  25. package/fesm2022/rxjs-interop.mjs +210 -308
  26. package/fesm2022/rxjs-interop.mjs.map +1 -1
  27. package/fesm2022/testing.mjs +2309 -3170
  28. package/fesm2022/testing.mjs.map +1 -1
  29. package/package.json +18 -12
  30. package/resources/best-practices.md +56 -0
  31. package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +117 -0
  32. package/schematics/bundles/application-config-core.cjs +84 -0
  33. package/schematics/bundles/{apply_import_manager-DR9xXCle.cjs → apply_import_manager-1Zs_gpB6.cjs} +4 -5
  34. package/schematics/bundles/bootstrap-options-migration.cjs +598 -0
  35. package/schematics/bundles/cleanup-unused-imports.cjs +9 -13
  36. package/schematics/bundles/common-to-standalone-migration.cjs +381 -0
  37. package/schematics/bundles/{compiler_host-BXBP7CE2.cjs → compiler_host-DBwYMlTo.cjs} +10 -11
  38. package/schematics/bundles/control-flow-migration.cjs +122 -119
  39. package/schematics/bundles/{imports-CIX-JgAN.cjs → imports-DP72APSx.cjs} +6 -1
  40. package/schematics/bundles/{index-CfTQUOiz.cjs → index-B7I9sIUx.cjs} +36 -39
  41. package/schematics/bundles/inject-migration.cjs +148 -70
  42. package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
  43. package/schematics/bundles/{migrate_ts_type_references-6NtAj-Wk.cjs → migrate_ts_type_references-UGIUl7En.cjs} +500 -24
  44. package/schematics/bundles/ng_component_template-Dsuq1Lw7.cjs +185 -0
  45. package/schematics/bundles/{ng_decorators-B5HCqr20.cjs → ng_decorators-DSFlWYQY.cjs} +2 -2
  46. package/schematics/bundles/ngclass-to-class-migration.cjs +542 -0
  47. package/schematics/bundles/ngstyle-to-style-migration.cjs +487 -0
  48. package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
  49. package/schematics/bundles/output-migration.cjs +16 -19
  50. package/schematics/bundles/parse_html-8VLCL37B.cjs +132 -0
  51. package/schematics/bundles/{project_paths-DcaODbky.cjs → project_paths-DvD50ouC.cjs} +14 -247
  52. package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +90 -0
  53. package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
  54. package/schematics/bundles/route-lazy-loading.cjs +54 -26
  55. package/schematics/bundles/router-current-navigation.cjs +7 -18
  56. package/schematics/bundles/router-last-successful-navigation.cjs +7 -18
  57. package/schematics/bundles/router-testing-module-migration.cjs +502 -0
  58. package/schematics/bundles/self-closing-tags-migration.cjs +17 -216
  59. package/schematics/bundles/signal-input-migration.cjs +93 -29
  60. package/schematics/bundles/signal-queries-migration.cjs +22 -25
  61. package/schematics/bundles/signals.cjs +10 -13
  62. package/schematics/bundles/standalone-migration.cjs +135 -102
  63. package/schematics/bundles/{symbol-VPWguRxr.cjs → symbol-BObKoqes.cjs} +3 -2
  64. package/schematics/collection.json +23 -0
  65. package/schematics/migrations/common-to-standalone-migration/schema.json +14 -0
  66. package/schematics/migrations/ngclass-to-class-migration/schema.json +20 -0
  67. package/schematics/migrations/ngstyle-to-style-migration/schema.json +20 -0
  68. package/schematics/migrations/router-testing-module-migration/schema.json +14 -0
  69. package/schematics/migrations.json +16 -2
  70. package/{api.d.d.ts → types/_api-chunk.d.ts} +9 -6
  71. package/{chrome_dev_tools_performance.d.d.ts → types/_chrome_dev_tools_performance-chunk.d.ts} +26 -31
  72. package/{discovery.d.d.ts → types/_discovery-chunk.d.ts} +135 -98
  73. package/{signal.d.d.ts → types/_effect-chunk.d.ts} +14 -5
  74. package/{event_dispatcher.d.d.ts → types/_event_dispatcher-chunk.d.ts} +2 -2
  75. package/{graph.d.d.ts → types/_formatter-chunk.d.ts} +40 -7
  76. package/{weak_ref.d.d.ts → types/_weak_ref-chunk.d.ts} +2 -2
  77. package/{index.d.ts → types/core.d.ts} +233 -305
  78. package/{primitives/di/index.d.ts → types/primitives-di.d.ts} +2 -2
  79. package/{primitives/event-dispatch/index.d.ts → types/primitives-event-dispatch.d.ts} +4 -4
  80. package/{primitives/signals/index.d.ts → types/primitives-signals.d.ts} +7 -8
  81. package/{rxjs-interop/index.d.ts → types/rxjs-interop.d.ts} +8 -6
  82. package/{testing/index.d.ts → types/testing.d.ts} +7 -7
  83. package/fesm2022/attribute.mjs +0 -24
  84. package/fesm2022/attribute.mjs.map +0 -1
  85. package/fesm2022/debug_node.mjs +0 -31833
  86. package/fesm2022/debug_node.mjs.map +0 -1
  87. package/fesm2022/not_found.mjs +0 -56
  88. package/fesm2022/not_found.mjs.map +0 -1
  89. package/fesm2022/primitives/di.mjs +0 -23
  90. package/fesm2022/primitives/di.mjs.map +0 -1
  91. package/fesm2022/primitives/event-dispatch.mjs +0 -1622
  92. package/fesm2022/primitives/event-dispatch.mjs.map +0 -1
  93. package/fesm2022/primitives/signals.mjs +0 -89
  94. package/fesm2022/primitives/signals.mjs.map +0 -1
  95. package/fesm2022/resource.mjs +0 -633
  96. package/fesm2022/resource.mjs.map +0 -1
  97. package/fesm2022/root_effect_scheduler.mjs +0 -4007
  98. package/fesm2022/root_effect_scheduler.mjs.map +0 -1
  99. package/fesm2022/signal.mjs +0 -560
  100. package/fesm2022/signal.mjs.map +0 -1
  101. package/fesm2022/untracked.mjs +0 -117
  102. package/fesm2022/untracked.mjs.map +0 -1
  103. package/fesm2022/weak_ref.mjs +0 -12
  104. package/fesm2022/weak_ref.mjs.map +0 -1
  105. package/schematics/bundles/index-esqfDjNB.cjs +0 -22074
  106. package/schematics/bundles/project_tsconfig_paths-CS-eSeHC.cjs +0 -51062
@@ -0,0 +1,381 @@
1
+ 'use strict';
2
+ /**
3
+ * @license Angular v21.0.0-next.10
4
+ * (c) 2010-2025 Google LLC. https://angular.io/
5
+ * License: MIT
6
+ */
7
+ 'use strict';
8
+
9
+ var ts = require('typescript');
10
+ require('@angular/compiler-cli');
11
+ var migrations = require('@angular/compiler-cli/private/migrations');
12
+ require('node:path');
13
+ var project_paths = require('./project_paths-DvD50ouC.cjs');
14
+ var ng_component_template = require('./ng_component_template-Dsuq1Lw7.cjs');
15
+ var ng_decorators = require('./ng_decorators-DSFlWYQY.cjs');
16
+ var apply_import_manager = require('./apply_import_manager-1Zs_gpB6.cjs');
17
+ var imports = require('./imports-DP72APSx.cjs');
18
+ require('@angular-devkit/core');
19
+ require('node:path/posix');
20
+ require('@angular-devkit/schematics');
21
+ require('./project_tsconfig_paths-CDVxT6Ov.cjs');
22
+ require('./property_name-BBwFuqMe.cjs');
23
+
24
+ const commonModuleStr = 'CommonModule';
25
+ const angularCommonStr = '@angular/common';
26
+ const PATTERN_IMPORTS = [
27
+ // Structural directives
28
+ { pattern: /\*ngIf\b/g, imports: ['NgIf'] },
29
+ { pattern: /\*ngFor\b/g, imports: ['NgFor'] },
30
+ { pattern: /\[ngForOf]\b/g, imports: ['NgForOf'] },
31
+ { pattern: /\[ngPlural\]/g, imports: ['NgPlural'] },
32
+ // Match ngPluralCase as structural (*ngPluralCase) or attribute (ngPluralCase="value")
33
+ { pattern: /(\*ngPluralCase\b|\s+ngPluralCase\s*=)/g, imports: ['NgPluralCase'] },
34
+ // Match ngSwitchCase as structural (*ngSwitchCase) or attribute (ngSwitchCase="value")
35
+ { pattern: /(\*ngSwitchCase\b|\s+ngSwitchCase\s*=)/g, imports: ['NgSwitchCase'] },
36
+ // Match ngSwitchDefault as structural (*ngSwitchDefault) or standalone attribute (ngSwitchDefault>)
37
+ { pattern: /(\*ngSwitchDefault\b|\s+ngSwitchDefault(?=\s*>))/g, imports: ['NgSwitchDefault'] },
38
+ { pattern: /\[ngClass\]/g, imports: ['NgClass'] },
39
+ { pattern: /\[ngStyle\]/g, imports: ['NgStyle'] },
40
+ // Match ngSwitch as property binding [ngSwitch] or attribute ngSwitch="value"
41
+ { pattern: /(\[ngSwitch\]|\s+ngSwitch\s*=)/g, imports: ['NgSwitch'] },
42
+ { pattern: /\[ngTemplateOutlet\]/g, imports: ['NgTemplateOutlet'] },
43
+ { pattern: /\[ngComponentOutlet\]/g, imports: ['NgComponentOutlet'] },
44
+ // Common pipes
45
+ { pattern: /\|\s*async\b/g, imports: ['AsyncPipe'] },
46
+ { pattern: /\|\s*json\b/g, imports: ['JsonPipe'] },
47
+ { pattern: /\|\s*date\b/g, imports: ['DatePipe'] },
48
+ { pattern: /\|\s*currency\b/g, imports: ['CurrencyPipe'] },
49
+ { pattern: /\|\s*number\b/g, imports: ['DecimalPipe'] },
50
+ { pattern: /\|\s*percent\b/g, imports: ['PercentPipe'] },
51
+ { pattern: /\|\s*lowercase\b/g, imports: ['LowerCasePipe'] },
52
+ { pattern: /\|\s*uppercase\b/g, imports: ['UpperCasePipe'] },
53
+ { pattern: /\|\s*titlecase\b/g, imports: ['TitleCasePipe'] },
54
+ { pattern: /\|\s*slice\b/g, imports: ['SlicePipe'] },
55
+ { pattern: /\|\s*keyvalue\b/g, imports: ['KeyValuePipe'] },
56
+ { pattern: /\|\s*i18nPlural\b/g, imports: ['I18nPluralPipe'] },
57
+ { pattern: /\|\s*i18nSelect\b/g, imports: ['I18nSelectPipe'] },
58
+ ];
59
+ function analyzeTemplateWithRegex(template, neededImports) {
60
+ PATTERN_IMPORTS.forEach(({ pattern, imports }) => {
61
+ // Reset regex lastIndex to avoid state issues with global flag
62
+ pattern.lastIndex = 0;
63
+ if (pattern.test(template)) {
64
+ imports.forEach((imp) => neededImports.add(imp));
65
+ }
66
+ });
67
+ }
68
+ function migrateCommonModuleUsage(template, componentNode, typeChecker) {
69
+ const analysis = analyzeTemplateContent(template);
70
+ const hasCommonModule = hasCommonModuleInImports(componentNode, typeChecker);
71
+ return {
72
+ migrated: template,
73
+ changed: hasCommonModule,
74
+ replacementCount: hasCommonModule ? 1 : 0,
75
+ canRemoveCommonModule: hasCommonModule,
76
+ neededImports: Array.from(analysis.neededImports),
77
+ };
78
+ }
79
+ function createCommonModuleImportsArrayRemoval(classNode, file, typeChecker, neededImports) {
80
+ const reflector = new migrations.TypeScriptReflectionHost(typeChecker);
81
+ const decorators = reflector.getDecoratorsOfDeclaration(classNode);
82
+ if (!decorators) {
83
+ return null;
84
+ }
85
+ const decorator = decorators.find((decorator) => decorator.name === 'Component');
86
+ if (!decorator?.node) {
87
+ return null;
88
+ }
89
+ const decoratorNode = decorator.node;
90
+ if (!ts.isDecorator(decoratorNode) ||
91
+ !ts.isCallExpression(decoratorNode.expression) ||
92
+ decoratorNode.expression.arguments.length === 0 ||
93
+ !ts.isObjectLiteralExpression(decoratorNode.expression.arguments[0])) {
94
+ return null;
95
+ }
96
+ const metadata = decoratorNode.expression.arguments[0];
97
+ const importsProperty = metadata.properties.find((p) => ts.isPropertyAssignment(p) && p.name?.getText() === 'imports');
98
+ if (!importsProperty || !ts.isArrayLiteralExpression(importsProperty.initializer)) {
99
+ return null;
100
+ }
101
+ const importsArray = importsProperty.initializer;
102
+ const originalElements = importsArray.elements;
103
+ const filteredElements = originalElements.filter((el) => {
104
+ if (!ts.isIdentifier(el))
105
+ return true;
106
+ return !isCommonModuleFromAngularCommon(typeChecker, el);
107
+ });
108
+ const newElements = [
109
+ ...filteredElements,
110
+ ...neededImports.sort().map((imp) => ts.factory.createIdentifier(imp)),
111
+ ];
112
+ if (newElements.length === originalElements.length && neededImports.length === 0) {
113
+ return null;
114
+ }
115
+ if (newElements.length === 0) {
116
+ // For standalone components, keep imports: [] instead of removing the property entirely
117
+ const printer = ts.createPrinter();
118
+ const emptyArray = ts.factory.createArrayLiteralExpression([]);
119
+ const newText = printer.printNode(ts.EmitHint.Unspecified, emptyArray, classNode.getSourceFile());
120
+ return new project_paths.Replacement(file, new project_paths.TextUpdate({
121
+ position: importsArray.getStart(),
122
+ end: importsArray.getEnd(),
123
+ toInsert: newText,
124
+ }));
125
+ }
126
+ const printer = ts.createPrinter();
127
+ const newArray = ts.factory.updateArrayLiteralExpression(importsArray, newElements);
128
+ const newText = printer.printNode(ts.EmitHint.Unspecified, newArray, classNode.getSourceFile());
129
+ return new project_paths.Replacement(file, new project_paths.TextUpdate({
130
+ position: importsArray.getStart(),
131
+ end: importsArray.getEnd(),
132
+ toInsert: newText,
133
+ }));
134
+ }
135
+ function analyzeTemplateContent(templateContent) {
136
+ const neededImports = new Set();
137
+ const errors = [];
138
+ try {
139
+ analyzeTemplateWithRegex(templateContent, neededImports);
140
+ }
141
+ catch (error) {
142
+ errors.push(`Failed to analyze template: ${error}`);
143
+ }
144
+ return { neededImports, errors };
145
+ }
146
+ function hasCommonModuleInImports(componentNode, typeChecker) {
147
+ // First check if there's a CommonModule in the imports array
148
+ const reflector = new migrations.TypeScriptReflectionHost(typeChecker);
149
+ const decorators = reflector.getDecoratorsOfDeclaration(componentNode);
150
+ if (!decorators) {
151
+ return false;
152
+ }
153
+ const decorator = decorators.find((decorator) => decorator.name === 'Component');
154
+ if (!decorator?.node) {
155
+ return false;
156
+ }
157
+ const decoratorNode = decorator.node;
158
+ if (!ts.isDecorator(decoratorNode) ||
159
+ !ts.isCallExpression(decoratorNode.expression) ||
160
+ decoratorNode.expression.arguments.length === 0 ||
161
+ !ts.isObjectLiteralExpression(decoratorNode.expression.arguments[0])) {
162
+ return false;
163
+ }
164
+ const metadata = decoratorNode.expression.arguments[0];
165
+ const importsProperty = metadata.properties.find((p) => ts.isPropertyAssignment(p) && p.name?.getText() === 'imports');
166
+ if (!importsProperty || !ts.isArrayLiteralExpression(importsProperty.initializer)) {
167
+ return false;
168
+ }
169
+ const importsArray = importsProperty.initializer;
170
+ return importsArray.elements.some((el) => {
171
+ if (!ts.isIdentifier(el))
172
+ return false;
173
+ return isCommonModuleFromAngularCommon(typeChecker, el);
174
+ });
175
+ }
176
+ function isCommonModuleFromAngularCommon(typeChecker, identifier) {
177
+ const importInfo = imports.getImportOfIdentifier(typeChecker, identifier);
178
+ return (importInfo !== null &&
179
+ importInfo.name === commonModuleStr &&
180
+ importInfo.importModule === angularCommonStr);
181
+ }
182
+ function processResolvedTemplate(template, componentNode, info, typeChecker, replacements, filesWithNeededImports) {
183
+ const result = migrateCommonModuleUsage(template.content, componentNode, typeChecker);
184
+ if (result.changed) {
185
+ const sourceFile = componentNode.getSourceFile();
186
+ const file = project_paths.projectFile(sourceFile, info);
187
+ filesWithNeededImports.set(sourceFile.fileName, result.neededImports);
188
+ const replacement = createCommonModuleImportsArrayRemoval(componentNode, file, typeChecker, result.neededImports);
189
+ if (replacement) {
190
+ replacements.push(replacement);
191
+ }
192
+ const importManager = new migrations.ImportManager({
193
+ shouldUseSingleQuotes: () => true,
194
+ });
195
+ // Always remove 'CommonModule' regardless of whether it's aliased or not
196
+ // ImportManager handles removing the correct import specifier
197
+ importManager.removeImport(sourceFile, commonModuleStr, angularCommonStr);
198
+ if (result.neededImports.length > 0) {
199
+ result.neededImports.forEach((importName) => {
200
+ importManager.addImport({
201
+ exportSymbolName: importName,
202
+ exportModuleSpecifier: angularCommonStr,
203
+ requestedFile: sourceFile,
204
+ });
205
+ });
206
+ }
207
+ const importReplacements = [];
208
+ apply_import_manager.applyImportManagerChanges(importManager, importReplacements, [sourceFile], info);
209
+ replacements.push(...importReplacements);
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Angular Common to Standalone migration.
215
+ *
216
+ * This migration converts standalone components and Angular modules from using
217
+ * CommonModule to importing individual directives and pipes.
218
+ */
219
+ class CommonToStandaloneMigration extends project_paths.TsurgeFunnelMigration {
220
+ config;
221
+ constructor(config = {}) {
222
+ super();
223
+ this.config = config;
224
+ }
225
+ async analyze(info) {
226
+ const fileReplacements = [];
227
+ const references = [];
228
+ const filesWithNeededImports = new Map();
229
+ for (const sf of info.sourceFiles) {
230
+ const file = project_paths.projectFile(sf, info);
231
+ if (this.config.shouldMigrate && !this.config.shouldMigrate(file)) {
232
+ continue;
233
+ }
234
+ this.visitSourceFile(sf, info, fileReplacements, references, filesWithNeededImports);
235
+ }
236
+ return project_paths.confirmAsSerializable({
237
+ replacements: fileReplacements,
238
+ references,
239
+ filesWithNeededImports,
240
+ });
241
+ }
242
+ visitSourceFile(sourceFile, info, replacements, references, filesWithNeededImports) {
243
+ const typeChecker = info.program.getTypeChecker();
244
+ const visit = (node) => {
245
+ const hasNode = ts.isClassDeclaration(node) && node.name;
246
+ if (!hasNode) {
247
+ ts.forEachChild(node, visit);
248
+ return;
249
+ }
250
+ const nodeDecorators = ts.getDecorators(node);
251
+ if (!nodeDecorators) {
252
+ ts.forEachChild(node, visit);
253
+ return;
254
+ }
255
+ const decorators = ng_decorators.getAngularDecorators(typeChecker, nodeDecorators);
256
+ const hasComponentDecorator = decorators.some((d) => d.name === 'Component');
257
+ if (!hasComponentDecorator) {
258
+ return;
259
+ }
260
+ const ref = this.analyzeClass(node, typeChecker);
261
+ if (!ref) {
262
+ return;
263
+ }
264
+ references.push(ref);
265
+ const templateVisitor = new ng_component_template.NgComponentTemplateVisitor(typeChecker);
266
+ templateVisitor.visitNode(node);
267
+ for (const template of templateVisitor.resolvedTemplates) {
268
+ processResolvedTemplate(template, node, info, typeChecker, replacements, filesWithNeededImports);
269
+ }
270
+ // Component has CommonModule in imports but no template content to analyze
271
+ // We still need to process these cases to remove unused CommonModule imports
272
+ if (templateVisitor.resolvedTemplates.length === 0) {
273
+ processResolvedTemplate({ content: ''}, node, info, typeChecker, replacements, filesWithNeededImports);
274
+ }
275
+ ts.forEachChild(node, visit);
276
+ };
277
+ visit(sourceFile);
278
+ }
279
+ analyzeClass(node, typeChecker) {
280
+ const nodeDecorators = ts.getDecorators(node);
281
+ if (!nodeDecorators)
282
+ return null;
283
+ const decorators = ng_decorators.getAngularDecorators(typeChecker, nodeDecorators);
284
+ // Only process Component decorators, not Directive or other Angular decorators
285
+ for (const decorator of decorators) {
286
+ if (decorator.name === 'Component') {
287
+ return this.analyzeComponentDecorator(node, decorator, typeChecker);
288
+ }
289
+ }
290
+ return null;
291
+ }
292
+ analyzeComponentDecorator(node, decorator, typeChecker) {
293
+ const decoratorNode = decorator.node;
294
+ if (!ts.isCallExpression(decoratorNode.expression)) {
295
+ return null;
296
+ }
297
+ const config = decoratorNode.expression.arguments[0];
298
+ if (!ts.isObjectLiteralExpression(config)) {
299
+ return null;
300
+ }
301
+ if (hasCommonModuleInImports(node, typeChecker)) {
302
+ return { node };
303
+ }
304
+ return null;
305
+ }
306
+ async combine(unitA, unitB) {
307
+ const combinedFilesWithNeededImports = new Map(unitA.filesWithNeededImports);
308
+ for (const [fileName, imports] of unitB.filesWithNeededImports) {
309
+ if (combinedFilesWithNeededImports.has(fileName)) {
310
+ const existingImports = combinedFilesWithNeededImports.get(fileName) || [];
311
+ const mergedImports = Array.from(new Set([...existingImports, ...imports]));
312
+ combinedFilesWithNeededImports.set(fileName, mergedImports);
313
+ }
314
+ else {
315
+ combinedFilesWithNeededImports.set(fileName, imports);
316
+ }
317
+ }
318
+ return project_paths.confirmAsSerializable({
319
+ replacements: [...unitA.replacements, ...unitB.replacements],
320
+ references: [...unitA.references, ...unitB.references],
321
+ filesWithNeededImports: combinedFilesWithNeededImports,
322
+ });
323
+ }
324
+ async globalMeta(combinedData) {
325
+ return project_paths.confirmAsSerializable(combinedData);
326
+ }
327
+ async stats(globalMetadata) {
328
+ const stats = {
329
+ counters: {
330
+ replacements: globalMetadata.replacements.length,
331
+ references: globalMetadata.references.length,
332
+ },
333
+ };
334
+ return stats;
335
+ }
336
+ async migrate(globalData) {
337
+ return {
338
+ replacements: globalData.replacements,
339
+ };
340
+ }
341
+ }
342
+
343
+ function migrate(options) {
344
+ return async (tree, context) => {
345
+ await project_paths.runMigrationInDevkit({
346
+ tree,
347
+ getMigration: (fs) => new CommonToStandaloneMigration({
348
+ shouldMigrate: (file) => {
349
+ return (file.rootRelativePath.startsWith(fs.normalize(options.path)) &&
350
+ !/(^|\/)node_modules\//.test(file.rootRelativePath));
351
+ },
352
+ }),
353
+ beforeProgramCreation: (tsconfigPath, stage) => {
354
+ if (stage === project_paths.MigrationStage.Analysis) {
355
+ context.logger.info(`Preparing analysis for: ${tsconfigPath}...`);
356
+ }
357
+ else {
358
+ context.logger.info(`Running migration for: ${tsconfigPath}...`);
359
+ }
360
+ },
361
+ beforeUnitAnalysis: (tsconfigPath) => {
362
+ context.logger.info(`Scanning for CommonModule usage: ${tsconfigPath}...`);
363
+ },
364
+ afterAllAnalyzed: () => {
365
+ context.logger.info(``);
366
+ context.logger.info(`Processing analysis data between targets...`);
367
+ context.logger.info(``);
368
+ },
369
+ afterAnalysisFailure: () => {
370
+ context.logger.error('Migration failed unexpectedly with no analysis data');
371
+ },
372
+ whenDone: (stats) => {
373
+ context.logger.info('');
374
+ context.logger.info(`Successfully migrated CommonModule to standalone imports 🎉`);
375
+ context.logger.info(` -> Migrated ${stats.counters.replacements} CommonModule references affecting ${stats.counters.references} components.`);
376
+ },
377
+ });
378
+ };
379
+ }
380
+
381
+ exports.migrate = migrate;
@@ -1,15 +1,14 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v21.0.0-next.0
3
+ * @license Angular v21.0.0-next.10
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
9
  var ts = require('typescript');
10
- var project_tsconfig_paths = require('./project_tsconfig_paths-CS-eSeHC.cjs');
11
- require('os');
12
- var p = require('path');
10
+ var migrations = require('@angular/compiler-cli/private/migrations');
11
+ var path = require('path');
13
12
 
14
13
  function _interopNamespaceDefault(e) {
15
14
  var n = Object.create(null);
@@ -28,7 +27,7 @@ function _interopNamespaceDefault(e) {
28
27
  return Object.freeze(n);
29
28
  }
30
29
 
31
- var p__namespace = /*#__PURE__*/_interopNamespaceDefault(p);
30
+ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
32
31
 
33
32
  /** Tracks changes that have to be made for specific files. */
34
33
  class ChangeTracker {
@@ -40,7 +39,7 @@ class ChangeTracker {
40
39
  constructor(_printer, _importRemapper) {
41
40
  this._printer = _printer;
42
41
  this._importRemapper = _importRemapper;
43
- this._importManager = new project_tsconfig_paths.ImportManager({
42
+ this._importManager = new migrations.ImportManager({
44
43
  shouldUseSingleQuotes: (file) => this._getQuoteKind(file) === 0 /* QuoteKind.SINGLE */,
45
44
  });
46
45
  }
@@ -227,7 +226,7 @@ function parseTsconfigFile(tsconfigPath, basePath) {
227
226
  // Throw if incorrect arguments are passed to this function. Passing relative base paths
228
227
  // results in root directories not being resolved and in later type checking runtime errors.
229
228
  // More details can be found here: https://github.com/microsoft/TypeScript/issues/37731.
230
- if (!p__namespace.isAbsolute(basePath)) {
229
+ if (!path__namespace.isAbsolute(basePath)) {
231
230
  throw Error('Unexpected relative base path has been specified.');
232
231
  }
233
232
  return ts.parseJsonConfigFileContent(config, parseConfigHost, basePath, {});
@@ -261,8 +260,8 @@ function createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additi
261
260
  // Resolve the tsconfig path to an absolute path. This is needed as TypeScript otherwise
262
261
  // is not able to resolve root directories in the given tsconfig. More details can be found
263
262
  // in the following issue: https://github.com/microsoft/TypeScript/issues/37731.
264
- tsconfigPath = p.resolve(basePath, tsconfigPath);
265
- const parsed = parseTsconfigFile(tsconfigPath, p.dirname(tsconfigPath));
263
+ tsconfigPath = path.resolve(basePath, tsconfigPath);
264
+ const parsed = parseTsconfigFile(tsconfigPath, path.dirname(tsconfigPath));
266
265
  const options = optionOverrides ? { ...parsed.options, ...optionOverrides } : parsed.options;
267
266
  const host = createMigrationCompilerHost(tree, options, basePath, fakeFileRead);
268
267
  return { rootNames: parsed.fileNames.concat([]), options, host };
@@ -275,7 +274,7 @@ function createMigrationCompilerHost(tree, options, basePath, fakeRead) {
275
274
  // if we run multiple migrations we might have intersecting changes and
276
275
  // source files.
277
276
  host.readFile = (fileName) => {
278
- const treeRelativePath = p.relative(basePath, fileName);
277
+ const treeRelativePath = path.relative(basePath, fileName);
279
278
  let result = fakeRead?.(treeRelativePath);
280
279
  if (typeof result !== 'string') {
281
280
  // If the relative path resolved to somewhere outside of the tree, fall back to
@@ -309,7 +308,7 @@ function canMigrateFile(basePath, sourceFile, program) {
309
308
  // project. We can't migrate files outside of the project, because our file system interactions
310
309
  // go through the CLI's `Tree` which assumes that all files are within the project. See:
311
310
  // https://github.com/angular/angular-cli/blob/0b0961c9c233a825b6e4bb59ab7f0790f9b14676/packages/angular_devkit/schematics/src/tree/host-tree.ts#L131
312
- return !p.relative(basePath, sourceFile.fileName).startsWith('..');
311
+ return !path.relative(basePath, sourceFile.fileName).startsWith('..');
313
312
  }
314
313
 
315
314
  exports.ChangeTracker = ChangeTracker;