@angular/core 18.2.3 → 18.2.4
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/esm2022/src/render3/component_ref.mjs +1 -1
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/application_error_handler.mjs +3 -3
- package/esm2022/testing/src/logger.mjs +3 -3
- package/fesm2022/core.mjs +3 -3
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +4 -4
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/after-render-phase/bundle.js +13 -13
- package/schematics/migrations/http-providers/bundle.js +13 -13
- package/schematics/migrations/invalid-two-way-bindings/bundle.js +13 -13
- package/schematics/ng-generate/control-flow-migration/bundle.js +13 -13
- package/schematics/ng-generate/inject-migration/bundle.js +13 -13
- package/schematics/ng-generate/route-lazy-loading/bundle.js +13 -13
- package/schematics/ng-generate/standalone-migration/bundle.js +351 -294
- package/testing/index.d.ts +1 -1
|
@@ -23395,7 +23395,7 @@ function createForLoop(ast, connectedBlocks, visitor, bindingParser) {
|
|
|
23395
23395
|
}
|
|
23396
23396
|
if (params !== null) {
|
|
23397
23397
|
if (params.trackBy === null) {
|
|
23398
|
-
errors.push(new ParseError(ast.
|
|
23398
|
+
errors.push(new ParseError(ast.startSourceSpan, '@for loop must have a "track" expression'));
|
|
23399
23399
|
} else {
|
|
23400
23400
|
const endSpan = (_a2 = empty == null ? void 0 : empty.endSourceSpan) != null ? _a2 : ast.endSourceSpan;
|
|
23401
23401
|
const sourceSpan = new ParseSourceSpan(ast.sourceSpan.start, (_b2 = endSpan == null ? void 0 : endSpan.end) != null ? _b2 : ast.sourceSpan.end);
|
|
@@ -23437,7 +23437,7 @@ function createSwitchBlock(ast, visitor, bindingParser) {
|
|
|
23437
23437
|
function parseForLoopParameters(block, errors, bindingParser) {
|
|
23438
23438
|
var _a2;
|
|
23439
23439
|
if (block.parameters.length === 0) {
|
|
23440
|
-
errors.push(new ParseError(block.
|
|
23440
|
+
errors.push(new ParseError(block.startSourceSpan, "@for loop does not have an expression"));
|
|
23441
23441
|
return null;
|
|
23442
23442
|
}
|
|
23443
23443
|
const [expressionParam, ...secondaryParams] = block.parameters;
|
|
@@ -23475,7 +23475,7 @@ function parseForLoopParameters(block, errors, bindingParser) {
|
|
|
23475
23475
|
} else {
|
|
23476
23476
|
const expression = parseBlockParameterToBinding(param, bindingParser, trackMatch[1]);
|
|
23477
23477
|
if (expression.ast instanceof EmptyExpr) {
|
|
23478
|
-
errors.push(new ParseError(
|
|
23478
|
+
errors.push(new ParseError(block.startSourceSpan, '@for loop must have a "track" expression'));
|
|
23479
23479
|
}
|
|
23480
23480
|
const keywordSpan = new ParseSourceSpan(param.sourceSpan.start, param.sourceSpan.start.moveBy("track".length));
|
|
23481
23481
|
result.trackBy = { expression, keywordSpan };
|
|
@@ -23526,15 +23526,15 @@ function validateIfConnectedBlocks(connectedBlocks) {
|
|
|
23526
23526
|
const block = connectedBlocks[i];
|
|
23527
23527
|
if (block.name === "else") {
|
|
23528
23528
|
if (hasElse) {
|
|
23529
|
-
errors.push(new ParseError(block.
|
|
23529
|
+
errors.push(new ParseError(block.startSourceSpan, "Conditional can only have one @else block"));
|
|
23530
23530
|
} else if (connectedBlocks.length > 1 && i < connectedBlocks.length - 1) {
|
|
23531
|
-
errors.push(new ParseError(block.
|
|
23531
|
+
errors.push(new ParseError(block.startSourceSpan, "@else block must be last inside the conditional"));
|
|
23532
23532
|
} else if (block.parameters.length > 0) {
|
|
23533
|
-
errors.push(new ParseError(block.
|
|
23533
|
+
errors.push(new ParseError(block.startSourceSpan, "@else block cannot have parameters"));
|
|
23534
23534
|
}
|
|
23535
23535
|
hasElse = true;
|
|
23536
23536
|
} else if (!ELSE_IF_PATTERN.test(block.name)) {
|
|
23537
|
-
errors.push(new ParseError(block.
|
|
23537
|
+
errors.push(new ParseError(block.startSourceSpan, `Unrecognized conditional block @${block.name}`));
|
|
23538
23538
|
}
|
|
23539
23539
|
}
|
|
23540
23540
|
return errors;
|
|
@@ -23543,7 +23543,7 @@ function validateSwitchBlock(ast) {
|
|
|
23543
23543
|
const errors = [];
|
|
23544
23544
|
let hasDefault = false;
|
|
23545
23545
|
if (ast.parameters.length !== 1) {
|
|
23546
|
-
errors.push(new ParseError(ast.
|
|
23546
|
+
errors.push(new ParseError(ast.startSourceSpan, "@switch block must have exactly one parameter"));
|
|
23547
23547
|
return errors;
|
|
23548
23548
|
}
|
|
23549
23549
|
for (const node of ast.children) {
|
|
@@ -23556,13 +23556,13 @@ function validateSwitchBlock(ast) {
|
|
|
23556
23556
|
}
|
|
23557
23557
|
if (node.name === "default") {
|
|
23558
23558
|
if (hasDefault) {
|
|
23559
|
-
errors.push(new ParseError(node.
|
|
23559
|
+
errors.push(new ParseError(node.startSourceSpan, "@switch block can only have one @default block"));
|
|
23560
23560
|
} else if (node.parameters.length > 0) {
|
|
23561
|
-
errors.push(new ParseError(node.
|
|
23561
|
+
errors.push(new ParseError(node.startSourceSpan, "@default block cannot have parameters"));
|
|
23562
23562
|
}
|
|
23563
23563
|
hasDefault = true;
|
|
23564
23564
|
} else if (node.name === "case" && node.parameters.length !== 1) {
|
|
23565
|
-
errors.push(new ParseError(node.
|
|
23565
|
+
errors.push(new ParseError(node.startSourceSpan, "@case block must have exactly one parameter"));
|
|
23566
23566
|
}
|
|
23567
23567
|
}
|
|
23568
23568
|
return errors;
|
|
@@ -23581,7 +23581,7 @@ function parseBlockParameterToBinding(ast, bindingParser, part) {
|
|
|
23581
23581
|
}
|
|
23582
23582
|
function parseConditionalBlockParameters(block, errors, bindingParser) {
|
|
23583
23583
|
if (block.parameters.length === 0) {
|
|
23584
|
-
errors.push(new ParseError(block.
|
|
23584
|
+
errors.push(new ParseError(block.startSourceSpan, "Conditional block does not have an expression"));
|
|
23585
23585
|
return null;
|
|
23586
23586
|
}
|
|
23587
23587
|
const expression = parseBlockParameterToBinding(block.parameters[0], bindingParser);
|
|
@@ -26226,7 +26226,7 @@ function publishFacade(global) {
|
|
|
26226
26226
|
}
|
|
26227
26227
|
|
|
26228
26228
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/version.mjs
|
|
26229
|
-
var VERSION2 = new Version("18.2.
|
|
26229
|
+
var VERSION2 = new Version("18.2.4");
|
|
26230
26230
|
|
|
26231
26231
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
|
|
26232
26232
|
var _I18N_ATTR = "i18n";
|
|
@@ -27343,7 +27343,7 @@ var MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = "18.0.0";
|
|
|
27343
27343
|
function compileDeclareClassMetadata(metadata) {
|
|
27344
27344
|
const definitionMap = new DefinitionMap();
|
|
27345
27345
|
definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
27346
|
-
definitionMap.set("version", literal("18.2.
|
|
27346
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27347
27347
|
definitionMap.set("ngImport", importExpr(Identifiers.core));
|
|
27348
27348
|
definitionMap.set("type", metadata.type);
|
|
27349
27349
|
definitionMap.set("decorators", metadata.decorators);
|
|
@@ -27362,7 +27362,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
|
27362
27362
|
callbackReturnDefinitionMap.set("ctorParameters", (_a2 = metadata.ctorParameters) != null ? _a2 : literal(null));
|
|
27363
27363
|
callbackReturnDefinitionMap.set("propDecorators", (_b2 = metadata.propDecorators) != null ? _b2 : literal(null));
|
|
27364
27364
|
definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
27365
|
-
definitionMap.set("version", literal("18.2.
|
|
27365
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27366
27366
|
definitionMap.set("ngImport", importExpr(Identifiers.core));
|
|
27367
27367
|
definitionMap.set("type", metadata.type);
|
|
27368
27368
|
definitionMap.set("resolveDeferredDeps", compileComponentMetadataAsyncResolver(dependencies));
|
|
@@ -27430,7 +27430,7 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
27430
27430
|
const definitionMap = new DefinitionMap();
|
|
27431
27431
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
27432
27432
|
definitionMap.set("minVersion", literal(minVersion));
|
|
27433
|
-
definitionMap.set("version", literal("18.2.
|
|
27433
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27434
27434
|
definitionMap.set("type", meta.type.value);
|
|
27435
27435
|
if (meta.isStandalone) {
|
|
27436
27436
|
definitionMap.set("isStandalone", literal(meta.isStandalone));
|
|
@@ -27748,7 +27748,7 @@ var MINIMUM_PARTIAL_LINKER_VERSION2 = "12.0.0";
|
|
|
27748
27748
|
function compileDeclareFactoryFunction(meta) {
|
|
27749
27749
|
const definitionMap = new DefinitionMap();
|
|
27750
27750
|
definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION2));
|
|
27751
|
-
definitionMap.set("version", literal("18.2.
|
|
27751
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27752
27752
|
definitionMap.set("ngImport", importExpr(Identifiers.core));
|
|
27753
27753
|
definitionMap.set("type", meta.type.value);
|
|
27754
27754
|
definitionMap.set("deps", compileDependencies(meta.deps));
|
|
@@ -27771,7 +27771,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
27771
27771
|
function createInjectableDefinitionMap(meta) {
|
|
27772
27772
|
const definitionMap = new DefinitionMap();
|
|
27773
27773
|
definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION3));
|
|
27774
|
-
definitionMap.set("version", literal("18.2.
|
|
27774
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27775
27775
|
definitionMap.set("ngImport", importExpr(Identifiers.core));
|
|
27776
27776
|
definitionMap.set("type", meta.type.value);
|
|
27777
27777
|
if (meta.providedIn !== void 0) {
|
|
@@ -27809,7 +27809,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
27809
27809
|
function createInjectorDefinitionMap(meta) {
|
|
27810
27810
|
const definitionMap = new DefinitionMap();
|
|
27811
27811
|
definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION4));
|
|
27812
|
-
definitionMap.set("version", literal("18.2.
|
|
27812
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27813
27813
|
definitionMap.set("ngImport", importExpr(Identifiers.core));
|
|
27814
27814
|
definitionMap.set("type", meta.type.value);
|
|
27815
27815
|
definitionMap.set("providers", meta.providers);
|
|
@@ -27833,7 +27833,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
27833
27833
|
throw new Error("Invalid path! Local compilation mode should not get into the partial compilation path");
|
|
27834
27834
|
}
|
|
27835
27835
|
definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION5));
|
|
27836
|
-
definitionMap.set("version", literal("18.2.
|
|
27836
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27837
27837
|
definitionMap.set("ngImport", importExpr(Identifiers.core));
|
|
27838
27838
|
definitionMap.set("type", meta.type.value);
|
|
27839
27839
|
if (meta.bootstrap.length > 0) {
|
|
@@ -27868,7 +27868,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
27868
27868
|
function createPipeDefinitionMap(meta) {
|
|
27869
27869
|
const definitionMap = new DefinitionMap();
|
|
27870
27870
|
definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION6));
|
|
27871
|
-
definitionMap.set("version", literal("18.2.
|
|
27871
|
+
definitionMap.set("version", literal("18.2.4"));
|
|
27872
27872
|
definitionMap.set("ngImport", importExpr(Identifiers.core));
|
|
27873
27873
|
definitionMap.set("type", meta.type.value);
|
|
27874
27874
|
if (meta.isStandalone) {
|
|
@@ -27885,7 +27885,7 @@ function createPipeDefinitionMap(meta) {
|
|
|
27885
27885
|
publishFacade(_global);
|
|
27886
27886
|
|
|
27887
27887
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/version.mjs
|
|
27888
|
-
var VERSION3 = new Version("18.2.
|
|
27888
|
+
var VERSION3 = new Version("18.2.4");
|
|
27889
27889
|
|
|
27890
27890
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/emitter.mjs
|
|
27891
27891
|
var import_typescript5 = __toESM(require("typescript"), 1);
|
|
@@ -47319,7 +47319,7 @@ var DocsExtractor = class {
|
|
|
47319
47319
|
this.typeChecker = typeChecker;
|
|
47320
47320
|
this.metadataReader = metadataReader;
|
|
47321
47321
|
}
|
|
47322
|
-
extractAll(sourceFile, rootDir) {
|
|
47322
|
+
extractAll(sourceFile, rootDir, privateModules) {
|
|
47323
47323
|
const entries = [];
|
|
47324
47324
|
const symbols = /* @__PURE__ */ new Map();
|
|
47325
47325
|
const exportedDeclarations = this.getExportedDeclarations(sourceFile);
|
|
@@ -47332,7 +47332,7 @@ var DocsExtractor = class {
|
|
|
47332
47332
|
const realSourceFile = node.getSourceFile();
|
|
47333
47333
|
const importedSymbols = getImportedSymbols(realSourceFile);
|
|
47334
47334
|
importedSymbols.forEach((moduleName, symbolName) => {
|
|
47335
|
-
if (symbolName.startsWith("\u0275")) {
|
|
47335
|
+
if (symbolName.startsWith("\u0275") || privateModules.has(moduleName)) {
|
|
47336
47336
|
return;
|
|
47337
47337
|
}
|
|
47338
47338
|
if (symbols.has(symbolName) && symbols.get(symbolName) !== moduleName) {
|
|
@@ -49715,7 +49715,7 @@ var NgCompiler = class {
|
|
|
49715
49715
|
compilation.traitCompiler.index(context);
|
|
49716
49716
|
return generateAnalysis(context);
|
|
49717
49717
|
}
|
|
49718
|
-
getApiDocumentation(entryPoint) {
|
|
49718
|
+
getApiDocumentation(entryPoint, privateModules) {
|
|
49719
49719
|
const compilation = this.ensureAnalyzed();
|
|
49720
49720
|
const checker = this.inputProgram.getTypeChecker();
|
|
49721
49721
|
const docsExtractor = new DocsExtractor(checker, compilation.metaReader);
|
|
@@ -49726,7 +49726,7 @@ var NgCompiler = class {
|
|
|
49726
49726
|
throw new Error(`Entry point "${entryPoint}" not found in program sources.`);
|
|
49727
49727
|
}
|
|
49728
49728
|
const rootDir = this.inputProgram.getCurrentDirectory();
|
|
49729
|
-
return docsExtractor.extractAll(entryPointSourceFile, rootDir);
|
|
49729
|
+
return docsExtractor.extractAll(entryPointSourceFile, rootDir, privateModules);
|
|
49730
49730
|
}
|
|
49731
49731
|
xi18n(ctx) {
|
|
49732
49732
|
const compilation = this.ensureAnalyzed();
|
|
@@ -50560,8 +50560,8 @@ var NgtscProgram = class {
|
|
|
50560
50560
|
getIndexedComponents() {
|
|
50561
50561
|
return this.compiler.getIndexedComponents();
|
|
50562
50562
|
}
|
|
50563
|
-
getApiDocumentation(entryPoint) {
|
|
50564
|
-
return this.compiler.getApiDocumentation(entryPoint);
|
|
50563
|
+
getApiDocumentation(entryPoint, privateModules) {
|
|
50564
|
+
return this.compiler.getApiDocumentation(entryPoint, privateModules);
|
|
50565
50565
|
}
|
|
50566
50566
|
getEmittedSourceFiles() {
|
|
50567
50567
|
throw new Error("Method not implemented.");
|
|
@@ -50876,7 +50876,7 @@ function canMigrateFile(basePath, sourceFile, program) {
|
|
|
50876
50876
|
}
|
|
50877
50877
|
|
|
50878
50878
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/prune-modules.mjs
|
|
50879
|
-
var
|
|
50879
|
+
var import_typescript136 = __toESM(require("typescript"), 1);
|
|
50880
50880
|
|
|
50881
50881
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/utils/typescript/decorators.mjs
|
|
50882
50882
|
var import_typescript131 = __toESM(require("typescript"), 1);
|
|
@@ -51151,217 +51151,14 @@ function isClassReferenceInAngularModule(node, className, moduleName, typeChecke
|
|
|
51151
51151
|
}));
|
|
51152
51152
|
}
|
|
51153
51153
|
|
|
51154
|
-
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/prune-modules.mjs
|
|
51155
|
-
function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper, referenceLookupExcludedFiles) {
|
|
51156
|
-
const filesToRemove = /* @__PURE__ */ new Set();
|
|
51157
|
-
const tracker = new ChangeTracker(printer, importRemapper);
|
|
51158
|
-
const tsProgram = program.getTsProgram();
|
|
51159
|
-
const typeChecker = tsProgram.getTypeChecker();
|
|
51160
|
-
const referenceResolver = new ReferenceResolver(program, host, rootFileNames, basePath, referenceLookupExcludedFiles);
|
|
51161
|
-
const removalLocations = {
|
|
51162
|
-
arrays: new UniqueItemTracker(),
|
|
51163
|
-
imports: new UniqueItemTracker(),
|
|
51164
|
-
exports: new UniqueItemTracker(),
|
|
51165
|
-
unknown: /* @__PURE__ */ new Set()
|
|
51166
|
-
};
|
|
51167
|
-
const classesToRemove = /* @__PURE__ */ new Set();
|
|
51168
|
-
const barrelExports = new UniqueItemTracker();
|
|
51169
|
-
const nodesToRemove = /* @__PURE__ */ new Set();
|
|
51170
|
-
sourceFiles.forEach(function walk(node) {
|
|
51171
|
-
var _a2, _b2;
|
|
51172
|
-
if (import_typescript134.default.isClassDeclaration(node) && canRemoveClass(node, typeChecker)) {
|
|
51173
|
-
collectRemovalLocations(node, removalLocations, referenceResolver, program);
|
|
51174
|
-
classesToRemove.add(node);
|
|
51175
|
-
} else if (import_typescript134.default.isExportDeclaration(node) && !node.exportClause && node.moduleSpecifier && import_typescript134.default.isStringLiteralLike(node.moduleSpecifier) && node.moduleSpecifier.text.startsWith(".")) {
|
|
51176
|
-
const exportedSourceFile = (_b2 = (_a2 = typeChecker.getSymbolAtLocation(node.moduleSpecifier)) == null ? void 0 : _a2.valueDeclaration) == null ? void 0 : _b2.getSourceFile();
|
|
51177
|
-
if (exportedSourceFile) {
|
|
51178
|
-
barrelExports.track(exportedSourceFile, node);
|
|
51179
|
-
}
|
|
51180
|
-
}
|
|
51181
|
-
node.forEachChild(walk);
|
|
51182
|
-
});
|
|
51183
|
-
removeArrayReferences(removalLocations.arrays, tracker);
|
|
51184
|
-
removeImportReferences(removalLocations.imports, tracker);
|
|
51185
|
-
removeExportReferences(removalLocations.exports, tracker);
|
|
51186
|
-
addRemovalTodos(removalLocations.unknown, tracker);
|
|
51187
|
-
(function trackNodesToRemove(nodes) {
|
|
51188
|
-
for (const node of nodes) {
|
|
51189
|
-
const sourceFile = node.getSourceFile();
|
|
51190
|
-
if (!filesToRemove.has(sourceFile) && canRemoveFile(sourceFile, nodes)) {
|
|
51191
|
-
const barrelExportsForFile = barrelExports.get(sourceFile);
|
|
51192
|
-
nodesToRemove.add(node);
|
|
51193
|
-
filesToRemove.add(sourceFile);
|
|
51194
|
-
barrelExportsForFile && trackNodesToRemove(barrelExportsForFile);
|
|
51195
|
-
} else {
|
|
51196
|
-
nodesToRemove.add(node);
|
|
51197
|
-
}
|
|
51198
|
-
}
|
|
51199
|
-
})(classesToRemove);
|
|
51200
|
-
for (const node of nodesToRemove) {
|
|
51201
|
-
const sourceFile = node.getSourceFile();
|
|
51202
|
-
if (!filesToRemove.has(sourceFile) && canRemoveFile(sourceFile, nodesToRemove)) {
|
|
51203
|
-
filesToRemove.add(sourceFile);
|
|
51204
|
-
} else {
|
|
51205
|
-
tracker.removeNode(node);
|
|
51206
|
-
}
|
|
51207
|
-
}
|
|
51208
|
-
return { pendingChanges: tracker.recordChanges(), filesToRemove };
|
|
51209
|
-
}
|
|
51210
|
-
function collectRemovalLocations(ngModule, removalLocations, referenceResolver, program) {
|
|
51211
|
-
const refsByFile = referenceResolver.findReferencesInProject(ngModule.name);
|
|
51212
|
-
const tsProgram = program.getTsProgram();
|
|
51213
|
-
const nodes = /* @__PURE__ */ new Set();
|
|
51214
|
-
for (const [fileName, refs] of refsByFile) {
|
|
51215
|
-
const sourceFile = tsProgram.getSourceFile(fileName);
|
|
51216
|
-
if (sourceFile) {
|
|
51217
|
-
offsetsToNodes(getNodeLookup(sourceFile), refs, nodes);
|
|
51218
|
-
}
|
|
51219
|
-
}
|
|
51220
|
-
for (const node of nodes) {
|
|
51221
|
-
const closestArray = closestNode(node, import_typescript134.default.isArrayLiteralExpression);
|
|
51222
|
-
if (closestArray) {
|
|
51223
|
-
removalLocations.arrays.track(closestArray, node);
|
|
51224
|
-
continue;
|
|
51225
|
-
}
|
|
51226
|
-
const closestImport = closestNode(node, import_typescript134.default.isNamedImports);
|
|
51227
|
-
if (closestImport) {
|
|
51228
|
-
removalLocations.imports.track(closestImport, node);
|
|
51229
|
-
continue;
|
|
51230
|
-
}
|
|
51231
|
-
const closestExport = closestNode(node, import_typescript134.default.isNamedExports);
|
|
51232
|
-
if (closestExport) {
|
|
51233
|
-
removalLocations.exports.track(closestExport, node);
|
|
51234
|
-
continue;
|
|
51235
|
-
}
|
|
51236
|
-
removalLocations.unknown.add(node);
|
|
51237
|
-
}
|
|
51238
|
-
}
|
|
51239
|
-
function removeArrayReferences(locations, tracker) {
|
|
51240
|
-
for (const [array, toRemove] of locations.getEntries()) {
|
|
51241
|
-
const newElements = filterRemovedElements(array.elements, toRemove);
|
|
51242
|
-
tracker.replaceNode(array, import_typescript134.default.factory.updateArrayLiteralExpression(array, import_typescript134.default.factory.createNodeArray(newElements, array.elements.hasTrailingComma)));
|
|
51243
|
-
}
|
|
51244
|
-
}
|
|
51245
|
-
function removeImportReferences(locations, tracker) {
|
|
51246
|
-
for (const [namedImports, toRemove] of locations.getEntries()) {
|
|
51247
|
-
const newElements = filterRemovedElements(namedImports.elements, toRemove);
|
|
51248
|
-
if (newElements.length === 0) {
|
|
51249
|
-
const importClause = closestNode(namedImports, import_typescript134.default.isImportClause);
|
|
51250
|
-
if (importClause && importClause.name) {
|
|
51251
|
-
tracker.replaceNode(importClause, import_typescript134.default.factory.updateImportClause(importClause, importClause.isTypeOnly, importClause.name, void 0));
|
|
51252
|
-
} else {
|
|
51253
|
-
const declaration = closestNode(namedImports, import_typescript134.default.isImportDeclaration);
|
|
51254
|
-
if (declaration) {
|
|
51255
|
-
tracker.removeNode(declaration);
|
|
51256
|
-
}
|
|
51257
|
-
}
|
|
51258
|
-
} else {
|
|
51259
|
-
tracker.replaceNode(namedImports, import_typescript134.default.factory.updateNamedImports(namedImports, newElements));
|
|
51260
|
-
}
|
|
51261
|
-
}
|
|
51262
|
-
}
|
|
51263
|
-
function removeExportReferences(locations, tracker) {
|
|
51264
|
-
for (const [namedExports, toRemove] of locations.getEntries()) {
|
|
51265
|
-
const newElements = filterRemovedElements(namedExports.elements, toRemove);
|
|
51266
|
-
if (newElements.length === 0) {
|
|
51267
|
-
const declaration = closestNode(namedExports, import_typescript134.default.isExportDeclaration);
|
|
51268
|
-
if (declaration) {
|
|
51269
|
-
tracker.removeNode(declaration);
|
|
51270
|
-
}
|
|
51271
|
-
} else {
|
|
51272
|
-
tracker.replaceNode(namedExports, import_typescript134.default.factory.updateNamedExports(namedExports, newElements));
|
|
51273
|
-
}
|
|
51274
|
-
}
|
|
51275
|
-
}
|
|
51276
|
-
function canRemoveClass(node, typeChecker) {
|
|
51277
|
-
var _a2;
|
|
51278
|
-
const decorator = (_a2 = findNgModuleDecorator(node, typeChecker)) == null ? void 0 : _a2.node;
|
|
51279
|
-
if (!decorator || !import_typescript134.default.isCallExpression(decorator.expression)) {
|
|
51280
|
-
return false;
|
|
51281
|
-
}
|
|
51282
|
-
if (decorator.expression.arguments.length > 0 && !import_typescript134.default.isObjectLiteralExpression(decorator.expression.arguments[0])) {
|
|
51283
|
-
return false;
|
|
51284
|
-
}
|
|
51285
|
-
if (node.members.length > 0 && node.members.some((member) => !isEmptyConstructor(member))) {
|
|
51286
|
-
return false;
|
|
51287
|
-
}
|
|
51288
|
-
if (decorator.expression.arguments.length === 0) {
|
|
51289
|
-
return true;
|
|
51290
|
-
}
|
|
51291
|
-
const literal3 = decorator.expression.arguments[0];
|
|
51292
|
-
const imports = findLiteralProperty(literal3, "imports");
|
|
51293
|
-
if (imports && isNonEmptyNgModuleProperty(imports)) {
|
|
51294
|
-
for (const dep of imports.initializer.elements) {
|
|
51295
|
-
if (!import_typescript134.default.isIdentifier(dep)) {
|
|
51296
|
-
return false;
|
|
51297
|
-
}
|
|
51298
|
-
const depDeclaration = findClassDeclaration(dep, typeChecker);
|
|
51299
|
-
const depNgModule = depDeclaration ? findNgModuleDecorator(depDeclaration, typeChecker) : null;
|
|
51300
|
-
if (depDeclaration !== null && depNgModule !== null && !canRemoveClass(depDeclaration, typeChecker)) {
|
|
51301
|
-
return false;
|
|
51302
|
-
}
|
|
51303
|
-
}
|
|
51304
|
-
}
|
|
51305
|
-
for (const prop of literal3.properties) {
|
|
51306
|
-
if (isNonEmptyNgModuleProperty(prop) && (prop.name.text === "declarations" || prop.name.text === "providers" || prop.name.text === "bootstrap")) {
|
|
51307
|
-
return false;
|
|
51308
|
-
}
|
|
51309
|
-
}
|
|
51310
|
-
return true;
|
|
51311
|
-
}
|
|
51312
|
-
function isNonEmptyNgModuleProperty(node) {
|
|
51313
|
-
return import_typescript134.default.isPropertyAssignment(node) && import_typescript134.default.isIdentifier(node.name) && import_typescript134.default.isArrayLiteralExpression(node.initializer) && node.initializer.elements.length > 0;
|
|
51314
|
-
}
|
|
51315
|
-
function canRemoveFile(sourceFile, nodesToBeRemoved) {
|
|
51316
|
-
var _a2;
|
|
51317
|
-
for (const node of sourceFile.statements) {
|
|
51318
|
-
if (import_typescript134.default.isImportDeclaration(node) || nodesToBeRemoved.has(node)) {
|
|
51319
|
-
continue;
|
|
51320
|
-
}
|
|
51321
|
-
if (import_typescript134.default.isExportDeclaration(node) || import_typescript134.default.canHaveModifiers(node) && ((_a2 = import_typescript134.default.getModifiers(node)) == null ? void 0 : _a2.some((m) => m.kind === import_typescript134.default.SyntaxKind.ExportKeyword))) {
|
|
51322
|
-
return false;
|
|
51323
|
-
}
|
|
51324
|
-
}
|
|
51325
|
-
return true;
|
|
51326
|
-
}
|
|
51327
|
-
function contains(parent, child) {
|
|
51328
|
-
return parent === child || parent.getSourceFile().fileName === child.getSourceFile().fileName && child.getStart() >= parent.getStart() && child.getStart() <= parent.getEnd();
|
|
51329
|
-
}
|
|
51330
|
-
function filterRemovedElements(elements, toRemove) {
|
|
51331
|
-
return elements.filter((el) => {
|
|
51332
|
-
for (const node of toRemove) {
|
|
51333
|
-
if (contains(el, node)) {
|
|
51334
|
-
return false;
|
|
51335
|
-
}
|
|
51336
|
-
}
|
|
51337
|
-
return true;
|
|
51338
|
-
});
|
|
51339
|
-
}
|
|
51340
|
-
function isEmptyConstructor(node) {
|
|
51341
|
-
return import_typescript134.default.isConstructorDeclaration(node) && node.parameters.length === 0 && (node.body == null || node.body.statements.length === 0);
|
|
51342
|
-
}
|
|
51343
|
-
function addRemovalTodos(nodes, tracker) {
|
|
51344
|
-
for (const node of nodes) {
|
|
51345
|
-
tracker.insertText(node.getSourceFile(), node.getFullStart(), ` /* TODO(standalone-migration): clean up removed NgModule reference manually. */ `);
|
|
51346
|
-
}
|
|
51347
|
-
}
|
|
51348
|
-
function findNgModuleDecorator(node, typeChecker) {
|
|
51349
|
-
const decorators = getAngularDecorators2(typeChecker, import_typescript134.default.getDecorators(node) || []);
|
|
51350
|
-
return decorators.find((decorator) => decorator.name === "NgModule") || null;
|
|
51351
|
-
}
|
|
51352
|
-
|
|
51353
|
-
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/standalone-bootstrap.mjs
|
|
51354
|
-
var import_path6 = require("path");
|
|
51355
|
-
var import_typescript137 = __toESM(require("typescript"), 1);
|
|
51356
|
-
|
|
51357
51154
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/to-standalone.mjs
|
|
51358
|
-
var
|
|
51155
|
+
var import_typescript135 = __toESM(require("typescript"), 1);
|
|
51359
51156
|
|
|
51360
51157
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/utils/typescript/symbol.mjs
|
|
51361
|
-
var
|
|
51158
|
+
var import_typescript134 = __toESM(require("typescript"), 1);
|
|
51362
51159
|
function isReferenceToImport(typeChecker, node, importSpecifier) {
|
|
51363
51160
|
var _a2, _b2;
|
|
51364
|
-
if (
|
|
51161
|
+
if (import_typescript134.default.isIdentifier(node) && node.text !== importSpecifier.name.text) {
|
|
51365
51162
|
return false;
|
|
51366
51163
|
}
|
|
51367
51164
|
const nodeSymbol = typeChecker.getTypeAtLocation(node).getSymbol();
|
|
@@ -51408,8 +51205,8 @@ function convertNgModuleDeclarationToStandalone(decl, allDeclarations, tracker,
|
|
|
51408
51205
|
const importsToAdd = getComponentImportExpressions(decl, allDeclarations, tracker, typeChecker, importRemapper);
|
|
51409
51206
|
if (importsToAdd.length > 0) {
|
|
51410
51207
|
const hasTrailingComma = importsToAdd.length > 2 && !!((_a2 = extractMetadataLiteral(directiveMeta.decorator)) == null ? void 0 : _a2.properties.hasTrailingComma);
|
|
51411
|
-
decorator = addPropertyToAngularDecorator(decorator,
|
|
51412
|
-
|
|
51208
|
+
decorator = addPropertyToAngularDecorator(decorator, import_typescript135.default.factory.createPropertyAssignment("imports", import_typescript135.default.factory.createArrayLiteralExpression(
|
|
51209
|
+
import_typescript135.default.factory.createNodeArray(importsToAdd, hasTrailingComma),
|
|
51413
51210
|
hasTrailingComma
|
|
51414
51211
|
)));
|
|
51415
51212
|
}
|
|
@@ -51425,7 +51222,6 @@ function convertNgModuleDeclarationToStandalone(decl, allDeclarations, tracker,
|
|
|
51425
51222
|
function getComponentImportExpressions(decl, allDeclarations, tracker, typeChecker, importRemapper) {
|
|
51426
51223
|
const templateDependencies = findTemplateDependencies(decl, typeChecker);
|
|
51427
51224
|
const usedDependenciesInMigration = new Set(templateDependencies.filter((dep) => allDeclarations.has(dep.node)));
|
|
51428
|
-
const imports = [];
|
|
51429
51225
|
const seenImports = /* @__PURE__ */ new Set();
|
|
51430
51226
|
const resolvedDependencies = [];
|
|
51431
51227
|
for (const dep of templateDependencies) {
|
|
@@ -51435,23 +51231,22 @@ function getComponentImportExpressions(decl, allDeclarations, tracker, typeCheck
|
|
|
51435
51231
|
resolvedDependencies.push(importLocation);
|
|
51436
51232
|
}
|
|
51437
51233
|
}
|
|
51438
|
-
|
|
51439
|
-
|
|
51234
|
+
return potentialImportsToExpressions(resolvedDependencies, decl, tracker, importRemapper);
|
|
51235
|
+
}
|
|
51236
|
+
function potentialImportsToExpressions(potentialImports, component, tracker, importRemapper) {
|
|
51237
|
+
const processedDependencies = importRemapper ? importRemapper(potentialImports, component) : potentialImports;
|
|
51238
|
+
return processedDependencies.map((importLocation) => {
|
|
51440
51239
|
if (importLocation.moduleSpecifier) {
|
|
51441
|
-
|
|
51442
|
-
imports.push(identifier);
|
|
51443
|
-
} else {
|
|
51444
|
-
const identifier = import_typescript136.default.factory.createIdentifier(importLocation.symbolName);
|
|
51445
|
-
if (importLocation.isForwardReference) {
|
|
51446
|
-
const forwardRefExpression = tracker.addImport(decl.getSourceFile(), "forwardRef", "@angular/core");
|
|
51447
|
-
const arrowFunction = import_typescript136.default.factory.createArrowFunction(void 0, void 0, [], void 0, void 0, identifier);
|
|
51448
|
-
imports.push(import_typescript136.default.factory.createCallExpression(forwardRefExpression, void 0, [arrowFunction]));
|
|
51449
|
-
} else {
|
|
51450
|
-
imports.push(identifier);
|
|
51451
|
-
}
|
|
51240
|
+
return tracker.addImport(component.getSourceFile(), importLocation.symbolName, importLocation.moduleSpecifier);
|
|
51452
51241
|
}
|
|
51453
|
-
|
|
51454
|
-
|
|
51242
|
+
const identifier = import_typescript135.default.factory.createIdentifier(importLocation.symbolName);
|
|
51243
|
+
if (!importLocation.isForwardReference) {
|
|
51244
|
+
return identifier;
|
|
51245
|
+
}
|
|
51246
|
+
const forwardRefExpression = tracker.addImport(component.getSourceFile(), "forwardRef", "@angular/core");
|
|
51247
|
+
const arrowFunction = import_typescript135.default.factory.createArrowFunction(void 0, void 0, [], void 0, void 0, identifier);
|
|
51248
|
+
return import_typescript135.default.factory.createCallExpression(forwardRefExpression, void 0, [arrowFunction]);
|
|
51249
|
+
});
|
|
51455
51250
|
}
|
|
51456
51251
|
function migrateNgModuleClass(node, allDeclarations, tracker, typeChecker, templateTypeChecker) {
|
|
51457
51252
|
var _a2;
|
|
@@ -51470,11 +51265,11 @@ function moveDeclarationsToImports(literal3, allDeclarations, typeChecker, templ
|
|
|
51470
51265
|
const declarationsToCopy = [];
|
|
51471
51266
|
const properties = [];
|
|
51472
51267
|
const importsProp = findLiteralProperty(literal3, "imports");
|
|
51473
|
-
const hasAnyArrayTrailingComma = literal3.properties.some((prop) =>
|
|
51474
|
-
if (
|
|
51475
|
-
if (
|
|
51268
|
+
const hasAnyArrayTrailingComma = literal3.properties.some((prop) => import_typescript135.default.isPropertyAssignment(prop) && import_typescript135.default.isArrayLiteralExpression(prop.initializer) && prop.initializer.elements.hasTrailingComma);
|
|
51269
|
+
if (import_typescript135.default.isPropertyAssignment(declarationsProp)) {
|
|
51270
|
+
if (import_typescript135.default.isArrayLiteralExpression(declarationsProp.initializer)) {
|
|
51476
51271
|
for (const el of declarationsProp.initializer.elements) {
|
|
51477
|
-
if (
|
|
51272
|
+
if (import_typescript135.default.isIdentifier(el)) {
|
|
51478
51273
|
const correspondingClass = findClassDeclaration(el, typeChecker);
|
|
51479
51274
|
if (!correspondingClass || isStandaloneDeclaration(correspondingClass, allDeclarations, templateTypeChecker)) {
|
|
51480
51275
|
declarationsToCopy.push(el);
|
|
@@ -51486,11 +51281,11 @@ function moveDeclarationsToImports(literal3, allDeclarations, typeChecker, templ
|
|
|
51486
51281
|
}
|
|
51487
51282
|
}
|
|
51488
51283
|
} else {
|
|
51489
|
-
declarationsToCopy.push(
|
|
51284
|
+
declarationsToCopy.push(import_typescript135.default.factory.createSpreadElement(declarationsProp.initializer));
|
|
51490
51285
|
}
|
|
51491
51286
|
}
|
|
51492
51287
|
if (!importsProp && declarationsToCopy.length > 0) {
|
|
51493
|
-
properties.push(
|
|
51288
|
+
properties.push(import_typescript135.default.factory.createPropertyAssignment("imports", import_typescript135.default.factory.createArrayLiteralExpression(import_typescript135.default.factory.createNodeArray(declarationsToCopy, hasAnyArrayTrailingComma && declarationsToCopy.length > 2))));
|
|
51494
51289
|
}
|
|
51495
51290
|
for (const prop of literal3.properties) {
|
|
51496
51291
|
if (!isNamedPropertyAssignment(prop)) {
|
|
@@ -51499,51 +51294,51 @@ function moveDeclarationsToImports(literal3, allDeclarations, typeChecker, templ
|
|
|
51499
51294
|
}
|
|
51500
51295
|
if (prop === declarationsProp) {
|
|
51501
51296
|
if (declarationsToPreserve.length > 0) {
|
|
51502
|
-
const hasTrailingComma =
|
|
51503
|
-
properties.push(
|
|
51297
|
+
const hasTrailingComma = import_typescript135.default.isArrayLiteralExpression(prop.initializer) ? prop.initializer.elements.hasTrailingComma : hasAnyArrayTrailingComma;
|
|
51298
|
+
properties.push(import_typescript135.default.factory.updatePropertyAssignment(prop, prop.name, import_typescript135.default.factory.createArrayLiteralExpression(import_typescript135.default.factory.createNodeArray(declarationsToPreserve, hasTrailingComma && declarationsToPreserve.length > 2))));
|
|
51504
51299
|
}
|
|
51505
51300
|
continue;
|
|
51506
51301
|
}
|
|
51507
51302
|
if (prop === importsProp && declarationsToCopy.length > 0) {
|
|
51508
51303
|
let initializer;
|
|
51509
|
-
if (
|
|
51510
|
-
initializer =
|
|
51304
|
+
if (import_typescript135.default.isArrayLiteralExpression(prop.initializer)) {
|
|
51305
|
+
initializer = import_typescript135.default.factory.updateArrayLiteralExpression(prop.initializer, import_typescript135.default.factory.createNodeArray([...prop.initializer.elements, ...declarationsToCopy], prop.initializer.elements.hasTrailingComma));
|
|
51511
51306
|
} else {
|
|
51512
|
-
initializer =
|
|
51513
|
-
[
|
|
51307
|
+
initializer = import_typescript135.default.factory.createArrayLiteralExpression(import_typescript135.default.factory.createNodeArray(
|
|
51308
|
+
[import_typescript135.default.factory.createSpreadElement(prop.initializer), ...declarationsToCopy],
|
|
51514
51309
|
hasAnyArrayTrailingComma && declarationsToCopy.length > 1
|
|
51515
51310
|
));
|
|
51516
51311
|
}
|
|
51517
|
-
properties.push(
|
|
51312
|
+
properties.push(import_typescript135.default.factory.updatePropertyAssignment(prop, prop.name, initializer));
|
|
51518
51313
|
continue;
|
|
51519
51314
|
}
|
|
51520
51315
|
properties.push(prop);
|
|
51521
51316
|
}
|
|
51522
|
-
tracker.replaceNode(literal3,
|
|
51317
|
+
tracker.replaceNode(literal3, import_typescript135.default.factory.updateObjectLiteralExpression(literal3, import_typescript135.default.factory.createNodeArray(properties, literal3.properties.hasTrailingComma)), import_typescript135.default.EmitHint.Expression);
|
|
51523
51318
|
}
|
|
51524
51319
|
function addStandaloneToDecorator(node) {
|
|
51525
|
-
return addPropertyToAngularDecorator(node,
|
|
51320
|
+
return addPropertyToAngularDecorator(node, import_typescript135.default.factory.createPropertyAssignment("standalone", import_typescript135.default.factory.createToken(import_typescript135.default.SyntaxKind.TrueKeyword)));
|
|
51526
51321
|
}
|
|
51527
51322
|
function addPropertyToAngularDecorator(node, property2) {
|
|
51528
|
-
if (!
|
|
51323
|
+
if (!import_typescript135.default.isCallExpression(node.expression) || node.expression.arguments.length > 1) {
|
|
51529
51324
|
return node;
|
|
51530
51325
|
}
|
|
51531
51326
|
let literalProperties;
|
|
51532
51327
|
let hasTrailingComma = false;
|
|
51533
51328
|
if (node.expression.arguments.length === 0) {
|
|
51534
51329
|
literalProperties = [property2];
|
|
51535
|
-
} else if (
|
|
51330
|
+
} else if (import_typescript135.default.isObjectLiteralExpression(node.expression.arguments[0])) {
|
|
51536
51331
|
hasTrailingComma = node.expression.arguments[0].properties.hasTrailingComma;
|
|
51537
51332
|
literalProperties = [...node.expression.arguments[0].properties, property2];
|
|
51538
51333
|
} else {
|
|
51539
51334
|
return node;
|
|
51540
51335
|
}
|
|
51541
|
-
return
|
|
51542
|
-
|
|
51336
|
+
return import_typescript135.default.factory.createDecorator(import_typescript135.default.factory.createCallExpression(node.expression.expression, node.expression.typeArguments, [
|
|
51337
|
+
import_typescript135.default.factory.createObjectLiteralExpression(import_typescript135.default.factory.createNodeArray(literalProperties, hasTrailingComma), literalProperties.length > 1)
|
|
51543
51338
|
]));
|
|
51544
51339
|
}
|
|
51545
51340
|
function isNamedPropertyAssignment(node) {
|
|
51546
|
-
return
|
|
51341
|
+
return import_typescript135.default.isPropertyAssignment(node) && node.name && import_typescript135.default.isIdentifier(node.name);
|
|
51547
51342
|
}
|
|
51548
51343
|
function findImportLocation(target, inComponent, importMode, typeChecker) {
|
|
51549
51344
|
const importLocations = typeChecker.getPotentialImportsFor(target, inComponent, importMode);
|
|
@@ -51563,14 +51358,14 @@ function findImportLocation(target, inComponent, importMode, typeChecker) {
|
|
|
51563
51358
|
return firstSameFileImport || firstModuleImport || importLocations[0] || null;
|
|
51564
51359
|
}
|
|
51565
51360
|
function hasNgModuleMetadataElements(node) {
|
|
51566
|
-
return
|
|
51361
|
+
return import_typescript135.default.isPropertyAssignment(node) && (!import_typescript135.default.isArrayLiteralExpression(node.initializer) || node.initializer.elements.length > 0);
|
|
51567
51362
|
}
|
|
51568
51363
|
function findNgModuleClassesToMigrate(sourceFile, typeChecker) {
|
|
51569
51364
|
const modules = [];
|
|
51570
51365
|
if (getImportSpecifier(sourceFile, "@angular/core", "NgModule")) {
|
|
51571
51366
|
sourceFile.forEachChild(function walk(node) {
|
|
51572
|
-
if (
|
|
51573
|
-
const decorator = getAngularDecorators2(typeChecker,
|
|
51367
|
+
if (import_typescript135.default.isClassDeclaration(node)) {
|
|
51368
|
+
const decorator = getAngularDecorators2(typeChecker, import_typescript135.default.getDecorators(node) || []).find((current) => current.name === "NgModule");
|
|
51574
51369
|
const metadata = decorator ? extractMetadataLiteral(decorator.node) : null;
|
|
51575
51370
|
if (metadata) {
|
|
51576
51371
|
const declarations = findLiteralProperty(metadata, "declarations");
|
|
@@ -51590,13 +51385,13 @@ function findTestObjectsToMigrate(sourceFile, typeChecker) {
|
|
|
51590
51385
|
const catalystImport = getImportSpecifier(sourceFile, /testing\/catalyst$/, "setupModule");
|
|
51591
51386
|
if (testBedImport || catalystImport) {
|
|
51592
51387
|
sourceFile.forEachChild(function walk(node) {
|
|
51593
|
-
const isObjectLiteralCall =
|
|
51388
|
+
const isObjectLiteralCall = import_typescript135.default.isCallExpression(node) && node.arguments.length > 0 && import_typescript135.default.isObjectLiteralExpression(node.arguments[0]);
|
|
51594
51389
|
const config = isObjectLiteralCall ? node.arguments[0] : null;
|
|
51595
|
-
const isTestBedCall = isObjectLiteralCall && testBedImport &&
|
|
51596
|
-
const isCatalystCall = isObjectLiteralCall && catalystImport &&
|
|
51390
|
+
const isTestBedCall = isObjectLiteralCall && testBedImport && import_typescript135.default.isPropertyAccessExpression(node.expression) && node.expression.name.text === "configureTestingModule" && isReferenceToImport(typeChecker, node.expression.expression, testBedImport);
|
|
51391
|
+
const isCatalystCall = isObjectLiteralCall && catalystImport && import_typescript135.default.isIdentifier(node.expression) && isReferenceToImport(typeChecker, node.expression, catalystImport);
|
|
51597
51392
|
if ((isTestBedCall || isCatalystCall) && config) {
|
|
51598
51393
|
const declarations = findLiteralProperty(config, "declarations");
|
|
51599
|
-
if (declarations &&
|
|
51394
|
+
if (declarations && import_typescript135.default.isPropertyAssignment(declarations) && import_typescript135.default.isArrayLiteralExpression(declarations.initializer) && declarations.initializer.elements.length > 0) {
|
|
51600
51395
|
testObjects.push(config);
|
|
51601
51396
|
}
|
|
51602
51397
|
}
|
|
@@ -51611,7 +51406,7 @@ function findTemplateDependencies(decl, typeChecker) {
|
|
|
51611
51406
|
const usedPipes = typeChecker.getUsedPipes(decl);
|
|
51612
51407
|
if (usedDirectives !== null) {
|
|
51613
51408
|
for (const dir of usedDirectives) {
|
|
51614
|
-
if (
|
|
51409
|
+
if (import_typescript135.default.isClassDeclaration(dir.ref.node)) {
|
|
51615
51410
|
results.push(dir.ref);
|
|
51616
51411
|
}
|
|
51617
51412
|
}
|
|
@@ -51619,7 +51414,7 @@ function findTemplateDependencies(decl, typeChecker) {
|
|
|
51619
51414
|
if (usedPipes !== null) {
|
|
51620
51415
|
const potentialPipes = typeChecker.getPotentialPipes(decl);
|
|
51621
51416
|
for (const pipe2 of potentialPipes) {
|
|
51622
|
-
if (
|
|
51417
|
+
if (import_typescript135.default.isClassDeclaration(pipe2.ref.node) && usedPipes.some((current) => pipe2.name === current)) {
|
|
51623
51418
|
results.push(pipe2.ref);
|
|
51624
51419
|
}
|
|
51625
51420
|
}
|
|
@@ -51633,12 +51428,12 @@ function filterNonBootstrappedDeclarations(declarations, ngModule, templateTypeC
|
|
|
51633
51428
|
if (!bootstrapProp) {
|
|
51634
51429
|
return declarations;
|
|
51635
51430
|
}
|
|
51636
|
-
if (!
|
|
51431
|
+
if (!import_typescript135.default.isPropertyAssignment(bootstrapProp) || !import_typescript135.default.isArrayLiteralExpression(bootstrapProp.initializer)) {
|
|
51637
51432
|
return [];
|
|
51638
51433
|
}
|
|
51639
51434
|
const bootstrappedClasses = /* @__PURE__ */ new Set();
|
|
51640
51435
|
for (const el of bootstrapProp.initializer.elements) {
|
|
51641
|
-
const referencedClass =
|
|
51436
|
+
const referencedClass = import_typescript135.default.isIdentifier(el) ? findClassDeclaration(el, typeChecker) : null;
|
|
51642
51437
|
if (referencedClass) {
|
|
51643
51438
|
bootstrappedClasses.add(referencedClass);
|
|
51644
51439
|
} else {
|
|
@@ -51649,14 +51444,14 @@ function filterNonBootstrappedDeclarations(declarations, ngModule, templateTypeC
|
|
|
51649
51444
|
}
|
|
51650
51445
|
function extractDeclarationsFromModule(ngModule, templateTypeChecker) {
|
|
51651
51446
|
const metadata = templateTypeChecker.getNgModuleMetadata(ngModule);
|
|
51652
|
-
return metadata ? metadata.declarations.filter((decl) =>
|
|
51447
|
+
return metadata ? metadata.declarations.filter((decl) => import_typescript135.default.isClassDeclaration(decl.node)).map((decl) => decl.node) : [];
|
|
51653
51448
|
}
|
|
51654
51449
|
function migrateTestDeclarations(testObjects, declarationsOutsideOfTestFiles, tracker, templateTypeChecker, typeChecker) {
|
|
51655
51450
|
var _a2;
|
|
51656
51451
|
const { decorators, componentImports } = analyzeTestingModules(testObjects, typeChecker);
|
|
51657
51452
|
const allDeclarations = new Set(declarationsOutsideOfTestFiles);
|
|
51658
51453
|
for (const decorator of decorators) {
|
|
51659
|
-
const closestClass = closestNode(decorator.node,
|
|
51454
|
+
const closestClass = closestNode(decorator.node, import_typescript135.default.isClassDeclaration);
|
|
51660
51455
|
if (decorator.name === "Pipe" || decorator.name === "Directive") {
|
|
51661
51456
|
tracker.replaceNode(decorator.node, addStandaloneToDecorator(decorator.node));
|
|
51662
51457
|
if (closestClass) {
|
|
@@ -51670,8 +51465,8 @@ function migrateTestDeclarations(testObjects, declarationsOutsideOfTestFiles, tr
|
|
|
51670
51465
|
}
|
|
51671
51466
|
if (importsToAdd && importsToAdd.size > 0) {
|
|
51672
51467
|
const hasTrailingComma = importsToAdd.size > 2 && !!((_a2 = extractMetadataLiteral(decorator.node)) == null ? void 0 : _a2.properties.hasTrailingComma);
|
|
51673
|
-
const importsArray =
|
|
51674
|
-
tracker.replaceNode(decorator.node, addPropertyToAngularDecorator(newDecorator,
|
|
51468
|
+
const importsArray = import_typescript135.default.factory.createNodeArray(Array.from(importsToAdd), hasTrailingComma);
|
|
51469
|
+
tracker.replaceNode(decorator.node, addPropertyToAngularDecorator(newDecorator, import_typescript135.default.factory.createPropertyAssignment("imports", import_typescript135.default.factory.createArrayLiteralExpression(importsArray))));
|
|
51675
51470
|
} else {
|
|
51676
51471
|
tracker.replaceNode(decorator.node, newDecorator);
|
|
51677
51472
|
}
|
|
@@ -51691,14 +51486,14 @@ function analyzeTestingModules(testObjects, typeChecker) {
|
|
|
51691
51486
|
continue;
|
|
51692
51487
|
}
|
|
51693
51488
|
const importsProp = findLiteralProperty(obj, "imports");
|
|
51694
|
-
const importElements = importsProp && hasNgModuleMetadataElements(importsProp) &&
|
|
51695
|
-
return !
|
|
51489
|
+
const importElements = importsProp && hasNgModuleMetadataElements(importsProp) && import_typescript135.default.isArrayLiteralExpression(importsProp.initializer) ? importsProp.initializer.elements.filter((el) => {
|
|
51490
|
+
return !import_typescript135.default.isCallExpression(el) && !isClassReferenceInAngularModule(el, /^BrowserAnimationsModule|NoopAnimationsModule$/, "platform-browser/animations", typeChecker);
|
|
51696
51491
|
}) : null;
|
|
51697
51492
|
for (const decl of declarations) {
|
|
51698
51493
|
if (seenDeclarations.has(decl)) {
|
|
51699
51494
|
continue;
|
|
51700
51495
|
}
|
|
51701
|
-
const [decorator] = getAngularDecorators2(typeChecker,
|
|
51496
|
+
const [decorator] = getAngularDecorators2(typeChecker, import_typescript135.default.getDecorators(decl) || []);
|
|
51702
51497
|
if (decorator) {
|
|
51703
51498
|
seenDeclarations.add(decl);
|
|
51704
51499
|
decorators.push(decorator);
|
|
@@ -51718,7 +51513,7 @@ function analyzeTestingModules(testObjects, typeChecker) {
|
|
|
51718
51513
|
function extractDeclarationsFromTestObject(obj, typeChecker) {
|
|
51719
51514
|
const results = [];
|
|
51720
51515
|
const declarations = findLiteralProperty(obj, "declarations");
|
|
51721
|
-
if (declarations && hasNgModuleMetadataElements(declarations) &&
|
|
51516
|
+
if (declarations && hasNgModuleMetadataElements(declarations) && import_typescript135.default.isArrayLiteralExpression(declarations.initializer)) {
|
|
51722
51517
|
for (const element2 of declarations.initializer.elements) {
|
|
51723
51518
|
const declaration = findClassDeclaration(element2, typeChecker);
|
|
51724
51519
|
if (declaration && declaration.getSourceFile().fileName === obj.getSourceFile().fileName) {
|
|
@@ -51729,7 +51524,7 @@ function extractDeclarationsFromTestObject(obj, typeChecker) {
|
|
|
51729
51524
|
return results;
|
|
51730
51525
|
}
|
|
51731
51526
|
function extractMetadataLiteral(decorator) {
|
|
51732
|
-
return
|
|
51527
|
+
return import_typescript135.default.isCallExpression(decorator.expression) && decorator.expression.arguments.length === 1 && import_typescript135.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
|
|
51733
51528
|
}
|
|
51734
51529
|
function isStandaloneDeclaration(node, declarationsInMigration, templateTypeChecker) {
|
|
51735
51530
|
if (declarationsInMigration.has(node)) {
|
|
@@ -51739,7 +51534,269 @@ function isStandaloneDeclaration(node, declarationsInMigration, templateTypeChec
|
|
|
51739
51534
|
return metadata != null && metadata.isStandalone;
|
|
51740
51535
|
}
|
|
51741
51536
|
|
|
51537
|
+
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/prune-modules.mjs
|
|
51538
|
+
function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper, referenceLookupExcludedFiles, componentImportRemapper) {
|
|
51539
|
+
const filesToRemove = /* @__PURE__ */ new Set();
|
|
51540
|
+
const tracker = new ChangeTracker(printer, importRemapper);
|
|
51541
|
+
const tsProgram = program.getTsProgram();
|
|
51542
|
+
const typeChecker = tsProgram.getTypeChecker();
|
|
51543
|
+
const templateTypeChecker = program.compiler.getTemplateTypeChecker();
|
|
51544
|
+
const referenceResolver = new ReferenceResolver(program, host, rootFileNames, basePath, referenceLookupExcludedFiles);
|
|
51545
|
+
const removalLocations = {
|
|
51546
|
+
arrays: new UniqueItemTracker(),
|
|
51547
|
+
imports: new UniqueItemTracker(),
|
|
51548
|
+
exports: new UniqueItemTracker(),
|
|
51549
|
+
unknown: /* @__PURE__ */ new Set()
|
|
51550
|
+
};
|
|
51551
|
+
const classesToRemove = /* @__PURE__ */ new Set();
|
|
51552
|
+
const barrelExports = new UniqueItemTracker();
|
|
51553
|
+
const componentImportArrays = new UniqueItemTracker();
|
|
51554
|
+
const nodesToRemove = /* @__PURE__ */ new Set();
|
|
51555
|
+
sourceFiles.forEach(function walk(node) {
|
|
51556
|
+
var _a2, _b2;
|
|
51557
|
+
if (import_typescript136.default.isClassDeclaration(node) && canRemoveClass(node, typeChecker)) {
|
|
51558
|
+
collectChangeLocations(node, removalLocations, componentImportArrays, templateTypeChecker, referenceResolver, program);
|
|
51559
|
+
classesToRemove.add(node);
|
|
51560
|
+
} else if (import_typescript136.default.isExportDeclaration(node) && !node.exportClause && node.moduleSpecifier && import_typescript136.default.isStringLiteralLike(node.moduleSpecifier) && node.moduleSpecifier.text.startsWith(".")) {
|
|
51561
|
+
const exportedSourceFile = (_b2 = (_a2 = typeChecker.getSymbolAtLocation(node.moduleSpecifier)) == null ? void 0 : _a2.valueDeclaration) == null ? void 0 : _b2.getSourceFile();
|
|
51562
|
+
if (exportedSourceFile) {
|
|
51563
|
+
barrelExports.track(exportedSourceFile, node);
|
|
51564
|
+
}
|
|
51565
|
+
}
|
|
51566
|
+
node.forEachChild(walk);
|
|
51567
|
+
});
|
|
51568
|
+
replaceInImportsArray(componentImportArrays, classesToRemove, tracker, typeChecker, templateTypeChecker, componentImportRemapper);
|
|
51569
|
+
removeArrayReferences(removalLocations.arrays, tracker);
|
|
51570
|
+
removeImportReferences(removalLocations.imports, tracker);
|
|
51571
|
+
removeExportReferences(removalLocations.exports, tracker);
|
|
51572
|
+
addRemovalTodos(removalLocations.unknown, tracker);
|
|
51573
|
+
(function trackNodesToRemove(nodes) {
|
|
51574
|
+
for (const node of nodes) {
|
|
51575
|
+
const sourceFile = node.getSourceFile();
|
|
51576
|
+
if (!filesToRemove.has(sourceFile) && canRemoveFile(sourceFile, nodes)) {
|
|
51577
|
+
const barrelExportsForFile = barrelExports.get(sourceFile);
|
|
51578
|
+
nodesToRemove.add(node);
|
|
51579
|
+
filesToRemove.add(sourceFile);
|
|
51580
|
+
barrelExportsForFile && trackNodesToRemove(barrelExportsForFile);
|
|
51581
|
+
} else {
|
|
51582
|
+
nodesToRemove.add(node);
|
|
51583
|
+
}
|
|
51584
|
+
}
|
|
51585
|
+
})(classesToRemove);
|
|
51586
|
+
for (const node of nodesToRemove) {
|
|
51587
|
+
const sourceFile = node.getSourceFile();
|
|
51588
|
+
if (!filesToRemove.has(sourceFile) && canRemoveFile(sourceFile, nodesToRemove)) {
|
|
51589
|
+
filesToRemove.add(sourceFile);
|
|
51590
|
+
} else {
|
|
51591
|
+
tracker.removeNode(node);
|
|
51592
|
+
}
|
|
51593
|
+
}
|
|
51594
|
+
return { pendingChanges: tracker.recordChanges(), filesToRemove };
|
|
51595
|
+
}
|
|
51596
|
+
function collectChangeLocations(ngModule, removalLocations, componentImportArrays, templateTypeChecker, referenceResolver, program) {
|
|
51597
|
+
const refsByFile = referenceResolver.findReferencesInProject(ngModule.name);
|
|
51598
|
+
const tsProgram = program.getTsProgram();
|
|
51599
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
51600
|
+
for (const [fileName, refs] of refsByFile) {
|
|
51601
|
+
const sourceFile = tsProgram.getSourceFile(fileName);
|
|
51602
|
+
if (sourceFile) {
|
|
51603
|
+
offsetsToNodes(getNodeLookup(sourceFile), refs, nodes);
|
|
51604
|
+
}
|
|
51605
|
+
}
|
|
51606
|
+
for (const node of nodes) {
|
|
51607
|
+
const closestArray = closestNode(node, import_typescript136.default.isArrayLiteralExpression);
|
|
51608
|
+
if (closestArray) {
|
|
51609
|
+
const closestAssignment = closestNode(closestArray, import_typescript136.default.isPropertyAssignment);
|
|
51610
|
+
if (closestAssignment && isInImportsArray(closestAssignment, closestArray)) {
|
|
51611
|
+
const closestDecorator = closestNode(closestAssignment, import_typescript136.default.isDecorator);
|
|
51612
|
+
const closestClass = closestDecorator ? closestNode(closestDecorator, import_typescript136.default.isClassDeclaration) : null;
|
|
51613
|
+
const directiveMeta = closestClass ? templateTypeChecker.getDirectiveMetadata(closestClass) : null;
|
|
51614
|
+
if (directiveMeta && directiveMeta.isComponent && directiveMeta.isStandalone) {
|
|
51615
|
+
componentImportArrays.track(closestArray, node);
|
|
51616
|
+
continue;
|
|
51617
|
+
}
|
|
51618
|
+
}
|
|
51619
|
+
removalLocations.arrays.track(closestArray, node);
|
|
51620
|
+
continue;
|
|
51621
|
+
}
|
|
51622
|
+
const closestImport = closestNode(node, import_typescript136.default.isNamedImports);
|
|
51623
|
+
if (closestImport) {
|
|
51624
|
+
removalLocations.imports.track(closestImport, node);
|
|
51625
|
+
continue;
|
|
51626
|
+
}
|
|
51627
|
+
const closestExport = closestNode(node, import_typescript136.default.isNamedExports);
|
|
51628
|
+
if (closestExport) {
|
|
51629
|
+
removalLocations.exports.track(closestExport, node);
|
|
51630
|
+
continue;
|
|
51631
|
+
}
|
|
51632
|
+
removalLocations.unknown.add(node);
|
|
51633
|
+
}
|
|
51634
|
+
}
|
|
51635
|
+
function replaceInImportsArray(componentImportArrays, classesToRemove, tracker, typeChecker, templateTypeChecker, importRemapper) {
|
|
51636
|
+
for (const [array, toReplace] of componentImportArrays.getEntries()) {
|
|
51637
|
+
const closestClass = closestNode(array, import_typescript136.default.isClassDeclaration);
|
|
51638
|
+
if (!closestClass) {
|
|
51639
|
+
continue;
|
|
51640
|
+
}
|
|
51641
|
+
const replacements = new UniqueItemTracker();
|
|
51642
|
+
const usedImports = new Set(findTemplateDependencies(closestClass, templateTypeChecker).map((ref) => ref.node));
|
|
51643
|
+
for (const node of toReplace) {
|
|
51644
|
+
const moduleDecl = findClassDeclaration(node, typeChecker);
|
|
51645
|
+
if (moduleDecl) {
|
|
51646
|
+
const moduleMeta = templateTypeChecker.getNgModuleMetadata(moduleDecl);
|
|
51647
|
+
if (moduleMeta) {
|
|
51648
|
+
moduleMeta.exports.forEach((exp) => {
|
|
51649
|
+
if (usedImports.has(exp.node)) {
|
|
51650
|
+
replacements.track(node, exp);
|
|
51651
|
+
}
|
|
51652
|
+
});
|
|
51653
|
+
} else {
|
|
51654
|
+
classesToRemove.delete(moduleDecl);
|
|
51655
|
+
}
|
|
51656
|
+
}
|
|
51657
|
+
}
|
|
51658
|
+
replaceModulesInImportsArray(array, closestClass, replacements, tracker, templateTypeChecker, importRemapper);
|
|
51659
|
+
}
|
|
51660
|
+
}
|
|
51661
|
+
function replaceModulesInImportsArray(array, componentClass, replacements, tracker, templateTypeChecker, importRemapper) {
|
|
51662
|
+
const newElements = [];
|
|
51663
|
+
for (const element2 of array.elements) {
|
|
51664
|
+
const replacementRefs = replacements.get(element2);
|
|
51665
|
+
if (!replacementRefs) {
|
|
51666
|
+
newElements.push(element2);
|
|
51667
|
+
continue;
|
|
51668
|
+
}
|
|
51669
|
+
const potentialImports = [];
|
|
51670
|
+
for (const ref of replacementRefs) {
|
|
51671
|
+
const importLocation = findImportLocation(ref, componentClass, PotentialImportMode.Normal, templateTypeChecker);
|
|
51672
|
+
if (importLocation) {
|
|
51673
|
+
potentialImports.push(importLocation);
|
|
51674
|
+
}
|
|
51675
|
+
}
|
|
51676
|
+
newElements.push(...potentialImportsToExpressions(potentialImports, componentClass, tracker, importRemapper));
|
|
51677
|
+
}
|
|
51678
|
+
tracker.replaceNode(array, import_typescript136.default.factory.updateArrayLiteralExpression(array, newElements));
|
|
51679
|
+
}
|
|
51680
|
+
function removeArrayReferences(locations, tracker) {
|
|
51681
|
+
for (const [array, toRemove] of locations.getEntries()) {
|
|
51682
|
+
const newElements = filterRemovedElements(array.elements, toRemove);
|
|
51683
|
+
tracker.replaceNode(array, import_typescript136.default.factory.updateArrayLiteralExpression(array, import_typescript136.default.factory.createNodeArray(newElements, array.elements.hasTrailingComma)));
|
|
51684
|
+
}
|
|
51685
|
+
}
|
|
51686
|
+
function removeImportReferences(locations, tracker) {
|
|
51687
|
+
for (const [namedImports, toRemove] of locations.getEntries()) {
|
|
51688
|
+
const newElements = filterRemovedElements(namedImports.elements, toRemove);
|
|
51689
|
+
if (newElements.length === 0) {
|
|
51690
|
+
const importClause = closestNode(namedImports, import_typescript136.default.isImportClause);
|
|
51691
|
+
if (importClause && importClause.name) {
|
|
51692
|
+
tracker.replaceNode(importClause, import_typescript136.default.factory.updateImportClause(importClause, importClause.isTypeOnly, importClause.name, void 0));
|
|
51693
|
+
} else {
|
|
51694
|
+
const declaration = closestNode(namedImports, import_typescript136.default.isImportDeclaration);
|
|
51695
|
+
if (declaration) {
|
|
51696
|
+
tracker.removeNode(declaration);
|
|
51697
|
+
}
|
|
51698
|
+
}
|
|
51699
|
+
} else {
|
|
51700
|
+
tracker.replaceNode(namedImports, import_typescript136.default.factory.updateNamedImports(namedImports, newElements));
|
|
51701
|
+
}
|
|
51702
|
+
}
|
|
51703
|
+
}
|
|
51704
|
+
function removeExportReferences(locations, tracker) {
|
|
51705
|
+
for (const [namedExports, toRemove] of locations.getEntries()) {
|
|
51706
|
+
const newElements = filterRemovedElements(namedExports.elements, toRemove);
|
|
51707
|
+
if (newElements.length === 0) {
|
|
51708
|
+
const declaration = closestNode(namedExports, import_typescript136.default.isExportDeclaration);
|
|
51709
|
+
if (declaration) {
|
|
51710
|
+
tracker.removeNode(declaration);
|
|
51711
|
+
}
|
|
51712
|
+
} else {
|
|
51713
|
+
tracker.replaceNode(namedExports, import_typescript136.default.factory.updateNamedExports(namedExports, newElements));
|
|
51714
|
+
}
|
|
51715
|
+
}
|
|
51716
|
+
}
|
|
51717
|
+
function canRemoveClass(node, typeChecker) {
|
|
51718
|
+
var _a2;
|
|
51719
|
+
const decorator = (_a2 = findNgModuleDecorator(node, typeChecker)) == null ? void 0 : _a2.node;
|
|
51720
|
+
if (!decorator || !import_typescript136.default.isCallExpression(decorator.expression)) {
|
|
51721
|
+
return false;
|
|
51722
|
+
}
|
|
51723
|
+
if (decorator.expression.arguments.length > 0 && !import_typescript136.default.isObjectLiteralExpression(decorator.expression.arguments[0])) {
|
|
51724
|
+
return false;
|
|
51725
|
+
}
|
|
51726
|
+
if (node.members.length > 0 && node.members.some((member) => !isEmptyConstructor(member))) {
|
|
51727
|
+
return false;
|
|
51728
|
+
}
|
|
51729
|
+
if (decorator.expression.arguments.length === 0) {
|
|
51730
|
+
return true;
|
|
51731
|
+
}
|
|
51732
|
+
const literal3 = decorator.expression.arguments[0];
|
|
51733
|
+
const imports = findLiteralProperty(literal3, "imports");
|
|
51734
|
+
if (imports && isNonEmptyNgModuleProperty(imports)) {
|
|
51735
|
+
for (const dep of imports.initializer.elements) {
|
|
51736
|
+
if (!import_typescript136.default.isIdentifier(dep)) {
|
|
51737
|
+
return false;
|
|
51738
|
+
}
|
|
51739
|
+
const depDeclaration = findClassDeclaration(dep, typeChecker);
|
|
51740
|
+
const depNgModule = depDeclaration ? findNgModuleDecorator(depDeclaration, typeChecker) : null;
|
|
51741
|
+
if (depDeclaration !== null && depNgModule !== null && !canRemoveClass(depDeclaration, typeChecker)) {
|
|
51742
|
+
return false;
|
|
51743
|
+
}
|
|
51744
|
+
}
|
|
51745
|
+
}
|
|
51746
|
+
for (const prop of literal3.properties) {
|
|
51747
|
+
if (isNonEmptyNgModuleProperty(prop) && (prop.name.text === "declarations" || prop.name.text === "providers" || prop.name.text === "bootstrap")) {
|
|
51748
|
+
return false;
|
|
51749
|
+
}
|
|
51750
|
+
}
|
|
51751
|
+
return true;
|
|
51752
|
+
}
|
|
51753
|
+
function isNonEmptyNgModuleProperty(node) {
|
|
51754
|
+
return import_typescript136.default.isPropertyAssignment(node) && import_typescript136.default.isIdentifier(node.name) && import_typescript136.default.isArrayLiteralExpression(node.initializer) && node.initializer.elements.length > 0;
|
|
51755
|
+
}
|
|
51756
|
+
function canRemoveFile(sourceFile, nodesToBeRemoved) {
|
|
51757
|
+
var _a2;
|
|
51758
|
+
for (const node of sourceFile.statements) {
|
|
51759
|
+
if (import_typescript136.default.isImportDeclaration(node) || nodesToBeRemoved.has(node)) {
|
|
51760
|
+
continue;
|
|
51761
|
+
}
|
|
51762
|
+
if (import_typescript136.default.isExportDeclaration(node) || import_typescript136.default.canHaveModifiers(node) && ((_a2 = import_typescript136.default.getModifiers(node)) == null ? void 0 : _a2.some((m) => m.kind === import_typescript136.default.SyntaxKind.ExportKeyword))) {
|
|
51763
|
+
return false;
|
|
51764
|
+
}
|
|
51765
|
+
}
|
|
51766
|
+
return true;
|
|
51767
|
+
}
|
|
51768
|
+
function contains(parent, child) {
|
|
51769
|
+
return parent === child || parent.getSourceFile().fileName === child.getSourceFile().fileName && child.getStart() >= parent.getStart() && child.getStart() <= parent.getEnd();
|
|
51770
|
+
}
|
|
51771
|
+
function filterRemovedElements(elements, toRemove) {
|
|
51772
|
+
return elements.filter((el) => {
|
|
51773
|
+
for (const node of toRemove) {
|
|
51774
|
+
if (contains(el, node)) {
|
|
51775
|
+
return false;
|
|
51776
|
+
}
|
|
51777
|
+
}
|
|
51778
|
+
return true;
|
|
51779
|
+
});
|
|
51780
|
+
}
|
|
51781
|
+
function isEmptyConstructor(node) {
|
|
51782
|
+
return import_typescript136.default.isConstructorDeclaration(node) && node.parameters.length === 0 && (node.body == null || node.body.statements.length === 0);
|
|
51783
|
+
}
|
|
51784
|
+
function addRemovalTodos(nodes, tracker) {
|
|
51785
|
+
for (const node of nodes) {
|
|
51786
|
+
tracker.insertText(node.getSourceFile(), node.getFullStart(), ` /* TODO(standalone-migration): clean up removed NgModule reference manually. */ `);
|
|
51787
|
+
}
|
|
51788
|
+
}
|
|
51789
|
+
function findNgModuleDecorator(node, typeChecker) {
|
|
51790
|
+
const decorators = getAngularDecorators2(typeChecker, import_typescript136.default.getDecorators(node) || []);
|
|
51791
|
+
return decorators.find((decorator) => decorator.name === "NgModule") || null;
|
|
51792
|
+
}
|
|
51793
|
+
function isInImportsArray(closestAssignment, closestArray) {
|
|
51794
|
+
return closestAssignment.initializer === closestArray && (import_typescript136.default.isIdentifier(closestAssignment.name) || import_typescript136.default.isStringLiteralLike(closestAssignment.name)) && closestAssignment.name.text === "imports";
|
|
51795
|
+
}
|
|
51796
|
+
|
|
51742
51797
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/standalone-bootstrap.mjs
|
|
51798
|
+
var import_path6 = require("path");
|
|
51799
|
+
var import_typescript137 = __toESM(require("typescript"), 1);
|
|
51743
51800
|
function toStandaloneBootstrap(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper, referenceLookupExcludedFiles, componentImportRemapper) {
|
|
51744
51801
|
const tracker = new ChangeTracker(printer, importRemapper);
|
|
51745
51802
|
const typeChecker = program.getTsProgram().getTypeChecker();
|
|
@@ -52167,7 +52224,7 @@ function standaloneMigration(tree, tsconfigPath, basePath, pathToMigrate, schema
|
|
|
52167
52224
|
let pendingChanges;
|
|
52168
52225
|
let filesToRemove = null;
|
|
52169
52226
|
if (schematicOptions.mode === MigrationMode.pruneModules) {
|
|
52170
|
-
const result = pruneNgModules(program, host, basePath, rootNames, sourceFiles, printer, void 0, referenceLookupExcludedFiles);
|
|
52227
|
+
const result = pruneNgModules(program, host, basePath, rootNames, sourceFiles, printer, void 0, referenceLookupExcludedFiles, knownInternalAliasRemapper);
|
|
52171
52228
|
pendingChanges = result.pendingChanges;
|
|
52172
52229
|
filesToRemove = result.filesToRemove;
|
|
52173
52230
|
} else if (schematicOptions.mode === MigrationMode.standaloneBootstrap) {
|