Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,6 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
];
}

// 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.
const loaderNodeModules = findAllNodeModules(__dirname, projectRoot);
loaderNodeModules.unshift('node_modules');

const extraMinimizers = [];
if (stylesOptimization) {
extraMinimizers.push(
Expand Down Expand Up @@ -485,22 +479,33 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
resolve: {
extensions: ['.ts', '.tsx', '.mjs', '.js'],
symlinks: !buildOptions.preserveSymlinks,
modules: [wco.tsConfig.options.baseUrl || projectRoot, 'node_modules'],
modules: [
wco.tsConfig.options.baseUrl || projectRoot,
// Prefer workspace level node_modules
path.resolve(root, 'node_modules'),
'node_modules',
],
plugins: [
PnpWebpackPlugin,
new DedupeModuleResolvePlugin({ verbose: buildOptions.verbose }),
],
},
resolveLoader: {
symlinks: !buildOptions.preserveSymlinks,
modules: loaderNodeModules,
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.
...findAllNodeModules(__dirname, root),
'node_modules',
],
plugins: [PnpWebpackPlugin.moduleLoader(module)],
},
context: projectRoot,
entry: entryPoints,
output: {
futureEmitAssets: true,
path: path.resolve(root, buildOptions.outputPath as string),
path: path.resolve(root, buildOptions.outputPath),
publicPath: buildOptions.deployUrl,
filename: `[name]${targetInFileName}${hashFormat.chunk}.js`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DedupeModuleResolvePlugin {
apply(resolver: any) {
resolver
.getHook('before-described-relative')
.tapPromise('DedupeModuleResolvePlugin', async (request: NormalModuleFactoryRequest) => {
.tap('DedupeModuleResolvePlugin', (request: NormalModuleFactoryRequest) => {
if (request.relativePath !== '.') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { existsSync } from 'fs';
import * as path from 'path';
import { isDirectory } from './is-directory';

export function findUp(names: string | string[], from: string, stopOnNodeModules = false) {
export function findUp(names: string | string[], from: string, stopOnNodeModules = false): string | null {
if (!Array.isArray(names)) {
names = [names];
}
Expand Down Expand Up @@ -37,7 +37,7 @@ export function findUp(names: string | string[], from: string, stopOnNodeModules
return null;
}

export function findAllNodeModules(from: string, root?: string) {
export function findAllNodeModules(from: string, root?: string): string[] {
const nodeModules: string[] = [];

let current = from;
Expand Down