@angular/compiler-cli 14.0.0-rc.0 → 14.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/bundles/chunk-7XY4OMWJ.js +2 -2
  2. package/bundles/{chunk-N6HUFHQ6.js → chunk-AWUSLKAS.js} +26 -21
  3. package/bundles/chunk-AWUSLKAS.js.map +6 -0
  4. package/bundles/{chunk-KPGMJT2X.js → chunk-EN4WVK2E.js} +2 -2
  5. package/bundles/{chunk-KPGMJT2X.js.map → chunk-EN4WVK2E.js.map} +0 -0
  6. package/bundles/{chunk-GJVJ6GH4.js → chunk-GWA6QBDZ.js} +160 -110
  7. package/bundles/chunk-GWA6QBDZ.js.map +6 -0
  8. package/bundles/{chunk-53V6MPBS.js → chunk-I7TI6THJ.js} +3 -3
  9. package/bundles/{chunk-53V6MPBS.js.map → chunk-I7TI6THJ.js.map} +0 -0
  10. package/bundles/{chunk-BHGVN4MI.js → chunk-KAZROYQX.js} +3 -3
  11. package/bundles/{chunk-BHGVN4MI.js.map → chunk-KAZROYQX.js.map} +0 -0
  12. package/bundles/index.js +3 -3
  13. package/bundles/linker/babel/index.js +4 -4
  14. package/bundles/linker/babel/index.js.map +1 -1
  15. package/bundles/ngcc/index.js +4 -4
  16. package/bundles/ngcc/main-ngcc.js +4 -4
  17. package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +3 -3
  18. package/bundles/private/migrations.js +1 -1
  19. package/bundles/src/bin/ng_xi18n.js +3 -3
  20. package/bundles/src/bin/ngc.js +3 -3
  21. package/bundles_metadata.json +1 -1
  22. package/ngcc/src/packages/build_marker.d.ts +1 -1
  23. package/package.json +2 -2
  24. package/src/ngtsc/annotations/common/src/util.d.ts +6 -0
  25. package/src/ngtsc/annotations/component/src/handler.d.ts +1 -1
  26. package/src/ngtsc/annotations/ng_module/index.d.ts +1 -0
  27. package/src/ngtsc/annotations/ng_module/src/handler.d.ts +2 -20
  28. package/src/ngtsc/annotations/ng_module/src/module_with_providers.d.ts +26 -0
  29. package/src/ngtsc/typecheck/api/api.d.ts +1 -0
  30. package/src/ngtsc/typecheck/api/context.d.ts +2 -1
  31. package/src/ngtsc/typecheck/src/context.d.ts +1 -1
  32. package/src/ngtsc/typecheck/src/dom.d.ts +6 -4
  33. package/src/ngtsc/typecheck/src/type_check_block.d.ts +2 -1
  34. package/bundles/chunk-GJVJ6GH4.js.map +0 -6
  35. package/bundles/chunk-N6HUFHQ6.js.map +0 -6
@@ -274,6 +274,15 @@ function resolveImportedFile(moduleResolver, importedFile, expr, origin) {
274
274
  }
275
275
  return moduleResolver.resolveModule(expr.value.moduleName, origin.fileName);
276
276
  }
277
+ function getOriginNodeForDiagnostics(expr, container) {
278
+ const nodeSf = expr.getSourceFile();
279
+ const exprSf = container.getSourceFile();
280
+ if (nodeSf === exprSf && expr.pos >= container.pos && expr.end <= container.end) {
281
+ return expr;
282
+ } else {
283
+ return container;
284
+ }
285
+ }
277
286
 
278
287
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/dynamic.mjs
279
288
  var DynamicValue = class {
@@ -1707,7 +1716,7 @@ function extractSchemas(rawExpr, evaluator, context) {
1707
1716
 
1708
1717
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/handler.mjs
1709
1718
  import { compileClassMetadata as compileClassMetadata3, compileComponentFromMetadata, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareComponentFromMetadata, CssSelector as CssSelector2, DEFAULT_INTERPOLATION_CONFIG as DEFAULT_INTERPOLATION_CONFIG2, DomElementSchemaRegistry, FactoryTarget as FactoryTarget3, makeBindingParser as makeBindingParser2, R3TargetBinder, R3TemplateDependencyKind, SelectorMatcher as SelectorMatcher2, ViewEncapsulation, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
1710
- import ts23 from "typescript";
1719
+ import ts24 from "typescript";
1711
1720
 
1712
1721
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/api.mjs
1713
1722
  import ts8 from "typescript";
@@ -4569,8 +4578,77 @@ var DirectiveDecoratorHandler = class {
4569
4578
  };
4570
4579
 
4571
4580
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.mjs
4572
- import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as ExternalExpr5, FactoryTarget as FactoryTarget2, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr2, R3Identifiers, R3SelectorScopeMode, WrappedNodeExpr as WrappedNodeExpr6 } from "@angular/compiler";
4581
+ import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as ExternalExpr5, FactoryTarget as FactoryTarget2, FunctionExpr as FunctionExpr2, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr2, R3Identifiers, R3SelectorScopeMode, ReturnStatement as ReturnStatement2, WrappedNodeExpr as WrappedNodeExpr6 } from "@angular/compiler";
4582
+ import ts22 from "typescript";
4583
+
4584
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/ng_module/src/module_with_providers.mjs
4573
4585
  import ts21 from "typescript";
4586
+ function createModuleWithProvidersResolver(reflector, isCore) {
4587
+ function _reflectModuleFromTypeParam(type, node) {
4588
+ if (!ts21.isTypeReferenceNode(type)) {
4589
+ return null;
4590
+ }
4591
+ const typeName = type && (ts21.isIdentifier(type.typeName) && type.typeName || ts21.isQualifiedName(type.typeName) && type.typeName.right) || null;
4592
+ if (typeName === null) {
4593
+ return null;
4594
+ }
4595
+ const id = reflector.getImportOfIdentifier(typeName);
4596
+ if (id === null || id.name !== "ModuleWithProviders") {
4597
+ return null;
4598
+ }
4599
+ if (!isCore && id.from !== "@angular/core") {
4600
+ return null;
4601
+ }
4602
+ if (type.typeArguments === void 0 || type.typeArguments.length !== 1) {
4603
+ const parent = ts21.isMethodDeclaration(node) && ts21.isClassDeclaration(node.parent) ? node.parent : null;
4604
+ const symbolName = (parent && parent.name ? parent.name.getText() + "." : "") + (node.name ? node.name.getText() : "anonymous");
4605
+ throw new FatalDiagnosticError(ErrorCode.NGMODULE_MODULE_WITH_PROVIDERS_MISSING_GENERIC, type, `${symbolName} returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.`);
4606
+ }
4607
+ const arg = type.typeArguments[0];
4608
+ return typeNodeToValueExpr(arg);
4609
+ }
4610
+ function _reflectModuleFromLiteralType(type) {
4611
+ if (!ts21.isIntersectionTypeNode(type)) {
4612
+ return null;
4613
+ }
4614
+ for (const t of type.types) {
4615
+ if (ts21.isTypeLiteralNode(t)) {
4616
+ for (const m of t.members) {
4617
+ const ngModuleType = ts21.isPropertySignature(m) && ts21.isIdentifier(m.name) && m.name.text === "ngModule" && m.type || null;
4618
+ const ngModuleExpression = ngModuleType && typeNodeToValueExpr(ngModuleType);
4619
+ if (ngModuleExpression) {
4620
+ return ngModuleExpression;
4621
+ }
4622
+ }
4623
+ }
4624
+ }
4625
+ return null;
4626
+ }
4627
+ return (fn, callExpr, resolve, unresolvable) => {
4628
+ var _a;
4629
+ const rawType = fn.node.type;
4630
+ if (rawType === void 0) {
4631
+ return unresolvable;
4632
+ }
4633
+ const type = (_a = _reflectModuleFromTypeParam(rawType, fn.node)) != null ? _a : _reflectModuleFromLiteralType(rawType);
4634
+ if (type === null) {
4635
+ return unresolvable;
4636
+ }
4637
+ const ngModule = resolve(type);
4638
+ if (!(ngModule instanceof Reference) || !isNamedClassDeclaration(ngModule.node)) {
4639
+ return unresolvable;
4640
+ }
4641
+ return new SyntheticValue({
4642
+ ngModule,
4643
+ mwpCall: callExpr
4644
+ });
4645
+ };
4646
+ }
4647
+ function isResolvedModuleWithProviders(sv) {
4648
+ return typeof sv.value === "object" && sv.value != null && sv.value.hasOwnProperty("ngModule") && sv.value.hasOwnProperty("mwpCall");
4649
+ }
4650
+
4651
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.mjs
4574
4652
  var NgModuleSymbol = class extends SemanticSymbol {
4575
4653
  constructor() {
4576
4654
  super(...arguments);
@@ -4653,8 +4731,8 @@ var NgModuleDecoratorHandler = class {
4653
4731
  if (decorator.args === null || decorator.args.length > 1) {
4654
4732
  throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, Decorator.nodeForError(decorator), `Incorrect number of arguments to @NgModule decorator`);
4655
4733
  }
4656
- const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) : ts21.factory.createObjectLiteralExpression([]);
4657
- if (!ts21.isObjectLiteralExpression(meta)) {
4734
+ const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) : ts22.factory.createObjectLiteralExpression([]);
4735
+ if (!ts22.isObjectLiteralExpression(meta)) {
4658
4736
  throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@NgModule argument must be an object literal");
4659
4737
  }
4660
4738
  const ngModule = reflectObjectLiteral(meta);
@@ -4662,7 +4740,7 @@ var NgModuleDecoratorHandler = class {
4662
4740
  return {};
4663
4741
  }
4664
4742
  const moduleResolvers = combineResolvers([
4665
- (fn, call, resolve, unresolvable) => this._extractModuleFromModuleWithProvidersFn(fn, call, resolve, unresolvable),
4743
+ createModuleWithProvidersResolver(this.reflector, this.isCore),
4666
4744
  forwardRefResolver
4667
4745
  ]);
4668
4746
  const diagnostics = [];
@@ -4717,7 +4795,7 @@ var NgModuleDecoratorHandler = class {
4717
4795
  id = new WrappedNodeExpr6(idExpr);
4718
4796
  } else {
4719
4797
  const diag = makeDiagnostic(ErrorCode.WARN_NGMODULE_ID_UNNECESSARY, idExpr, `Using 'module.id' for NgModule.id is a common anti-pattern that is ignored by the Angular compiler.`);
4720
- diag.category = ts21.DiagnosticCategory.Warning;
4798
+ diag.category = ts22.DiagnosticCategory.Warning;
4721
4799
  diagnostics.push(diag);
4722
4800
  }
4723
4801
  }
@@ -4755,9 +4833,9 @@ var NgModuleDecoratorHandler = class {
4755
4833
  if (ngModule.has("imports")) {
4756
4834
  const rawImports2 = unwrapExpression(ngModule.get("imports"));
4757
4835
  let topLevelExpressions = [];
4758
- if (ts21.isArrayLiteralExpression(rawImports2)) {
4836
+ if (ts22.isArrayLiteralExpression(rawImports2)) {
4759
4837
  for (const element of rawImports2.elements) {
4760
- if (ts21.isSpreadElement(element)) {
4838
+ if (ts22.isSpreadElement(element)) {
4761
4839
  topLevelExpressions.push(element.expression);
4762
4840
  continue;
4763
4841
  }
@@ -4792,6 +4870,7 @@ var NgModuleDecoratorHandler = class {
4792
4870
  deps: getValidConstructorDependencies(node, this.reflector, this.isCore),
4793
4871
  target: FactoryTarget2.NgModule
4794
4872
  };
4873
+ const remoteScopesMayRequireCycleProtection = declarationRefs.some(isSyntheticReference) || importRefs.some(isSyntheticReference);
4795
4874
  return {
4796
4875
  diagnostics: diagnostics.length > 0 ? diagnostics : void 0,
4797
4876
  analysis: {
@@ -4810,7 +4889,8 @@ var NgModuleDecoratorHandler = class {
4810
4889
  providers: rawProviders,
4811
4890
  providersRequiringFactory: rawProviders ? resolveProvidersRequiringFactory(rawProviders, this.reflector, this.evaluator) : null,
4812
4891
  classMetadata: extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler),
4813
- factorySymbolName: node.name.text
4892
+ factorySymbolName: node.name.text,
4893
+ remoteScopesMayRequireCycleProtection
4814
4894
  }
4815
4895
  };
4816
4896
  }
@@ -4910,7 +4990,7 @@ var NgModuleDecoratorHandler = class {
4910
4990
  };
4911
4991
  }
4912
4992
  }
4913
- compileFull(node, { inj, mod, fac, classMetadata, declarations }, { injectorImports }) {
4993
+ compileFull(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection }, { injectorImports }) {
4914
4994
  const factoryFn = compileNgFactoryDefField(fac);
4915
4995
  const ngInjectorDef = compileInjector(__spreadProps(__spreadValues({}, inj), {
4916
4996
  imports: injectorImports
@@ -4919,7 +4999,7 @@ var NgModuleDecoratorHandler = class {
4919
4999
  const statements = ngModuleDef.statements;
4920
5000
  const metadata = classMetadata !== null ? compileClassMetadata2(classMetadata) : null;
4921
5001
  this.insertMetadataStatement(statements, metadata);
4922
- this.appendRemoteScopingStatements(statements, node, declarations);
5002
+ this.appendRemoteScopingStatements(statements, node, declarations, remoteScopesMayRequireCycleProtection);
4923
5003
  return this.compileNgModule(factoryFn, ngInjectorDef, ngModuleDef);
4924
5004
  }
4925
5005
  compilePartial(node, { inj, fac, mod, classMetadata }, { injectorImports }) {
@@ -4937,7 +5017,7 @@ var NgModuleDecoratorHandler = class {
4937
5017
  ngModuleStatements.unshift(metadata.toStmt());
4938
5018
  }
4939
5019
  }
4940
- appendRemoteScopingStatements(ngModuleStatements, node, declarations) {
5020
+ appendRemoteScopingStatements(ngModuleStatements, node, declarations, remoteScopesMayRequireCycleProtection) {
4941
5021
  const context = getSourceFile(node);
4942
5022
  for (const decl of declarations) {
4943
5023
  const remoteScope = this.scopeRegistry.getRemoteScope(decl.node);
@@ -4954,11 +5034,13 @@ var NgModuleDecoratorHandler = class {
4954
5034
  });
4955
5035
  const directiveArray = new LiteralArrayExpr2(directives);
4956
5036
  const pipesArray = new LiteralArrayExpr2(pipes);
5037
+ const directiveExpr = remoteScopesMayRequireCycleProtection && directives.length > 0 ? new FunctionExpr2([], [new ReturnStatement2(directiveArray)]) : directiveArray;
5038
+ const pipesExpr = remoteScopesMayRequireCycleProtection && pipes.length > 0 ? new FunctionExpr2([], [new ReturnStatement2(pipesArray)]) : pipesArray;
4957
5039
  const componentType = this.refEmitter.emit(decl, context);
4958
5040
  assertSuccessfulReferenceEmit(componentType, node, "component");
4959
5041
  const declExpr = componentType.expression;
4960
5042
  const setComponentScope = new ExternalExpr5(R3Identifiers.setComponentScope);
4961
- const callExpr = new InvokeFunctionExpr(setComponentScope, [declExpr, directiveArray, pipesArray]);
5043
+ const callExpr = new InvokeFunctionExpr(setComponentScope, [declExpr, directiveExpr, pipesExpr]);
4962
5044
  ngModuleStatements.push(callExpr.toStmt());
4963
5045
  }
4964
5046
  }
@@ -4993,61 +5075,6 @@ var NgModuleDecoratorHandler = class {
4993
5075
  return toR3Reference(origin, valueRef, typeRef, valueContext, typeContext, this.refEmitter);
4994
5076
  }
4995
5077
  }
4996
- _extractModuleFromModuleWithProvidersFn(fn, node, resolve, unresolvable) {
4997
- const rawType = fn.node.type || null;
4998
- const type = rawType && (this._reflectModuleFromTypeParam(rawType, fn.node) || this._reflectModuleFromLiteralType(rawType));
4999
- if (type === null) {
5000
- return unresolvable;
5001
- }
5002
- const ngModule = resolve(type);
5003
- if (!(ngModule instanceof Reference) || !isNamedClassDeclaration(ngModule.node)) {
5004
- return unresolvable;
5005
- }
5006
- return new SyntheticValue({
5007
- ngModule,
5008
- mwpCall: node
5009
- });
5010
- }
5011
- _reflectModuleFromTypeParam(type, node) {
5012
- if (!ts21.isTypeReferenceNode(type)) {
5013
- return null;
5014
- }
5015
- const typeName = type && (ts21.isIdentifier(type.typeName) && type.typeName || ts21.isQualifiedName(type.typeName) && type.typeName.right) || null;
5016
- if (typeName === null) {
5017
- return null;
5018
- }
5019
- const id = this.reflector.getImportOfIdentifier(typeName);
5020
- if (id === null || id.name !== "ModuleWithProviders") {
5021
- return null;
5022
- }
5023
- if (!this.isCore && id.from !== "@angular/core") {
5024
- return null;
5025
- }
5026
- if (type.typeArguments === void 0 || type.typeArguments.length !== 1) {
5027
- const parent = ts21.isMethodDeclaration(node) && ts21.isClassDeclaration(node.parent) ? node.parent : null;
5028
- const symbolName = (parent && parent.name ? parent.name.getText() + "." : "") + (node.name ? node.name.getText() : "anonymous");
5029
- throw new FatalDiagnosticError(ErrorCode.NGMODULE_MODULE_WITH_PROVIDERS_MISSING_GENERIC, type, `${symbolName} returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.`);
5030
- }
5031
- const arg = type.typeArguments[0];
5032
- return typeNodeToValueExpr(arg);
5033
- }
5034
- _reflectModuleFromLiteralType(type) {
5035
- if (!ts21.isIntersectionTypeNode(type)) {
5036
- return null;
5037
- }
5038
- for (const t of type.types) {
5039
- if (ts21.isTypeLiteralNode(t)) {
5040
- for (const m of t.members) {
5041
- const ngModuleType = ts21.isPropertySignature(m) && ts21.isIdentifier(m.name) && m.name.text === "ngModule" && m.type || null;
5042
- const ngModuleExpression = ngModuleType && typeNodeToValueExpr(ngModuleType);
5043
- if (ngModuleExpression) {
5044
- return ngModuleExpression;
5045
- }
5046
- }
5047
- }
5048
- }
5049
- return null;
5050
- }
5051
5078
  isClassDeclarationReference(ref) {
5052
5079
  return this.reflector.isClass(ref.node);
5053
5080
  }
@@ -5091,10 +5118,7 @@ function isNgModule(node, compilation) {
5091
5118
  return !compilation.dependencies.some((dep) => dep.ref.node === node);
5092
5119
  }
5093
5120
  function isModuleIdExpression(expr) {
5094
- return ts21.isPropertyAccessExpression(expr) && ts21.isIdentifier(expr.expression) && expr.expression.text === "module" && expr.name.text === "id";
5095
- }
5096
- function isResolvedModuleWithProviders(sv) {
5097
- return typeof sv.value === "object" && sv.value != null && sv.value.hasOwnProperty("ngModule") && sv.value.hasOwnProperty("mwpCall");
5121
+ return ts22.isPropertyAccessExpression(expr) && ts22.isIdentifier(expr.expression) && expr.expression.text === "module" && expr.name.text === "id";
5098
5122
  }
5099
5123
  function makeStandaloneBootstrapDiagnostic(ngModuleClass, bootstrappedClassRef, rawBootstrapExpr) {
5100
5124
  const componentClassName = bootstrappedClassRef.node.name.text;
@@ -5102,6 +5126,9 @@ function makeStandaloneBootstrapDiagnostic(ngModuleClass, bootstrappedClassRef,
5102
5126
  const relatedInformation = [makeRelatedInformation(ngModuleClass, `The 'bootstrap' array is present on this NgModule.`)];
5103
5127
  return makeDiagnostic(ErrorCode.NGMODULE_BOOTSTRAP_IS_STANDALONE, getDiagnosticNode(bootstrappedClassRef, rawBootstrapExpr), message, relatedInformation);
5104
5128
  }
5129
+ function isSyntheticReference(ref) {
5130
+ return ref.synthetic;
5131
+ }
5105
5132
 
5106
5133
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/diagnostics.mjs
5107
5134
  function makeCyclicImportInfo(ref, type, cycle) {
@@ -5128,7 +5155,7 @@ function checkCustomElementSelectorForErrors(selector) {
5128
5155
 
5129
5156
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/resources.mjs
5130
5157
  import { DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, ParseSourceFile as ParseSourceFile2, parseTemplate } from "@angular/compiler";
5131
- import ts22 from "typescript";
5158
+ import ts23 from "typescript";
5132
5159
  function getTemplateDeclarationNodeForError(declaration) {
5133
5160
  switch (declaration.isInline) {
5134
5161
  case true:
@@ -5145,7 +5172,7 @@ function extractTemplate(node, template, evaluator, depTracker, resourceLoader,
5145
5172
  let sourceMapping;
5146
5173
  let escapedString = false;
5147
5174
  let sourceMapUrl;
5148
- if (ts22.isStringLiteral(template.expression) || ts22.isNoSubstitutionTemplateLiteral(template.expression)) {
5175
+ if (ts23.isStringLiteral(template.expression) || ts23.isNoSubstitutionTemplateLiteral(template.expression)) {
5149
5176
  sourceParseRange = getTemplateRange(template.expression);
5150
5177
  sourceStr = template.expression.getSourceFile().text;
5151
5178
  templateContent = template.expression.text;
@@ -5303,7 +5330,7 @@ function preloadAndParseTemplate(evaluator, resourceLoader, depTracker, preanaly
5303
5330
  }
5304
5331
  function getTemplateRange(templateExpr) {
5305
5332
  const startPos = templateExpr.getStart() + 1;
5306
- const { line, character } = ts22.getLineAndCharacterOfPosition(templateExpr.getSourceFile(), startPos);
5333
+ const { line, character } = ts23.getLineAndCharacterOfPosition(templateExpr.getSourceFile(), startPos);
5307
5334
  return {
5308
5335
  startPos,
5309
5336
  startLine: line,
@@ -5336,7 +5363,7 @@ function transformDecoratorResources(dec, component, styles, template) {
5336
5363
  const metadata = new Map(component);
5337
5364
  if (metadata.has("templateUrl")) {
5338
5365
  metadata.delete("templateUrl");
5339
- metadata.set("template", ts22.factory.createStringLiteral(template.content));
5366
+ metadata.set("template", ts23.factory.createStringLiteral(template.content));
5340
5367
  }
5341
5368
  if (metadata.has("styleUrls") || metadata.has("styles")) {
5342
5369
  metadata.delete("styles");
@@ -5344,20 +5371,20 @@ function transformDecoratorResources(dec, component, styles, template) {
5344
5371
  if (styles.length > 0) {
5345
5372
  const styleNodes = styles.reduce((result, style) => {
5346
5373
  if (style.trim().length > 0) {
5347
- result.push(ts22.factory.createStringLiteral(style));
5374
+ result.push(ts23.factory.createStringLiteral(style));
5348
5375
  }
5349
5376
  return result;
5350
5377
  }, []);
5351
5378
  if (styleNodes.length > 0) {
5352
- metadata.set("styles", ts22.factory.createArrayLiteralExpression(styleNodes));
5379
+ metadata.set("styles", ts23.factory.createArrayLiteralExpression(styleNodes));
5353
5380
  }
5354
5381
  }
5355
5382
  }
5356
5383
  const newMetadataFields = [];
5357
5384
  for (const [name, value] of metadata.entries()) {
5358
- newMetadataFields.push(ts22.factory.createPropertyAssignment(name, value));
5385
+ newMetadataFields.push(ts23.factory.createPropertyAssignment(name, value));
5359
5386
  }
5360
- return __spreadProps(__spreadValues({}, dec), { args: [ts22.factory.createObjectLiteralExpression(newMetadataFields)] });
5387
+ return __spreadProps(__spreadValues({}, dec), { args: [ts23.factory.createObjectLiteralExpression(newMetadataFields)] });
5361
5388
  }
5362
5389
  function extractComponentStyleUrls(evaluator, component) {
5363
5390
  if (!component.has("styleUrls")) {
@@ -5367,9 +5394,9 @@ function extractComponentStyleUrls(evaluator, component) {
5367
5394
  }
5368
5395
  function extractStyleUrlsFromExpression(evaluator, styleUrlsExpr) {
5369
5396
  const styleUrls = [];
5370
- if (ts22.isArrayLiteralExpression(styleUrlsExpr)) {
5397
+ if (ts23.isArrayLiteralExpression(styleUrlsExpr)) {
5371
5398
  for (const styleUrlExpr of styleUrlsExpr.elements) {
5372
- if (ts22.isSpreadElement(styleUrlExpr)) {
5399
+ if (ts23.isSpreadElement(styleUrlExpr)) {
5373
5400
  styleUrls.push(...extractStyleUrlsFromExpression(evaluator, styleUrlExpr.expression));
5374
5401
  } else {
5375
5402
  const styleUrl = evaluator.evaluate(styleUrlExpr);
@@ -5401,10 +5428,10 @@ function extractStyleUrlsFromExpression(evaluator, styleUrlsExpr) {
5401
5428
  function extractStyleResources(resourceLoader, component, containingFile) {
5402
5429
  const styles = /* @__PURE__ */ new Set();
5403
5430
  function stringLiteralElements(array) {
5404
- return array.elements.filter((e) => ts22.isStringLiteralLike(e));
5431
+ return array.elements.filter((e) => ts23.isStringLiteralLike(e));
5405
5432
  }
5406
5433
  const styleUrlsExpr = component.get("styleUrls");
5407
- if (styleUrlsExpr !== void 0 && ts22.isArrayLiteralExpression(styleUrlsExpr)) {
5434
+ if (styleUrlsExpr !== void 0 && ts23.isArrayLiteralExpression(styleUrlsExpr)) {
5408
5435
  for (const expression of stringLiteralElements(styleUrlsExpr)) {
5409
5436
  try {
5410
5437
  const resourceUrl = resourceLoader.resolve(expression.text, containingFile);
@@ -5414,7 +5441,7 @@ function extractStyleResources(resourceLoader, component, containingFile) {
5414
5441
  }
5415
5442
  }
5416
5443
  const stylesExpr = component.get("styles");
5417
- if (stylesExpr !== void 0 && ts22.isArrayLiteralExpression(stylesExpr)) {
5444
+ if (stylesExpr !== void 0 && ts23.isArrayLiteralExpression(stylesExpr)) {
5418
5445
  for (const expression of stringLiteralElements(stylesExpr)) {
5419
5446
  styles.add({ path: null, expression });
5420
5447
  }
@@ -5518,12 +5545,27 @@ function validateAndFlattenComponentImports(imports, expr) {
5518
5545
  } else {
5519
5546
  diagnostics.push(createValueHasWrongTypeError(ref.getOriginForDiagnostics(expr), ref, `'imports' must be an array of components, directives, pipes, or NgModules`).toDiagnostic());
5520
5547
  }
5548
+ } else if (isLikelyModuleWithProviders(ref)) {
5549
+ let origin = expr;
5550
+ if (ref instanceof SyntheticValue) {
5551
+ origin = getOriginNodeForDiagnostics(ref.value.mwpCall, expr);
5552
+ }
5553
+ diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_UNKNOWN_IMPORT, origin, `'imports' contains a ModuleWithProviders value, likely the result of a 'Module.forRoot()'-style call. These calls are not used to configure components and are not valid in standalone component imports - consider importing them in the application bootstrap instead.`));
5521
5554
  } else {
5522
5555
  diagnostics.push(createValueHasWrongTypeError(expr, imports, `'imports' must be an array of components, directives, pipes, or NgModules`).toDiagnostic());
5523
5556
  }
5524
5557
  }
5525
5558
  return { imports: flattened, diagnostics };
5526
5559
  }
5560
+ function isLikelyModuleWithProviders(value) {
5561
+ if (value instanceof SyntheticValue && isResolvedModuleWithProviders(value)) {
5562
+ return true;
5563
+ }
5564
+ if (value instanceof Map && value.has("ngModule")) {
5565
+ return true;
5566
+ }
5567
+ return false;
5568
+ }
5527
5569
 
5528
5570
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/handler.mjs
5529
5571
  var EMPTY_ARRAY = [];
@@ -5675,7 +5717,11 @@ var ComponentDecoratorHandler = class {
5675
5717
  isPoisoned = true;
5676
5718
  } else if (component.has("imports")) {
5677
5719
  const expr = component.get("imports");
5678
- const imported = this.evaluator.evaluate(expr, forwardRefResolver);
5720
+ const importResolvers = combineResolvers([
5721
+ createModuleWithProvidersResolver(this.reflector, this.isCore),
5722
+ forwardRefResolver
5723
+ ]);
5724
+ const imported = this.evaluator.evaluate(expr, importResolvers);
5679
5725
  const { imports: flattened, diagnostics: importDiagnostics } = validateAndFlattenComponentImports(imported, expr);
5680
5726
  resolvedImports = flattened;
5681
5727
  rawImports = expr;
@@ -5869,7 +5915,7 @@ var ComponentDecoratorHandler = class {
5869
5915
  });
5870
5916
  }
5871
5917
  typeCheck(ctx, node, meta) {
5872
- if (this.typeCheckScopeRegistry === null || !ts23.isClassDeclaration(node)) {
5918
+ if (this.typeCheckScopeRegistry === null || !ts24.isClassDeclaration(node)) {
5873
5919
  return;
5874
5920
  }
5875
5921
  if (meta.isPoisoned && !this.usePoisonedData) {
@@ -5880,7 +5926,7 @@ var ComponentDecoratorHandler = class {
5880
5926
  return;
5881
5927
  }
5882
5928
  const binder = new R3TargetBinder(scope.matcher);
5883
- ctx.addTemplate(new Reference(node), binder, meta.template.diagNodes, scope.pipes, scope.schemas, meta.template.sourceMapping, meta.template.file, meta.template.errors);
5929
+ ctx.addTemplate(new Reference(node), binder, meta.template.diagNodes, scope.pipes, scope.schemas, meta.template.sourceMapping, meta.template.file, meta.template.errors, meta.meta.isStandalone);
5884
5930
  }
5885
5931
  extendedTemplateCheck(component, extendedTemplateChecker) {
5886
5932
  return extendedTemplateChecker.getDiagnosticsForComponent(component);
@@ -5983,25 +6029,29 @@ var ComponentDecoratorHandler = class {
5983
6029
  }
5984
6030
  const cyclesFromDirectives = /* @__PURE__ */ new Map();
5985
6031
  const cyclesFromPipes = /* @__PURE__ */ new Map();
5986
- for (const usedDep of declarations) {
5987
- const cycle = this._checkForCyclicImport(usedDep.importedFile, usedDep.type, context);
5988
- if (cycle !== null) {
5989
- switch (usedDep.kind) {
5990
- case R3TemplateDependencyKind.Directive:
5991
- cyclesFromDirectives.set(usedDep, cycle);
5992
- break;
5993
- case R3TemplateDependencyKind.Pipe:
5994
- cyclesFromPipes.set(usedDep, cycle);
5995
- break;
6032
+ if (!metadata.isStandalone) {
6033
+ for (const usedDep of declarations) {
6034
+ const cycle = this._checkForCyclicImport(usedDep.importedFile, usedDep.type, context);
6035
+ if (cycle !== null) {
6036
+ switch (usedDep.kind) {
6037
+ case R3TemplateDependencyKind.Directive:
6038
+ cyclesFromDirectives.set(usedDep, cycle);
6039
+ break;
6040
+ case R3TemplateDependencyKind.Pipe:
6041
+ cyclesFromPipes.set(usedDep, cycle);
6042
+ break;
6043
+ }
5996
6044
  }
5997
6045
  }
5998
6046
  }
6047
+ const standaloneImportMayBeForwardDeclared = analysis.resolvedImports !== null && analysis.resolvedImports.some((ref) => ref.synthetic);
5999
6048
  const cycleDetected = cyclesFromDirectives.size !== 0 || cyclesFromPipes.size !== 0;
6000
6049
  if (!cycleDetected) {
6001
6050
  for (const { type, importedFile } of declarations) {
6002
- this._recordSyntheticImport(importedFile, type, context);
6051
+ this.maybeRecordSyntheticImport(importedFile, type, context);
6003
6052
  }
6004
- const wrapDirectivesAndPipesInClosure = declarations.some((decl) => isExpressionForwardReference(decl.type, node.name, context));
6053
+ const declarationIsForwardDeclared = declarations.some((decl) => isExpressionForwardReference(decl.type, node.name, context));
6054
+ const wrapDirectivesAndPipesInClosure = declarationIsForwardDeclared || standaloneImportMayBeForwardDeclared;
6005
6055
  data.declarations = declarations;
6006
6056
  data.declarationListEmitMode = wrapDirectivesAndPipesInClosure ? 1 : 0;
6007
6057
  } else {
@@ -6112,7 +6162,7 @@ var ComponentDecoratorHandler = class {
6112
6162
  }
6113
6163
  return this.cycleAnalyzer.wouldCreateCycle(origin, imported);
6114
6164
  }
6115
- _recordSyntheticImport(importedFile, expr, origin) {
6165
+ maybeRecordSyntheticImport(importedFile, expr, origin) {
6116
6166
  const imported = resolveImportedFile(this.moduleResolver, importedFile, expr, origin);
6117
6167
  if (imported === null) {
6118
6168
  return;
@@ -6148,7 +6198,7 @@ function validateStandaloneImports(importRefs, importExpr, metaReader, scopeRead
6148
6198
 
6149
6199
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/injectable.mjs
6150
6200
  import { compileClassMetadata as compileClassMetadata4, compileDeclareClassMetadata as compileDeclareClassMetadata4, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression2, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as WrappedNodeExpr8 } from "@angular/compiler";
6151
- import ts24 from "typescript";
6201
+ import ts25 from "typescript";
6152
6202
  var InjectableDecoratorHandler = class {
6153
6203
  constructor(reflector, isCore, strictCtorDeps, injectableRegistry, perf, errorOnDuplicateProv = true) {
6154
6204
  this.reflector = reflector;
@@ -6239,7 +6289,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
6239
6289
  };
6240
6290
  } else if (decorator.args.length === 1) {
6241
6291
  const metaNode = decorator.args[0];
6242
- if (!ts24.isObjectLiteralExpression(metaNode)) {
6292
+ if (!ts25.isObjectLiteralExpression(metaNode)) {
6243
6293
  throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
6244
6294
  }
6245
6295
  const meta = reflectObjectLiteral(metaNode);
@@ -6247,7 +6297,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
6247
6297
  let deps = void 0;
6248
6298
  if ((meta.has("useClass") || meta.has("useFactory")) && meta.has("deps")) {
6249
6299
  const depsExpr = meta.get("deps");
6250
- if (!ts24.isArrayLiteralExpression(depsExpr)) {
6300
+ if (!ts25.isArrayLiteralExpression(depsExpr)) {
6251
6301
  throw new FatalDiagnosticError(ErrorCode.VALUE_NOT_LITERAL, depsExpr, `@Injectable deps metadata must be an inline array`);
6252
6302
  }
6253
6303
  deps = depsExpr.elements.map((dep) => getDep(dep, reflector));
@@ -6329,12 +6379,12 @@ function getDep(dep, reflector) {
6329
6379
  }
6330
6380
  return true;
6331
6381
  }
6332
- if (ts24.isArrayLiteralExpression(dep)) {
6382
+ if (ts25.isArrayLiteralExpression(dep)) {
6333
6383
  dep.elements.forEach((el) => {
6334
6384
  let isDecorator = false;
6335
- if (ts24.isIdentifier(el)) {
6385
+ if (ts25.isIdentifier(el)) {
6336
6386
  isDecorator = maybeUpdateDecorator(el, reflector);
6337
- } else if (ts24.isNewExpression(el) && ts24.isIdentifier(el.expression)) {
6387
+ } else if (ts25.isNewExpression(el) && ts25.isIdentifier(el.expression)) {
6338
6388
  const token = el.arguments && el.arguments.length > 0 && el.arguments[0] || void 0;
6339
6389
  isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
6340
6390
  }
@@ -6348,7 +6398,7 @@ function getDep(dep, reflector) {
6348
6398
 
6349
6399
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/pipe.mjs
6350
6400
  import { compileClassMetadata as compileClassMetadata5, compileDeclareClassMetadata as compileDeclareClassMetadata5, compileDeclarePipeFromMetadata, compilePipeFromMetadata, FactoryTarget as FactoryTarget5, WrappedNodeExpr as WrappedNodeExpr9 } from "@angular/compiler";
6351
- import ts25 from "typescript";
6401
+ import ts26 from "typescript";
6352
6402
  var PipeSymbol = class extends SemanticSymbol {
6353
6403
  constructor(decl, name) {
6354
6404
  super(decl);
@@ -6403,7 +6453,7 @@ var PipeDecoratorHandler = class {
6403
6453
  throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, Decorator.nodeForError(decorator), "@Pipe must have exactly one argument");
6404
6454
  }
6405
6455
  const meta = unwrapExpression(decorator.args[0]);
6406
- if (!ts25.isObjectLiteralExpression(meta)) {
6456
+ if (!ts26.isObjectLiteralExpression(meta)) {
6407
6457
  throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@Pipe must have a literal argument");
6408
6458
  }
6409
6459
  const pipe = reflectObjectLiteral(meta);
@@ -6528,4 +6578,4 @@ export {
6528
6578
  * Use of this source code is governed by an MIT-style license that can be
6529
6579
  * found in the LICENSE file at https://angular.io/license
6530
6580
  */
6531
- //# sourceMappingURL=chunk-GJVJ6GH4.js.map
6581
+ //# sourceMappingURL=chunk-GWA6QBDZ.js.map