mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-19 20:52:06 +08:00
refactor(@angular-devkit/build-angular): remove Webpack loader resolve custom setting
The Webpack configuration setup previously walked up the directory structure to find all `node_modules` directories and then pass this list to Webpack's `resolverLoader.modules` option. This was previously done to ensure that hoisted packages were properly resolved. However, all loader paths are now fully resolved prior to being added to the Webpack configuration. Since loader paths will now be absolute, Webpack no longer needs to resolve them which makes the resolve settings no longer necessary.
This commit is contained in:
parent
734d61df3f
commit
a2bc175dbf
@ -1,31 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC 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 { existsSync } from 'fs';
|
||||
import * as path from 'path';
|
||||
import { isDirectory } from './is-directory';
|
||||
|
||||
export function findAllNodeModules(from: string, root?: string): string[] {
|
||||
const nodeModules: string[] = [];
|
||||
|
||||
let current = from;
|
||||
while (current && current !== root) {
|
||||
const potential = path.join(current, 'node_modules');
|
||||
if (existsSync(potential) && isDirectory(potential)) {
|
||||
nodeModules.push(potential);
|
||||
}
|
||||
|
||||
const next = path.dirname(current);
|
||||
if (next === current) {
|
||||
break;
|
||||
}
|
||||
current = next;
|
||||
}
|
||||
|
||||
return nodeModules;
|
||||
}
|
@ -41,7 +41,6 @@ import {
|
||||
persistentBuildCacheEnabled,
|
||||
profilingEnabled,
|
||||
} from '../../utils/environment-options';
|
||||
import { findAllNodeModules } from '../../utils/find-up';
|
||||
import { Spinner } from '../../utils/spinner';
|
||||
import { addError } from '../../utils/webpack-diagnostics';
|
||||
import { DedupeModuleResolvePlugin, ScriptsWebpackPlugin } from '../plugins';
|
||||
@ -359,13 +358,6 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
|
||||
},
|
||||
resolveLoader: {
|
||||
symlinks: !buildOptions.preserveSymlinks,
|
||||
modules: [
|
||||
// Allow loaders to be in a node_modules nested inside the devkit/build-angular package.
|
||||
// This is important in case loaders do not get hoisted.
|
||||
// If this file moves to another location, alter potentialNodeModules as well.
|
||||
'node_modules',
|
||||
...findAllNodeModules(__dirname, projectRoot),
|
||||
],
|
||||
},
|
||||
context: root,
|
||||
entry: entryPoints,
|
||||
|
Loading…
x
Reference in New Issue
Block a user