MCPcopy
hub / github.com/angular/angular-cli / AngularWebpackPlugin

Class AngularWebpackPlugin

packages/ngtools/webpack/src/ivy/plugin.ts:86–768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 * Deprecated since v22.
85 */
86export class AngularWebpackPlugin {
87 private readonly pluginOptions: AngularWebpackPluginOptions;
88 private compilerCliModule?: typeof import('@angular/compiler-cli');
89 private compilerCliToolingModule?: typeof import('@angular/compiler-cli/private/tooling');
90 private watchMode?: boolean;
91 private ngtscNextProgram?: NgtscProgram;
92 private builder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
93 private sourceFileCache?: SourceFileCache;
94 private webpackCache?: ReturnType<Compilation['getCache']>;
95 private webpackCreateHash?: Compiler['webpack']['util']['createHash'];
96 private readonly fileDependencies = new Map<string, Set<string>>();
97 private readonly requiredFilesToEmit = new Set<string>();
98 private readonly requiredFilesToEmitCache = new Map<string, EmitFileResult | undefined>();
99 private readonly fileEmitHistory = new Map<string, FileEmitHistoryItem>();
100
101 constructor(options: Partial<AngularWebpackPluginOptions> = {}) {
102 this.pluginOptions = {
103 emitClassMetadata: false,
104 emitNgModuleScope: false,
105 jitMode: false,
106 fileReplacements: {},
107 substitutions: {},
108 directTemplateLoading: true,
109 tsconfig: 'tsconfig.json',
110 ...options,
111 };
112 }
113
114 private get compilerCli(): typeof import('@angular/compiler-cli') {
115 // The compilerCliModule field is guaranteed to be defined during a compilation
116 // due to the `beforeCompile` hook. Usage of this property accessor prior to the
117 // hook execution is an implementation error.
118 assert.ok(this.compilerCliModule, `'@angular/compiler-cli' used prior to Webpack compilation.`);
119
120 return this.compilerCliModule;
121 }
122
123 private get compilerCliTooling(): typeof import('@angular/compiler-cli/private/tooling') {
124 // The compilerCliToolingModule field is guaranteed to be defined during a compilation
125 // due to the `beforeCompile` hook. Usage of this property accessor prior to the
126 // hook execution is an implementation error.
127 assert.ok(
128 this.compilerCliToolingModule,
129 `'@angular/compiler-cli' used prior to Webpack compilation.`,
130 );
131
132 return this.compilerCliToolingModule;
133 }
134
135 get options(): AngularWebpackPluginOptions {
136 return this.pluginOptions;
137 }
138
139 apply(compiler: Compiler): void {
140 const { NormalModuleReplacementPlugin, util } = compiler.webpack;
141 this.webpackCreateHash = util.createHash;
142
143 // Setup file replacements with webpack

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected