mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 10:11:50 +08:00
refactor(@angular-devkit/build-optimizer): improve transitional Webpack 5 compatibility
This change provides both Webpack 4 and 5 compatible types for the the build optimizer Webpack plugin.
This commit is contained in:
parent
a937012db2
commit
d720d3db73
@ -3,7 +3,7 @@ export declare function buildOptimizer(options: BuildOptimizerOptions): Transfor
|
||||
export declare const buildOptimizerLoaderPath: string;
|
||||
|
||||
export declare class BuildOptimizerWebpackPlugin {
|
||||
apply(compiler: Compiler): void;
|
||||
apply(compiler: Compiler | WebpackFourCompiler): void;
|
||||
}
|
||||
|
||||
export default function buildOptimizerLoader(this: {
|
||||
|
@ -22,5 +22,9 @@
|
||||
"webpack": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/webpack": "^4.41.22",
|
||||
"webpack": "5.21.2"
|
||||
}
|
||||
}
|
||||
|
@ -5,15 +5,15 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import { Compiler } from 'webpack';
|
||||
import { Compiler, WebpackFourCompiler } from 'webpack';
|
||||
|
||||
interface ModuleData {
|
||||
resourceResolveData: { descriptionFileData?: { typings?: string } };
|
||||
}
|
||||
|
||||
export class BuildOptimizerWebpackPlugin {
|
||||
apply(compiler: Compiler) {
|
||||
compiler.hooks.normalModuleFactory.tap('BuildOptimizerWebpackPlugin', nmf => {
|
||||
apply(compiler: Compiler | WebpackFourCompiler) {
|
||||
(compiler as Compiler).hooks.normalModuleFactory.tap('BuildOptimizerWebpackPlugin', nmf => {
|
||||
// tslint:disable-next-line: no-any
|
||||
nmf.hooks.module.tap('BuildOptimizerWebpackPlugin', (module, data) => {
|
||||
const { descriptionFileData } = (data as ModuleData).resourceResolveData;
|
||||
|
14
packages/angular_devkit/build_optimizer/src/webpack.d.ts
vendored
Normal file
14
packages/angular_devkit/build_optimizer/src/webpack.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import * as webpack from 'webpack';
|
||||
import { Compiler as webpack4Compiler } from '@types/webpack';
|
||||
|
||||
// Webpack 5 transition support types
|
||||
declare module 'webpack' {
|
||||
export type WebpackFourCompiler = webpack4Compiler;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user