@angular/core 12.1.2 → 12.1.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.
package/fesm2015/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v12.1.2
2
+ * @license Angular v12.1.3
3
3
  * (c) 2010-2021 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -4025,15 +4025,38 @@ var ViewEncapsulation$1;
4025
4025
  * Use of this source code is governed by an MIT-style license that can be
4026
4026
  * found in the LICENSE file at https://angular.io/license
4027
4027
  */
4028
- function getCompilerFacade() {
4028
+ function getCompilerFacade(request) {
4029
4029
  const globalNg = _global['ng'];
4030
- if (!globalNg || !globalNg.ɵcompilerFacade) {
4031
- throw new Error(`Angular JIT compilation failed: '@angular/compiler' not loaded!\n` +
4032
- ` - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.\n` +
4033
- ` - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?\n` +
4034
- ` - Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.`);
4030
+ if (globalNg && globalNg.ɵcompilerFacade) {
4031
+ return globalNg.ɵcompilerFacade;
4032
+ }
4033
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
4034
+ // Log the type as an error so that a developer can easily navigate to the type from the
4035
+ // console.
4036
+ console.error(`JIT compilation failed for ${request.kind}`, request.type);
4037
+ let message = `The ${request.kind} '${request
4038
+ .type.name}' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.\n\n`;
4039
+ if (request.usage === 1 /* PartialDeclaration */) {
4040
+ message += `The ${request.kind} is part of a library that has been partially compiled.\n`;
4041
+ message +=
4042
+ `However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.\n`;
4043
+ message += '\n';
4044
+ message +=
4045
+ `Ideally, the library is processed using the Angular Linker to become fully AOT compiled.\n`;
4046
+ }
4047
+ else {
4048
+ message +=
4049
+ `JIT compilation is discouraged for production use-cases! Consider using AOT mode instead.\n`;
4050
+ }
4051
+ message +=
4052
+ `Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',\n`;
4053
+ message +=
4054
+ `or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.`;
4055
+ throw new Error(message);
4056
+ }
4057
+ else {
4058
+ throw new Error('JIT compiler unavailable');
4035
4059
  }
4036
- return globalNg.ɵcompilerFacade;
4037
4060
  }
4038
4061
 
4039
4062
  /**
@@ -11208,6 +11231,7 @@ class R3Injector {
11208
11231
  this.assertNotDestroyed();
11209
11232
  // Set the injection context.
11210
11233
  const previousInjector = setCurrentInjector(this);
11234
+ const previousInjectImplementation = setInjectImplementation(undefined);
11211
11235
  try {
11212
11236
  // Check for the SkipSelf flag.
11213
11237
  if (!(flags & InjectFlags.SkipSelf)) {
@@ -11260,7 +11284,8 @@ class R3Injector {
11260
11284
  }
11261
11285
  }
11262
11286
  finally {
11263
- // Lastly, clean up the state by restoring the previous injector.
11287
+ // Lastly, restore the previous injection context.
11288
+ setInjectImplementation(previousInjectImplementation);
11264
11289
  setCurrentInjector(previousInjector);
11265
11290
  }
11266
11291
  }
@@ -13669,7 +13694,8 @@ function compileInjectable(type, meta) {
13669
13694
  Object.defineProperty(type, NG_PROV_DEF, {
13670
13695
  get: () => {
13671
13696
  if (ngInjectableDef === null) {
13672
- ngInjectableDef = getCompilerFacade().compileInjectable(angularCoreDiEnv, `ng:///${type.name}/ɵprov.js`, getInjectableMetadata(type, meta));
13697
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'injectable', type });
13698
+ ngInjectableDef = compiler.compileInjectable(angularCoreDiEnv, `ng:///${type.name}/ɵprov.js`, getInjectableMetadata(type, meta));
13673
13699
  }
13674
13700
  return ngInjectableDef;
13675
13701
  },
@@ -13680,7 +13706,7 @@ function compileInjectable(type, meta) {
13680
13706
  Object.defineProperty(type, NG_FACTORY_DEF, {
13681
13707
  get: () => {
13682
13708
  if (ngFactoryDef === null) {
13683
- const compiler = getCompilerFacade();
13709
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'injectable', type });
13684
13710
  ngFactoryDef = compiler.compileFactory(angularCoreDiEnv, `ng:///${type.name}/ɵfac.js`, {
13685
13711
  name: type.name,
13686
13712
  type,
@@ -21465,7 +21491,7 @@ class Version {
21465
21491
  /**
21466
21492
  * @publicApi
21467
21493
  */
21468
- const VERSION = new Version('12.1.2');
21494
+ const VERSION = new Version('12.1.3');
21469
21495
 
21470
21496
  /**
21471
21497
  * @license
@@ -26924,7 +26950,8 @@ function compileNgModuleDefs(moduleType, ngModule, allowDuplicateDeclarationsInR
26924
26950
  // go into an infinite loop before we've reached the point where we throw all the errors.
26925
26951
  throw new Error(`'${stringifyForError(moduleType)}' module can't import itself`);
26926
26952
  }
26927
- ngModuleDef = getCompilerFacade().compileNgModule(angularCoreEnv, `ng:///${moduleType.name}/ɵmod.js`, {
26953
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'NgModule', type: moduleType });
26954
+ ngModuleDef = compiler.compileNgModule(angularCoreEnv, `ng:///${moduleType.name}/ɵmod.js`, {
26928
26955
  type: moduleType,
26929
26956
  bootstrap: flatten(ngModule.bootstrap || EMPTY_ARRAY).map(resolveForwardRef),
26930
26957
  declarations: declarations.map(resolveForwardRef),
@@ -26952,7 +26979,7 @@ function compileNgModuleDefs(moduleType, ngModule, allowDuplicateDeclarationsInR
26952
26979
  Object.defineProperty(moduleType, NG_FACTORY_DEF, {
26953
26980
  get: () => {
26954
26981
  if (ngFactoryDef === null) {
26955
- const compiler = getCompilerFacade();
26982
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'NgModule', type: moduleType });
26956
26983
  ngFactoryDef = compiler.compileFactory(angularCoreEnv, `ng:///${moduleType.name}/ɵfac.js`, {
26957
26984
  name: moduleType.name,
26958
26985
  type: moduleType,
@@ -26981,7 +27008,9 @@ function compileNgModuleDefs(moduleType, ngModule, allowDuplicateDeclarationsInR
26981
27008
  (ngModule.exports || EMPTY_ARRAY).map(resolveForwardRef),
26982
27009
  ],
26983
27010
  };
26984
- ngInjectorDef = getCompilerFacade().compileInjector(angularCoreEnv, `ng:///${moduleType.name}/ɵinj.js`, meta);
27011
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'NgModule', type: moduleType });
27012
+ ngInjectorDef =
27013
+ compiler.compileInjector(angularCoreEnv, `ng:///${moduleType.name}/ɵinj.js`, meta);
26985
27014
  }
26986
27015
  return ngInjectorDef;
26987
27016
  },
@@ -27347,7 +27376,7 @@ function compileComponent(type, metadata) {
27347
27376
  Object.defineProperty(type, NG_COMP_DEF, {
27348
27377
  get: () => {
27349
27378
  if (ngComponentDef === null) {
27350
- const compiler = getCompilerFacade();
27379
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'component', type: type });
27351
27380
  if (componentNeedsResolution(metadata)) {
27352
27381
  const error = [`Component '${type.name}' is not resolved:`];
27353
27382
  if (metadata.templateUrl) {
@@ -27438,8 +27467,9 @@ function compileDirective(type, directive) {
27438
27467
  // that use `@Directive()` with no selector. In that case, pass empty object to the
27439
27468
  // `directiveMetadata` function instead of null.
27440
27469
  const meta = getDirectiveMetadata$1(type, directive || {});
27470
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'directive', type });
27441
27471
  ngDirectiveDef =
27442
- getCompilerFacade().compileDirective(angularCoreEnv, meta.sourceMapUrl, meta.metadata);
27472
+ compiler.compileDirective(angularCoreEnv, meta.sourceMapUrl, meta.metadata);
27443
27473
  }
27444
27474
  return ngDirectiveDef;
27445
27475
  },
@@ -27450,7 +27480,7 @@ function compileDirective(type, directive) {
27450
27480
  function getDirectiveMetadata$1(type, metadata) {
27451
27481
  const name = type && type.name;
27452
27482
  const sourceMapUrl = `ng:///${name}/ɵdir.js`;
27453
- const compiler = getCompilerFacade();
27483
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'directive', type });
27454
27484
  const facade = directiveMetadata(type, metadata);
27455
27485
  facade.typeSourceSpan = compiler.createParseSourceSpan('Directive', name, sourceMapUrl);
27456
27486
  if (facade.usesInheritance) {
@@ -27464,7 +27494,7 @@ function addDirectiveFactoryDef(type, metadata) {
27464
27494
  get: () => {
27465
27495
  if (ngFactoryDef === null) {
27466
27496
  const meta = getDirectiveMetadata$1(type, metadata);
27467
- const compiler = getCompilerFacade();
27497
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'directive', type });
27468
27498
  ngFactoryDef = compiler.compileFactory(angularCoreEnv, `ng:///${type.name}/ɵfac.js`, {
27469
27499
  name: meta.metadata.name,
27470
27500
  type: meta.metadata.type,
@@ -27615,7 +27645,7 @@ function compilePipe(type, meta) {
27615
27645
  get: () => {
27616
27646
  if (ngFactoryDef === null) {
27617
27647
  const metadata = getPipeMetadata(type, meta);
27618
- const compiler = getCompilerFacade();
27648
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'pipe', type: metadata.type });
27619
27649
  ngFactoryDef = compiler.compileFactory(angularCoreEnv, `ng:///${metadata.name}/ɵfac.js`, {
27620
27650
  name: metadata.name,
27621
27651
  type: metadata.type,
@@ -27633,7 +27663,9 @@ function compilePipe(type, meta) {
27633
27663
  get: () => {
27634
27664
  if (ngPipeDef === null) {
27635
27665
  const metadata = getPipeMetadata(type, meta);
27636
- ngPipeDef = getCompilerFacade().compilePipe(angularCoreEnv, `ng:///${metadata.name}/ɵpipe.js`, metadata);
27666
+ const compiler = getCompilerFacade({ usage: 0 /* Decorator */, kind: 'pipe', type: metadata.type });
27667
+ ngPipeDef =
27668
+ compiler.compilePipe(angularCoreEnv, `ng:///${metadata.name}/ɵpipe.js`, metadata);
27637
27669
  }
27638
27670
  return ngPipeDef;
27639
27671
  },
@@ -29081,7 +29113,11 @@ function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {
29081
29113
  if (compilerProviders.length === 0) {
29082
29114
  return Promise.resolve(moduleFactory);
29083
29115
  }
29084
- const compiler = getCompilerFacade();
29116
+ const compiler = getCompilerFacade({
29117
+ usage: 0 /* Decorator */,
29118
+ kind: 'NgModule',
29119
+ type: moduleType,
29120
+ });
29085
29121
  const compilerInjector = Injector.create({ providers: compilerProviders });
29086
29122
  const resourceLoader = compilerInjector.get(compiler.ResourceLoader);
29087
29123
  // The resource loader can also return a string while the "resolveComponentResources"
@@ -33023,7 +33059,7 @@ class NgModuleFactory_ extends NgModuleFactory {
33023
33059
  * @codeGenApi
33024
33060
  */
33025
33061
  function ɵɵngDeclareDirective(decl) {
33026
- const compiler = getCompilerFacade();
33062
+ const compiler = getCompilerFacade({ usage: 1 /* PartialDeclaration */, kind: 'directive', type: decl.type });
33027
33063
  return compiler.compileDirectiveDeclaration(angularCoreEnv, `ng:///${decl.type.name}/ɵfac.js`, decl);
33028
33064
  }
33029
33065
  /**
@@ -33041,7 +33077,7 @@ function ɵɵngDeclareClassMetadata(decl) {
33041
33077
  * @codeGenApi
33042
33078
  */
33043
33079
  function ɵɵngDeclareComponent(decl) {
33044
- const compiler = getCompilerFacade();
33080
+ const compiler = getCompilerFacade({ usage: 1 /* PartialDeclaration */, kind: 'component', type: decl.type });
33045
33081
  return compiler.compileComponentDeclaration(angularCoreEnv, `ng:///${decl.type.name}/ɵcmp.js`, decl);
33046
33082
  }
33047
33083
  /**
@@ -33050,16 +33086,34 @@ function ɵɵngDeclareComponent(decl) {
33050
33086
  * @codeGenApi
33051
33087
  */
33052
33088
  function ɵɵngDeclareFactory(decl) {
33053
- const compiler = getCompilerFacade();
33089
+ const compiler = getCompilerFacade({
33090
+ usage: 1 /* PartialDeclaration */,
33091
+ kind: getFactoryKind(decl.target),
33092
+ type: decl.type
33093
+ });
33054
33094
  return compiler.compileFactoryDeclaration(angularCoreEnv, `ng:///${decl.type.name}/ɵfac.js`, decl);
33055
33095
  }
33096
+ function getFactoryKind(target) {
33097
+ switch (target) {
33098
+ case FactoryTarget.Directive:
33099
+ return 'directive';
33100
+ case FactoryTarget.Component:
33101
+ return 'component';
33102
+ case FactoryTarget.Injectable:
33103
+ return 'injectable';
33104
+ case FactoryTarget.Pipe:
33105
+ return 'pipe';
33106
+ case FactoryTarget.NgModule:
33107
+ return 'NgModule';
33108
+ }
33109
+ }
33056
33110
  /**
33057
33111
  * Compiles a partial injectable declaration object into a full injectable definition object.
33058
33112
  *
33059
33113
  * @codeGenApi
33060
33114
  */
33061
33115
  function ɵɵngDeclareInjectable(decl) {
33062
- const compiler = getCompilerFacade();
33116
+ const compiler = getCompilerFacade({ usage: 1 /* PartialDeclaration */, kind: 'injectable', type: decl.type });
33063
33117
  return compiler.compileInjectableDeclaration(angularCoreEnv, `ng:///${decl.type.name}/ɵprov.js`, decl);
33064
33118
  }
33065
33119
  /**
@@ -33068,7 +33122,7 @@ function ɵɵngDeclareInjectable(decl) {
33068
33122
  * @codeGenApi
33069
33123
  */
33070
33124
  function ɵɵngDeclareInjector(decl) {
33071
- const compiler = getCompilerFacade();
33125
+ const compiler = getCompilerFacade({ usage: 1 /* PartialDeclaration */, kind: 'NgModule', type: decl.type });
33072
33126
  return compiler.compileInjectorDeclaration(angularCoreEnv, `ng:///${decl.type.name}/ɵinj.js`, decl);
33073
33127
  }
33074
33128
  /**
@@ -33077,7 +33131,7 @@ function ɵɵngDeclareInjector(decl) {
33077
33131
  * @codeGenApi
33078
33132
  */
33079
33133
  function ɵɵngDeclareNgModule(decl) {
33080
- const compiler = getCompilerFacade();
33134
+ const compiler = getCompilerFacade({ usage: 1 /* PartialDeclaration */, kind: 'NgModule', type: decl.type });
33081
33135
  return compiler.compileNgModuleDeclaration(angularCoreEnv, `ng:///${decl.type.name}/ɵmod.js`, decl);
33082
33136
  }
33083
33137
  /**
@@ -33086,7 +33140,7 @@ function ɵɵngDeclareNgModule(decl) {
33086
33140
  * @codeGenApi
33087
33141
  */
33088
33142
  function ɵɵngDeclarePipe(decl) {
33089
- const compiler = getCompilerFacade();
33143
+ const compiler = getCompilerFacade({ usage: 1 /* PartialDeclaration */, kind: 'pipe', type: decl.type });
33090
33144
  return compiler.compilePipeDeclaration(angularCoreEnv, `ng:///${decl.type.name}/ɵpipe.js`, decl);
33091
33145
  }
33092
33146