Skip to content

Commit

Permalink
refactor(@angular-devkit/build-angular): remove use of Webpack RuleSe…
Browse files Browse the repository at this point in the history
…tLoader type

The `RuleSetLoader` type is not exported from the Webpack 5 types.
  • Loading branch information
clydin committed Feb 10, 2021
1 parent 6306872 commit e871f87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
Compiler,
Configuration,
ContextReplacementPlugin,
RuleSetLoader,
RuleSetRule,
compilation,
debug,
Expand Down Expand Up @@ -326,7 +325,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
});
}

let buildOptimizerUseRule: RuleSetLoader[] = [];
let buildOptimizerUseRule: RuleSetRule[] = [];
if (buildOptions.buildOptimizer) {
extraPlugins.push(new BuildOptimizerWebpackPlugin());
buildOptimizerUseRule = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
}

// set base rules to derive final rules from
const baseRules: { test: RegExp, use: webpack.RuleSetLoader[] }[] = [
const baseRules: { test: RegExp, use: webpack.RuleSetUseItem[] }[] = [
{ test: /\.css$/, use: [] },
{
test: /\.scss$|\.sass$/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
ivy,
} from '@ngtools/webpack';
import * as path from 'path';
import { RuleSetLoader } from 'webpack';
import { WebpackConfigOptions, BuildOptions } from '../../utils/build-options';
import { legacyIvyPluginEnabled } from '../../utils/environment-options';

Expand Down Expand Up @@ -191,21 +190,20 @@ export function getAotConfig(wco: WebpackConfigOptions, i18nExtract = false) {
const optimize = buildOptions.optimization.scripts;
const useIvyOnlyPlugin = canUseIvyPlugin(wco) && !i18nExtract;

let buildOptimizerRules: RuleSetLoader[] = [];
if (buildOptions.buildOptimizer) {
buildOptimizerRules = [{
loader: buildOptimizerLoaderPath,
options: { sourceMap: buildOptions.sourceMap.scripts }
}];
}

return {
module: {
rules: [
{
test: useIvyOnlyPlugin ? /\.tsx?$/ : /(?:\.ngfactory\.js|\.ngstyle\.js|\.tsx?)$/,
use: [
...buildOptimizerRules,
...(buildOptions.buildOptimizer
? [
{
loader: buildOptimizerLoaderPath,
options: { sourceMap: buildOptions.sourceMap.scripts },
},
]
: []),
useIvyOnlyPlugin ? ivy.AngularWebpackLoaderPath : NgToolsLoader,
],
},
Expand Down

0 comments on commit e871f87

Please sign in to comment.