Skip to content

Commit 4bb23dd

Browse files
committed
d0c74f3 fix(compiler-cli): report when NgModule imports or exports itself (#58231)
1 parent 15e9390 commit 4bb23dd

21 files changed

+60
-47
lines changed

BUILD_INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Fri Oct 18 08:17:31 UTC 2024
2-
8311f00faaf282d1a5b1ddca29247a2fba94a692
1+
Fri Oct 18 09:32:31 UTC 2024
2+
d0c74f3891eed2feae913256ab15ac1e7435c379

bundles/chunk-5AXLJZ3D.js renamed to bundles/chunk-2KSGTNY4.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

bundles/chunk-Q4DA5WRV.js renamed to bundles/chunk-GVXGZHIM.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4074,6 +4074,7 @@ function makeUnknownComponentDeferredImportDiagnostic(ref, rawExpr) {
40744074
}
40754075

40764076
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/local.mjs
4077+
var IN_PROGRESS_RESOLUTION = {};
40774078
var LocalModuleScopeRegistry = class {
40784079
constructor(localReader, fullReader, dependencyScopeReader, refEmitter, aliasingHost) {
40794080
this.localReader = localReader;
@@ -4146,8 +4147,12 @@ var LocalModuleScopeRegistry = class {
41464147
}
41474148
getScopeOfModuleReference(ref) {
41484149
if (this.cache.has(ref.node)) {
4149-
return this.cache.get(ref.node);
4150+
const cachedValue = this.cache.get(ref.node);
4151+
if (cachedValue !== IN_PROGRESS_RESOLUTION) {
4152+
return cachedValue;
4153+
}
41504154
}
4155+
this.cache.set(ref.node, IN_PROGRESS_RESOLUTION);
41514156
this.sealed = true;
41524157
const ngModule = this.localReader.getNgModuleMetadata(ref);
41534158
if (ngModule === null) {
@@ -4167,10 +4172,12 @@ var LocalModuleScopeRegistry = class {
41674172
for (const decl of ngModule.imports) {
41684173
const importScope = this.getExportedScope(decl, diagnostics, ref.node, "import");
41694174
if (importScope !== null) {
4170-
if (importScope === "invalid" || importScope.exported.isPoisoned) {
4171-
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, "import"));
4175+
if (importScope === "invalid" || importScope === "cycle" || importScope.exported.isPoisoned) {
41724176
isPoisoned = true;
4173-
if (importScope === "invalid") {
4177+
if (importScope !== "cycle") {
4178+
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, "import"));
4179+
}
4180+
if (importScope === "invalid" || importScope === "cycle") {
41744181
continue;
41754182
}
41764183
}
@@ -4237,10 +4244,12 @@ var LocalModuleScopeRegistry = class {
42374244
}
42384245
for (const decl of ngModule.exports) {
42394246
const exportScope = this.getExportedScope(decl, diagnostics, ref.node, "export");
4240-
if (exportScope === "invalid" || exportScope !== null && exportScope.exported.isPoisoned) {
4241-
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, "export"));
4247+
if (exportScope === "invalid" || exportScope === "cycle" || exportScope !== null && exportScope.exported.isPoisoned) {
42424248
isPoisoned = true;
4243-
if (exportScope === "invalid") {
4249+
if (exportScope !== "cycle") {
4250+
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, "export"));
4251+
}
4252+
if (exportScope === "invalid" || exportScope === "cycle") {
42444253
continue;
42454254
}
42464255
} else if (exportScope !== null) {
@@ -4308,6 +4317,10 @@ var LocalModuleScopeRegistry = class {
43084317
}
43094318
return this.dependencyScopeReader.resolve(ref);
43104319
} else {
4320+
if (this.cache.get(ref.node) === IN_PROGRESS_RESOLUTION) {
4321+
diagnostics.push(makeDiagnostic(type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT, identifierOfNode(ref.node) || ref.node, `NgModule "${type}" field contains a cycle`));
4322+
return "cycle";
4323+
}
43114324
return this.getScopeOfModuleReference(ref);
43124325
}
43134326
}
@@ -15029,4 +15042,4 @@ export {
1502915042
* Use of this source code is governed by an MIT-style license that can be
1503015043
* found in the LICENSE file at https://angular.io/license
1503115044
*/
15032-
//# sourceMappingURL=chunk-Q4DA5WRV.js.map
15045+
//# sourceMappingURL=chunk-GVXGZHIM.js.map

bundles/chunk-GVXGZHIM.js.map

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundles/chunk-EJZF542V.js renamed to bundles/chunk-I7ZLTQZI.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

bundles/chunk-CE344QNW.js renamed to bundles/chunk-KGEMNMTH.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

bundles/chunk-Q4DA5WRV.js.map

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)