@ngtools/webpack 12.0.3 → 12.0.4

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": "12.0.3",
3
+ "version": "12.0.4",
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",
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { CompilerOptions } from '@angular/compiler-cli';
9
- import { Compiler } from 'webpack';
9
+ import type { Compiler } from 'webpack';
10
10
  export interface AngularWebpackPluginOptions {
11
11
  tsconfig: string;
12
12
  compilerOptions?: CompilerOptions;
package/src/ivy/plugin.js CHANGED
@@ -12,7 +12,6 @@ const compiler_cli_1 = require("@angular/compiler-cli");
12
12
  const program_1 = require("@angular/compiler-cli/src/ngtsc/program");
13
13
  const crypto_1 = require("crypto");
14
14
  const ts = require("typescript");
15
- const webpack_1 = require("webpack");
16
15
  const ngcc_processor_1 = require("../ngcc_processor");
17
16
  const paths_plugin_1 = require("../paths-plugin");
18
17
  const resource_loader_1 = require("../resource_loader");
@@ -64,9 +63,10 @@ class AngularWebpackPlugin {
64
63
  return this.pluginOptions;
65
64
  }
66
65
  apply(compiler) {
66
+ const { NormalModuleReplacementPlugin, util } = compiler.webpack;
67
67
  // Setup file replacements with webpack
68
68
  for (const [key, value] of Object.entries(this.pluginOptions.fileReplacements)) {
69
- new webpack_1.NormalModuleReplacementPlugin(new RegExp('^' + key.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&') + '$'), value).apply(compiler);
69
+ new NormalModuleReplacementPlugin(new RegExp('^' + key.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&') + '$'), value).apply(compiler);
70
70
  }
71
71
  // Set resolver options
72
72
  const pathsPlugin = new paths_plugin_1.TypeScriptPathsPlugin();
@@ -84,7 +84,7 @@ class AngularWebpackPlugin {
84
84
  (_b = resolveOptions.plugins) !== null && _b !== void 0 ? _b : (resolveOptions.plugins = []);
85
85
  resolveOptions.plugins.push(pathsPlugin);
86
86
  // https://github.com/webpack/webpack/issues/11635#issuecomment-707016779
87
- return webpack_1.util.cleverMerge(resolveOptions, { mainFields: [...ivyMainFields, '...'] });
87
+ return util.cleverMerge(resolveOptions, { mainFields: [...ivyMainFields, '...'] });
88
88
  });
89
89
  });
90
90
  let ngccProcessor;
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Compilation } from 'webpack';
8
+ import type { Compilation } from 'webpack';
9
9
  export declare class WebpackResourceLoader {
10
10
  private _parentCompilation?;
11
11
  private _fileDependencies;
@@ -11,7 +11,6 @@ exports.WebpackResourceLoader = void 0;
11
11
  const crypto_1 = require("crypto");
12
12
  const path = require("path");
13
13
  const vm = require("vm");
14
- const webpack_1 = require("webpack");
15
14
  const paths_1 = require("./ivy/paths");
16
15
  class WebpackResourceLoader {
17
16
  constructor(shouldCache) {
@@ -93,12 +92,13 @@ class WebpackResourceLoader {
93
92
  name: 'resource',
94
93
  },
95
94
  };
96
- const context = this._parentCompilation.compiler.context;
95
+ const { context, webpack } = this._parentCompilation.compiler;
96
+ const { EntryPlugin, NormalModule, library, node, sources } = webpack;
97
97
  const childCompiler = this._parentCompilation.createChildCompiler('angular-compiler:resource', outputOptions, [
98
- new webpack_1.node.NodeTemplatePlugin(outputOptions),
99
- new webpack_1.node.NodeTargetPlugin(),
100
- new webpack_1.EntryPlugin(context, entry, { name: 'resource' }),
101
- new webpack_1.library.EnableLibraryPlugin('var'),
98
+ new node.NodeTemplatePlugin(outputOptions),
99
+ new node.NodeTargetPlugin(),
100
+ new EntryPlugin(context, entry, { name: 'resource' }),
101
+ new library.EnableLibraryPlugin('var'),
102
102
  ]);
103
103
  childCompiler.hooks.thisCompilation.tap('angular-compiler', (compilation, { normalModuleFactory }) => {
104
104
  // If no data is provided, the resource will be read from the filesystem
@@ -115,7 +115,7 @@ class WebpackResourceLoader {
115
115
  }
116
116
  return true;
117
117
  });
118
- webpack_1.NormalModule.getCompilationHooks(compilation)
118
+ NormalModule.getCompilationHooks(compilation)
119
119
  .readResourceForScheme.for('angular-resource')
120
120
  .tap('angular-compiler', () => data);
121
121
  }
@@ -127,7 +127,7 @@ class WebpackResourceLoader {
127
127
  try {
128
128
  const output = this._evaluate(outputFilePath, asset.source().toString());
129
129
  if (typeof output === 'string') {
130
- compilation.assets[outputFilePath] = new webpack_1.sources.RawSource(output);
130
+ compilation.assets[outputFilePath] = new sources.RawSource(output);
131
131
  }
132
132
  }
133
133
  catch (error) {
@@ -139,7 +139,7 @@ class WebpackResourceLoader {
139
139
  let finalContent;
140
140
  let finalMap;
141
141
  childCompiler.hooks.compilation.tap('angular-compiler', (childCompilation) => {
142
- childCompilation.hooks.processAssets.tap({ name: 'angular-compiler', stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, () => {
142
+ childCompilation.hooks.processAssets.tap({ name: 'angular-compiler', stage: webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT }, () => {
143
143
  var _a, _b;
144
144
  finalContent = (_a = childCompilation.assets[outputFilePath]) === null || _a === void 0 ? void 0 : _a.source().toString();
145
145
  finalMap = (_b = childCompilation.assets[outputFilePath + '.map']) === null || _b === void 0 ? void 0 : _b.source().toString();
@@ -5,6 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Compilation } from 'webpack';
8
+ import type { Compilation } from 'webpack';
9
9
  export declare function addWarning(compilation: Compilation, message: string): void;
10
10
  export declare function addError(compilation: Compilation, message: string): void;
@@ -8,12 +8,11 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.addError = exports.addWarning = void 0;
11
- const webpack_1 = require("webpack");
12
11
  function addWarning(compilation, message) {
13
- compilation.warnings.push(new webpack_1.WebpackError(message));
12
+ compilation.warnings.push(new compilation.compiler.webpack.WebpackError(message));
14
13
  }
15
14
  exports.addWarning = addWarning;
16
15
  function addError(compilation, message) {
17
- compilation.errors.push(new webpack_1.WebpackError(message));
16
+ compilation.errors.push(new compilation.compiler.webpack.WebpackError(message));
18
17
  }
19
18
  exports.addError = addError;