@ngtools/webpack 19.0.0-next.0 → 19.0.0-next.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngtools/webpack",
3
- "version": "19.0.0-next.0",
3
+ "version": "19.0.0-next.2",
4
4
  "description": "Webpack plugin that AoT compiles your Angular components and modules.",
5
5
  "main": "./src/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -23,6 +23,7 @@ export interface AngularWebpackPluginOptions {
23
23
  export declare class AngularWebpackPlugin {
24
24
  private readonly pluginOptions;
25
25
  private compilerCliModule?;
26
+ private compilerCliToolingModule?;
26
27
  private watchMode?;
27
28
  private ngtscNextProgram?;
28
29
  private builder?;
@@ -35,6 +36,7 @@ export declare class AngularWebpackPlugin {
35
36
  private readonly fileEmitHistory;
36
37
  constructor(options?: Partial<AngularWebpackPluginOptions>);
37
38
  private get compilerCli();
39
+ private get compilerCliTooling();
38
40
  get options(): AngularWebpackPluginOptions;
39
41
  apply(compiler: Compiler): void;
40
42
  private setupCompilation;
package/src/ivy/plugin.js CHANGED
@@ -54,6 +54,7 @@ const compilationFileEmitters = new WeakMap();
54
54
  class AngularWebpackPlugin {
55
55
  pluginOptions;
56
56
  compilerCliModule;
57
+ compilerCliToolingModule;
57
58
  watchMode;
58
59
  ngtscNextProgram;
59
60
  builder;
@@ -83,6 +84,13 @@ class AngularWebpackPlugin {
83
84
  assert_1.strict.ok(this.compilerCliModule, `'@angular/compiler-cli' used prior to Webpack compilation.`);
84
85
  return this.compilerCliModule;
85
86
  }
87
+ get compilerCliTooling() {
88
+ // The compilerCliToolingModule field is guaranteed to be defined during a compilation
89
+ // due to the `beforeCompile` hook. Usage of this property accessor prior to the
90
+ // hook execution is an implementation error.
91
+ assert_1.strict.ok(this.compilerCliToolingModule, `'@angular/compiler-cli' used prior to Webpack compilation.`);
92
+ return this.compilerCliToolingModule;
93
+ }
86
94
  get options() {
87
95
  return this.pluginOptions;
88
96
  }
@@ -230,7 +238,8 @@ class AngularWebpackPlugin {
230
238
  if (!fileEmitters) {
231
239
  fileEmitters = new symbol_1.FileEmitterCollection();
232
240
  compilationFileEmitters.set(compilation, fileEmitters);
233
- compilation.compiler.webpack.NormalModule.getCompilationHooks(compilation).loader.tap(PLUGIN_NAME, (loaderContext) => {
241
+ compilation.compiler.webpack.NormalModule.getCompilationHooks(compilation).loader.tap(PLUGIN_NAME, (context) => {
242
+ const loaderContext = context;
234
243
  loaderContext[symbol_1.AngularPluginSymbol] = fileEmitters;
235
244
  });
236
245
  }
@@ -497,9 +506,6 @@ class AngularWebpackPlugin {
497
506
  };
498
507
  }
499
508
  async initializeCompilerCli() {
500
- if (this.compilerCliModule) {
501
- return;
502
- }
503
509
  // This uses a dynamic import to load `@angular/compiler-cli` which may be ESM.
504
510
  // CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
505
511
  // will currently, unconditionally downlevel dynamic import into a require call.
@@ -507,7 +513,8 @@ class AngularWebpackPlugin {
507
513
  // this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
508
514
  // Once TypeScript provides support for keeping the dynamic import this workaround can
509
515
  // be dropped.
510
- this.compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();
516
+ this.compilerCliModule ??= await new Function(`return import('@angular/compiler-cli');`)();
517
+ this.compilerCliToolingModule ??= await new Function(`return import('@angular/compiler-cli/private/tooling');`)();
511
518
  }
512
519
  async addFileEmitHistory(filePath, content) {
513
520
  assert_1.strict.ok(this.webpackCreateHash, 'File emitter is used prior to Webpack compilation');
@@ -11,7 +11,7 @@ export declare function createAotTransformers(builder: ts.BuilderProgram, option
11
11
  emitNgModuleScope?: boolean;
12
12
  emitSetClassDebugInfo?: boolean;
13
13
  }, imageDomains: Set<string>): ts.CustomTransformers;
14
- export declare function createJitTransformers(builder: ts.BuilderProgram, compilerCli: typeof import('@angular/compiler-cli'), options: {
14
+ export declare function createJitTransformers(builder: ts.BuilderProgram, compilerCli: typeof import('@angular/compiler-cli/private/tooling'), options: {
15
15
  inlineStyleFileExtension?: string;
16
16
  }): ts.CustomTransformers;
17
17
  export declare function mergeTransformers(first: ts.CustomTransformers, second: ts.CustomTransformers): ts.CustomTransformers;