Unverified Commit 35bbe309 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Optimize resolve configuration (#6954)

* Resolve Next.js loaders first

Next.js loaders should be resolved first, then node_modules. There is no need for NEXT_PROJECT_ROOT_NODE_MODULES anymore since all our loaders are internal

* Move wasm to end of array

Since wasm isn’t the main target for Next.js it makes no sense to try and resolve it as the first value, as it would incur a file not found for nearly all files in the compilation
parent 4b7dd253
...@@ -47,7 +47,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug = ...@@ -47,7 +47,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
const resolveConfig = { const resolveConfig = {
// Disable .mjs for node_modules bundling // Disable .mjs for node_modules bundling
extensions: isServer ? ['.wasm', '.js', '.mjs', '.jsx', '.json'] : ['.wasm', '.mjs', '.js', '.jsx', '.json'], extensions: isServer ? ['.js', '.mjs', '.jsx', '.json', '.wasm'] : ['.mjs', '.js', '.jsx', '.json', '.wasm'],
modules: [ modules: [
'node_modules', 'node_modules',
...nodePathList // Support for NODE_PATH environment variable ...nodePathList // Support for NODE_PATH environment variable
...@@ -212,9 +212,8 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug = ...@@ -212,9 +212,8 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
resolve: resolveConfig, resolve: resolveConfig,
resolveLoader: { resolveLoader: {
modules: [ modules: [
NEXT_PROJECT_ROOT_NODE_MODULES,
'node_modules',
path.join(__dirname, 'webpack', 'loaders'), // The loaders Next.js provides path.join(__dirname, 'webpack', 'loaders'), // The loaders Next.js provides
'node_modules',
...nodePathList // Support for NODE_PATH environment variable ...nodePathList // Support for NODE_PATH environment variable
] ]
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment