@angular/core 21.0.0-next.8 → 21.0.0-next.9
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.
- package/fesm2022/_attribute-chunk.mjs +1 -1
- package/fesm2022/_debug_node-chunk.mjs +481 -438
- package/fesm2022/_debug_node-chunk.mjs.map +1 -1
- package/fesm2022/_effect-chunk.mjs +512 -48
- package/fesm2022/_effect-chunk.mjs.map +1 -1
- package/fesm2022/{_root_effect_scheduler-chunk.mjs → _effect-chunk2.mjs} +197 -19
- package/fesm2022/_effect-chunk2.mjs.map +1 -0
- package/fesm2022/_not_found-chunk.mjs +1 -1
- package/fesm2022/_resource-chunk.mjs +5 -173
- package/fesm2022/_resource-chunk.mjs.map +1 -1
- package/fesm2022/_untracked-chunk.mjs +117 -0
- package/fesm2022/_untracked-chunk.mjs.map +1 -0
- package/fesm2022/_weak_ref-chunk.mjs +1 -1
- package/fesm2022/core.mjs +8 -7
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives-di.mjs +1 -1
- package/fesm2022/primitives-event-dispatch.mjs +1 -1
- package/fesm2022/primitives-signals.mjs +4 -4
- package/fesm2022/primitives-signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +5 -5
- package/fesm2022/testing.mjs +3 -3
- package/package.json +2 -2
- package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +5 -5
- package/schematics/bundles/application-config-core.cjs +5 -5
- package/schematics/bundles/{apply_import_manager-CBLmogDD.cjs → apply_import_manager-CoeTX_Ob.cjs} +3 -3
- package/schematics/bundles/bootstrap-options-migration.cjs +5 -5
- package/schematics/bundles/cleanup-unused-imports.cjs +5 -5
- package/schematics/bundles/common-to-standalone-migration.cjs +385 -0
- package/schematics/bundles/{compiler_host-T6xncpiw.cjs → compiler_host-emLDwK2U.cjs} +2 -2
- package/schematics/bundles/control-flow-migration.cjs +4 -4
- package/schematics/bundles/imports-DwPXlGFl.cjs +1 -1
- package/schematics/bundles/{index-DWSaRJdz.cjs → index-CLxYZ09c.cjs} +4 -4
- package/schematics/bundles/{index-BnmACOsq.cjs → index-Dvqnp6JS.cjs} +166 -66
- package/schematics/bundles/inject-migration.cjs +3 -3
- package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
- package/schematics/bundles/{migrate_ts_type_references-Cu-FR4L5.cjs → migrate_ts_type_references-CpM5FPGa.cjs} +5 -5
- package/schematics/bundles/{ng_component_template-BkWiUuGG.cjs → ng_component_template-BRbBIAUX.cjs} +2 -2
- package/schematics/bundles/ng_decorators-BI0uV7KI.cjs +1 -1
- package/schematics/bundles/ngclass-to-class-migration.cjs +7 -7
- package/schematics/bundles/ngstyle-to-style-migration.cjs +7 -7
- package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
- package/schematics/bundles/output-migration.cjs +6 -6
- package/schematics/bundles/{parse_html-C97tKKp3.cjs → parse_html-CPWfkfhR.cjs} +2 -2
- package/schematics/bundles/{project_paths-C6g3lqjX.cjs → project_paths-C8H7KDJ3.cjs} +3 -3
- package/schematics/bundles/{project_tsconfig_paths-CdhVNYMk.cjs → project_tsconfig_paths-CiBzGSIa.cjs} +12 -4
- package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
- package/schematics/bundles/route-lazy-loading.cjs +3 -3
- package/schematics/bundles/router-current-navigation.cjs +4 -4
- package/schematics/bundles/router-last-successful-navigation.cjs +4 -4
- package/schematics/bundles/router-testing-module-migration.cjs +5 -5
- package/schematics/bundles/self-closing-tags-migration.cjs +6 -6
- package/schematics/bundles/signal-input-migration.cjs +7 -7
- package/schematics/bundles/signal-queries-migration.cjs +7 -7
- package/schematics/bundles/signals.cjs +7 -7
- package/schematics/bundles/standalone-migration.cjs +4 -4
- package/schematics/bundles/symbol-BObKoqes.cjs +1 -1
- package/schematics/collection.json +6 -0
- package/schematics/migrations/common-to-standalone-migration/schema.json +14 -0
- package/types/_api-chunk.d.ts +1 -1
- package/types/_chrome_dev_tools_performance-chunk.d.ts +20 -12
- package/types/_discovery-chunk.d.ts +12 -6
- package/types/_effect-chunk.d.ts +1 -1
- package/types/_event_dispatcher-chunk.d.ts +1 -1
- package/types/_formatter-chunk.d.ts +4 -3
- package/types/_weak_ref-chunk.d.ts +1 -1
- package/types/core.d.ts +49 -20
- package/types/primitives-di.d.ts +1 -1
- package/types/primitives-event-dispatch.d.ts +1 -1
- package/types/primitives-signals.d.ts +2 -2
- package/types/rxjs-interop.d.ts +1 -1
- package/types/testing.d.ts +1 -1
- package/fesm2022/_root_effect_scheduler-chunk.mjs.map +0 -1
- package/fesm2022/_signal-chunk.mjs +0 -581
- package/fesm2022/_signal-chunk.mjs.map +0 -1
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @license Angular v21.0.0-next.9
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var ts = require('typescript');
|
|
10
|
+
require('os');
|
|
11
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CiBzGSIa.cjs');
|
|
12
|
+
require('./index-Dvqnp6JS.cjs');
|
|
13
|
+
require('path');
|
|
14
|
+
require('node:path');
|
|
15
|
+
var project_paths = require('./project_paths-C8H7KDJ3.cjs');
|
|
16
|
+
var ng_component_template = require('./ng_component_template-BRbBIAUX.cjs');
|
|
17
|
+
var ng_decorators = require('./ng_decorators-BI0uV7KI.cjs');
|
|
18
|
+
var apply_import_manager = require('./apply_import_manager-CoeTX_Ob.cjs');
|
|
19
|
+
var imports = require('./imports-DwPXlGFl.cjs');
|
|
20
|
+
require('@angular-devkit/core');
|
|
21
|
+
require('node:path/posix');
|
|
22
|
+
require('fs');
|
|
23
|
+
require('module');
|
|
24
|
+
require('url');
|
|
25
|
+
require('@angular-devkit/schematics');
|
|
26
|
+
require('./property_name-BBwFuqMe.cjs');
|
|
27
|
+
|
|
28
|
+
const commonModuleStr = 'CommonModule';
|
|
29
|
+
const angularCommonStr = '@angular/common';
|
|
30
|
+
const PATTERN_IMPORTS = [
|
|
31
|
+
// Structural directives
|
|
32
|
+
{ pattern: /\*ngIf\b/g, imports: ['NgIf'] },
|
|
33
|
+
{ pattern: /\*ngFor\b/g, imports: ['NgFor'] },
|
|
34
|
+
{ pattern: /\[ngForOf]\b/g, imports: ['NgForOf'] },
|
|
35
|
+
{ pattern: /\[ngPlural\]/g, imports: ['NgPlural'] },
|
|
36
|
+
// Match ngPluralCase as structural (*ngPluralCase) or attribute (ngPluralCase="value")
|
|
37
|
+
{ pattern: /(\*ngPluralCase\b|\s+ngPluralCase\s*=)/g, imports: ['NgPluralCase'] },
|
|
38
|
+
// Match ngSwitchCase as structural (*ngSwitchCase) or attribute (ngSwitchCase="value")
|
|
39
|
+
{ pattern: /(\*ngSwitchCase\b|\s+ngSwitchCase\s*=)/g, imports: ['NgSwitchCase'] },
|
|
40
|
+
// Match ngSwitchDefault as structural (*ngSwitchDefault) or standalone attribute (ngSwitchDefault>)
|
|
41
|
+
{ pattern: /(\*ngSwitchDefault\b|\s+ngSwitchDefault(?=\s*>))/g, imports: ['NgSwitchDefault'] },
|
|
42
|
+
{ pattern: /\[ngClass\]/g, imports: ['NgClass'] },
|
|
43
|
+
{ pattern: /\[ngStyle\]/g, imports: ['NgStyle'] },
|
|
44
|
+
// Match ngSwitch as property binding [ngSwitch] or attribute ngSwitch="value"
|
|
45
|
+
{ pattern: /(\[ngSwitch\]|\s+ngSwitch\s*=)/g, imports: ['NgSwitch'] },
|
|
46
|
+
{ pattern: /\[ngTemplateOutlet\]/g, imports: ['NgTemplateOutlet'] },
|
|
47
|
+
{ pattern: /\[ngComponentOutlet\]/g, imports: ['NgComponentOutlet'] },
|
|
48
|
+
// Common pipes
|
|
49
|
+
{ pattern: /\|\s*async\b/g, imports: ['AsyncPipe'] },
|
|
50
|
+
{ pattern: /\|\s*json\b/g, imports: ['JsonPipe'] },
|
|
51
|
+
{ pattern: /\|\s*date\b/g, imports: ['DatePipe'] },
|
|
52
|
+
{ pattern: /\|\s*currency\b/g, imports: ['CurrencyPipe'] },
|
|
53
|
+
{ pattern: /\|\s*number\b/g, imports: ['DecimalPipe'] },
|
|
54
|
+
{ pattern: /\|\s*percent\b/g, imports: ['PercentPipe'] },
|
|
55
|
+
{ pattern: /\|\s*lowercase\b/g, imports: ['LowerCasePipe'] },
|
|
56
|
+
{ pattern: /\|\s*uppercase\b/g, imports: ['UpperCasePipe'] },
|
|
57
|
+
{ pattern: /\|\s*titlecase\b/g, imports: ['TitleCasePipe'] },
|
|
58
|
+
{ pattern: /\|\s*slice\b/g, imports: ['SlicePipe'] },
|
|
59
|
+
{ pattern: /\|\s*keyvalue\b/g, imports: ['KeyValuePipe'] },
|
|
60
|
+
{ pattern: /\|\s*i18nPlural\b/g, imports: ['I18nPluralPipe'] },
|
|
61
|
+
{ pattern: /\|\s*i18nSelect\b/g, imports: ['I18nSelectPipe'] },
|
|
62
|
+
];
|
|
63
|
+
function analyzeTemplateWithRegex(template, neededImports) {
|
|
64
|
+
PATTERN_IMPORTS.forEach(({ pattern, imports }) => {
|
|
65
|
+
// Reset regex lastIndex to avoid state issues with global flag
|
|
66
|
+
pattern.lastIndex = 0;
|
|
67
|
+
if (pattern.test(template)) {
|
|
68
|
+
imports.forEach((imp) => neededImports.add(imp));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function migrateCommonModuleUsage(template, componentNode, typeChecker) {
|
|
73
|
+
const analysis = analyzeTemplateContent(template);
|
|
74
|
+
const hasCommonModule = hasCommonModuleInImports(componentNode, typeChecker);
|
|
75
|
+
return {
|
|
76
|
+
migrated: template,
|
|
77
|
+
changed: hasCommonModule,
|
|
78
|
+
replacementCount: hasCommonModule ? 1 : 0,
|
|
79
|
+
canRemoveCommonModule: hasCommonModule,
|
|
80
|
+
neededImports: Array.from(analysis.neededImports),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function createCommonModuleImportsArrayRemoval(classNode, file, typeChecker, neededImports) {
|
|
84
|
+
const reflector = new project_tsconfig_paths.TypeScriptReflectionHost(typeChecker);
|
|
85
|
+
const decorators = reflector.getDecoratorsOfDeclaration(classNode);
|
|
86
|
+
if (!decorators) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const decorator = decorators.find((decorator) => decorator.name === 'Component');
|
|
90
|
+
if (!decorator?.node) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const decoratorNode = decorator.node;
|
|
94
|
+
if (!ts.isDecorator(decoratorNode) ||
|
|
95
|
+
!ts.isCallExpression(decoratorNode.expression) ||
|
|
96
|
+
decoratorNode.expression.arguments.length === 0 ||
|
|
97
|
+
!ts.isObjectLiteralExpression(decoratorNode.expression.arguments[0])) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const metadata = decoratorNode.expression.arguments[0];
|
|
101
|
+
const importsProperty = metadata.properties.find((p) => ts.isPropertyAssignment(p) && p.name?.getText() === 'imports');
|
|
102
|
+
if (!importsProperty || !ts.isArrayLiteralExpression(importsProperty.initializer)) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const importsArray = importsProperty.initializer;
|
|
106
|
+
const originalElements = importsArray.elements;
|
|
107
|
+
const filteredElements = originalElements.filter((el) => {
|
|
108
|
+
if (!ts.isIdentifier(el))
|
|
109
|
+
return true;
|
|
110
|
+
return !isCommonModuleFromAngularCommon(typeChecker, el);
|
|
111
|
+
});
|
|
112
|
+
const newElements = [
|
|
113
|
+
...filteredElements,
|
|
114
|
+
...neededImports.sort().map((imp) => ts.factory.createIdentifier(imp)),
|
|
115
|
+
];
|
|
116
|
+
if (newElements.length === originalElements.length && neededImports.length === 0) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
if (newElements.length === 0) {
|
|
120
|
+
// For standalone components, keep imports: [] instead of removing the property entirely
|
|
121
|
+
const printer = ts.createPrinter();
|
|
122
|
+
const emptyArray = ts.factory.createArrayLiteralExpression([]);
|
|
123
|
+
const newText = printer.printNode(ts.EmitHint.Unspecified, emptyArray, classNode.getSourceFile());
|
|
124
|
+
return new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
125
|
+
position: importsArray.getStart(),
|
|
126
|
+
end: importsArray.getEnd(),
|
|
127
|
+
toInsert: newText,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
const printer = ts.createPrinter();
|
|
131
|
+
const newArray = ts.factory.updateArrayLiteralExpression(importsArray, newElements);
|
|
132
|
+
const newText = printer.printNode(ts.EmitHint.Unspecified, newArray, classNode.getSourceFile());
|
|
133
|
+
return new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
134
|
+
position: importsArray.getStart(),
|
|
135
|
+
end: importsArray.getEnd(),
|
|
136
|
+
toInsert: newText,
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
function analyzeTemplateContent(templateContent) {
|
|
140
|
+
const neededImports = new Set();
|
|
141
|
+
const errors = [];
|
|
142
|
+
try {
|
|
143
|
+
analyzeTemplateWithRegex(templateContent, neededImports);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
errors.push(`Failed to analyze template: ${error}`);
|
|
147
|
+
}
|
|
148
|
+
return { neededImports, errors };
|
|
149
|
+
}
|
|
150
|
+
function hasCommonModuleInImports(componentNode, typeChecker) {
|
|
151
|
+
// First check if there's a CommonModule in the imports array
|
|
152
|
+
const reflector = new project_tsconfig_paths.TypeScriptReflectionHost(typeChecker);
|
|
153
|
+
const decorators = reflector.getDecoratorsOfDeclaration(componentNode);
|
|
154
|
+
if (!decorators) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const decorator = decorators.find((decorator) => decorator.name === 'Component');
|
|
158
|
+
if (!decorator?.node) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
const decoratorNode = decorator.node;
|
|
162
|
+
if (!ts.isDecorator(decoratorNode) ||
|
|
163
|
+
!ts.isCallExpression(decoratorNode.expression) ||
|
|
164
|
+
decoratorNode.expression.arguments.length === 0 ||
|
|
165
|
+
!ts.isObjectLiteralExpression(decoratorNode.expression.arguments[0])) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const metadata = decoratorNode.expression.arguments[0];
|
|
169
|
+
const importsProperty = metadata.properties.find((p) => ts.isPropertyAssignment(p) && p.name?.getText() === 'imports');
|
|
170
|
+
if (!importsProperty || !ts.isArrayLiteralExpression(importsProperty.initializer)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
const importsArray = importsProperty.initializer;
|
|
174
|
+
return importsArray.elements.some((el) => {
|
|
175
|
+
if (!ts.isIdentifier(el))
|
|
176
|
+
return false;
|
|
177
|
+
return isCommonModuleFromAngularCommon(typeChecker, el);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function isCommonModuleFromAngularCommon(typeChecker, identifier) {
|
|
181
|
+
const importInfo = imports.getImportOfIdentifier(typeChecker, identifier);
|
|
182
|
+
return (importInfo !== null &&
|
|
183
|
+
importInfo.name === commonModuleStr &&
|
|
184
|
+
importInfo.importModule === angularCommonStr);
|
|
185
|
+
}
|
|
186
|
+
function processResolvedTemplate(template, componentNode, info, typeChecker, replacements, filesWithNeededImports) {
|
|
187
|
+
const result = migrateCommonModuleUsage(template.content, componentNode, typeChecker);
|
|
188
|
+
if (result.changed) {
|
|
189
|
+
const sourceFile = componentNode.getSourceFile();
|
|
190
|
+
const file = project_paths.projectFile(sourceFile, info);
|
|
191
|
+
filesWithNeededImports.set(sourceFile.fileName, result.neededImports);
|
|
192
|
+
const replacement = createCommonModuleImportsArrayRemoval(componentNode, file, typeChecker, result.neededImports);
|
|
193
|
+
if (replacement) {
|
|
194
|
+
replacements.push(replacement);
|
|
195
|
+
}
|
|
196
|
+
const importManager = new project_tsconfig_paths.ImportManager({
|
|
197
|
+
shouldUseSingleQuotes: () => true,
|
|
198
|
+
});
|
|
199
|
+
// Always remove 'CommonModule' regardless of whether it's aliased or not
|
|
200
|
+
// ImportManager handles removing the correct import specifier
|
|
201
|
+
importManager.removeImport(sourceFile, commonModuleStr, angularCommonStr);
|
|
202
|
+
if (result.neededImports.length > 0) {
|
|
203
|
+
result.neededImports.forEach((importName) => {
|
|
204
|
+
importManager.addImport({
|
|
205
|
+
exportSymbolName: importName,
|
|
206
|
+
exportModuleSpecifier: angularCommonStr,
|
|
207
|
+
requestedFile: sourceFile,
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const importReplacements = [];
|
|
212
|
+
apply_import_manager.applyImportManagerChanges(importManager, importReplacements, [sourceFile], info);
|
|
213
|
+
replacements.push(...importReplacements);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Angular Common to Standalone migration.
|
|
219
|
+
*
|
|
220
|
+
* This migration converts standalone components and Angular modules from using
|
|
221
|
+
* CommonModule to importing individual directives and pipes.
|
|
222
|
+
*/
|
|
223
|
+
class CommonToStandaloneMigration extends project_paths.TsurgeFunnelMigration {
|
|
224
|
+
config;
|
|
225
|
+
constructor(config = {}) {
|
|
226
|
+
super();
|
|
227
|
+
this.config = config;
|
|
228
|
+
}
|
|
229
|
+
async analyze(info) {
|
|
230
|
+
const fileReplacements = [];
|
|
231
|
+
const references = [];
|
|
232
|
+
const filesWithNeededImports = new Map();
|
|
233
|
+
for (const sf of info.sourceFiles) {
|
|
234
|
+
const file = project_paths.projectFile(sf, info);
|
|
235
|
+
if (this.config.shouldMigrate && !this.config.shouldMigrate(file)) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
this.visitSourceFile(sf, info, fileReplacements, references, filesWithNeededImports);
|
|
239
|
+
}
|
|
240
|
+
return project_paths.confirmAsSerializable({
|
|
241
|
+
replacements: fileReplacements,
|
|
242
|
+
references,
|
|
243
|
+
filesWithNeededImports,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
visitSourceFile(sourceFile, info, replacements, references, filesWithNeededImports) {
|
|
247
|
+
const typeChecker = info.program.getTypeChecker();
|
|
248
|
+
const visit = (node) => {
|
|
249
|
+
const hasNode = ts.isClassDeclaration(node) && node.name;
|
|
250
|
+
if (!hasNode) {
|
|
251
|
+
ts.forEachChild(node, visit);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const nodeDecorators = ts.getDecorators(node);
|
|
255
|
+
if (!nodeDecorators) {
|
|
256
|
+
ts.forEachChild(node, visit);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const decorators = ng_decorators.getAngularDecorators(typeChecker, nodeDecorators);
|
|
260
|
+
const hasComponentDecorator = decorators.some((d) => d.name === 'Component');
|
|
261
|
+
if (!hasComponentDecorator) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const ref = this.analyzeClass(node, typeChecker);
|
|
265
|
+
if (!ref) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
references.push(ref);
|
|
269
|
+
const templateVisitor = new ng_component_template.NgComponentTemplateVisitor(typeChecker);
|
|
270
|
+
templateVisitor.visitNode(node);
|
|
271
|
+
for (const template of templateVisitor.resolvedTemplates) {
|
|
272
|
+
processResolvedTemplate(template, node, info, typeChecker, replacements, filesWithNeededImports);
|
|
273
|
+
}
|
|
274
|
+
// Component has CommonModule in imports but no template content to analyze
|
|
275
|
+
// We still need to process these cases to remove unused CommonModule imports
|
|
276
|
+
if (templateVisitor.resolvedTemplates.length === 0) {
|
|
277
|
+
processResolvedTemplate({ content: ''}, node, info, typeChecker, replacements, filesWithNeededImports);
|
|
278
|
+
}
|
|
279
|
+
ts.forEachChild(node, visit);
|
|
280
|
+
};
|
|
281
|
+
visit(sourceFile);
|
|
282
|
+
}
|
|
283
|
+
analyzeClass(node, typeChecker) {
|
|
284
|
+
const nodeDecorators = ts.getDecorators(node);
|
|
285
|
+
if (!nodeDecorators)
|
|
286
|
+
return null;
|
|
287
|
+
const decorators = ng_decorators.getAngularDecorators(typeChecker, nodeDecorators);
|
|
288
|
+
// Only process Component decorators, not Directive or other Angular decorators
|
|
289
|
+
for (const decorator of decorators) {
|
|
290
|
+
if (decorator.name === 'Component') {
|
|
291
|
+
return this.analyzeComponentDecorator(node, decorator, typeChecker);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
analyzeComponentDecorator(node, decorator, typeChecker) {
|
|
297
|
+
const decoratorNode = decorator.node;
|
|
298
|
+
if (!ts.isCallExpression(decoratorNode.expression)) {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
const config = decoratorNode.expression.arguments[0];
|
|
302
|
+
if (!ts.isObjectLiteralExpression(config)) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
if (hasCommonModuleInImports(node, typeChecker)) {
|
|
306
|
+
return { node };
|
|
307
|
+
}
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
async combine(unitA, unitB) {
|
|
311
|
+
const combinedFilesWithNeededImports = new Map(unitA.filesWithNeededImports);
|
|
312
|
+
for (const [fileName, imports] of unitB.filesWithNeededImports) {
|
|
313
|
+
if (combinedFilesWithNeededImports.has(fileName)) {
|
|
314
|
+
const existingImports = combinedFilesWithNeededImports.get(fileName) || [];
|
|
315
|
+
const mergedImports = Array.from(new Set([...existingImports, ...imports]));
|
|
316
|
+
combinedFilesWithNeededImports.set(fileName, mergedImports);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
combinedFilesWithNeededImports.set(fileName, imports);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return project_paths.confirmAsSerializable({
|
|
323
|
+
replacements: [...unitA.replacements, ...unitB.replacements],
|
|
324
|
+
references: [...unitA.references, ...unitB.references],
|
|
325
|
+
filesWithNeededImports: combinedFilesWithNeededImports,
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
async globalMeta(combinedData) {
|
|
329
|
+
return project_paths.confirmAsSerializable(combinedData);
|
|
330
|
+
}
|
|
331
|
+
async stats(globalMetadata) {
|
|
332
|
+
const stats = {
|
|
333
|
+
counters: {
|
|
334
|
+
replacements: globalMetadata.replacements.length,
|
|
335
|
+
references: globalMetadata.references.length,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
return stats;
|
|
339
|
+
}
|
|
340
|
+
async migrate(globalData) {
|
|
341
|
+
return {
|
|
342
|
+
replacements: globalData.replacements,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function migrate(options) {
|
|
348
|
+
return async (tree, context) => {
|
|
349
|
+
await project_paths.runMigrationInDevkit({
|
|
350
|
+
tree,
|
|
351
|
+
getMigration: (fs) => new CommonToStandaloneMigration({
|
|
352
|
+
shouldMigrate: (file) => {
|
|
353
|
+
return (file.rootRelativePath.startsWith(fs.normalize(options.path)) &&
|
|
354
|
+
!/(^|\/)node_modules\//.test(file.rootRelativePath));
|
|
355
|
+
},
|
|
356
|
+
}),
|
|
357
|
+
beforeProgramCreation: (tsconfigPath, stage) => {
|
|
358
|
+
if (stage === project_paths.MigrationStage.Analysis) {
|
|
359
|
+
context.logger.info(`Preparing analysis for: ${tsconfigPath}...`);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
context.logger.info(`Running migration for: ${tsconfigPath}...`);
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
beforeUnitAnalysis: (tsconfigPath) => {
|
|
366
|
+
context.logger.info(`Scanning for CommonModule usage: ${tsconfigPath}...`);
|
|
367
|
+
},
|
|
368
|
+
afterAllAnalyzed: () => {
|
|
369
|
+
context.logger.info(``);
|
|
370
|
+
context.logger.info(`Processing analysis data between targets...`);
|
|
371
|
+
context.logger.info(``);
|
|
372
|
+
},
|
|
373
|
+
afterAnalysisFailure: () => {
|
|
374
|
+
context.logger.error('Migration failed unexpectedly with no analysis data');
|
|
375
|
+
},
|
|
376
|
+
whenDone: (stats) => {
|
|
377
|
+
context.logger.info('');
|
|
378
|
+
context.logger.info(`Successfully migrated CommonModule to standalone imports 🎉`);
|
|
379
|
+
context.logger.info(` -> Migrated ${stats.counters.replacements} CommonModule references affecting ${stats.counters.references} components.`);
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
exports.migrate = migrate;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-next.
|
|
3
|
+
* @license Angular v21.0.0-next.9
|
|
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-
|
|
10
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CiBzGSIa.cjs');
|
|
11
11
|
require('os');
|
|
12
12
|
var p = require('path');
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-next.
|
|
3
|
+
* @license Angular v21.0.0-next.9
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
var schematics = require('@angular-devkit/schematics');
|
|
10
10
|
var p = require('path');
|
|
11
|
-
var compiler_host = require('./compiler_host-
|
|
12
|
-
var project_tsconfig_paths = require('./project_tsconfig_paths-
|
|
11
|
+
var compiler_host = require('./compiler_host-emLDwK2U.cjs');
|
|
12
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CiBzGSIa.cjs');
|
|
13
13
|
var ts = require('typescript');
|
|
14
|
-
var parse_html = require('./parse_html-
|
|
14
|
+
var parse_html = require('./parse_html-CPWfkfhR.cjs');
|
|
15
15
|
require('os');
|
|
16
16
|
require('fs');
|
|
17
17
|
require('module');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-next.
|
|
3
|
+
* @license Angular v21.0.0-next.9
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
var ts = require('typescript');
|
|
10
10
|
require('os');
|
|
11
|
-
var project_tsconfig_paths = require('./project_tsconfig_paths-
|
|
12
|
-
var index = require('./index-
|
|
11
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CiBzGSIa.cjs');
|
|
12
|
+
var index = require('./index-Dvqnp6JS.cjs');
|
|
13
13
|
require('path');
|
|
14
14
|
require('node:path');
|
|
15
|
-
var project_paths = require('./project_paths-
|
|
15
|
+
var project_paths = require('./project_paths-C8H7KDJ3.cjs');
|
|
16
16
|
|
|
17
17
|
function getMemberName(member) {
|
|
18
18
|
if (member.name === undefined) {
|