Skip to content

Commit efe0c7b

Browse files
timneutkensrauchg
authored andcommitted
Resolve all modules through module resolver (vercel#963)
1 parent fca0a39 commit efe0c7b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

server/build/webpack.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ export default async function createCompiler (dir, { dev = false, quiet = false
154154
if (!(/\.js$/.test(interpolatedName))) {
155155
return { content, sourceMap }
156156
}
157-
157+
const babelRuntimePath = require.resolve('babel-runtime/package')
158+
.replace(/[\\/]package\.json$/, '')
158159
const transpiled = babelCore.transform(content, {
159160
presets: [require.resolve('babel-preset-es2015')],
160161
sourceMaps: dev ? 'both' : false,
161-
// Here we need to resolve styled-jsx/style to the absolute paths.
162+
// Here we need to resolve all modules to the absolute paths.
162163
// Earlier we did it with the babel-preset.
163164
// But since we don't transpile ES2015 in the preset this is not resolving.
164165
// That's why we need to do it here.
@@ -168,7 +169,16 @@ export default async function createCompiler (dir, { dev = false, quiet = false
168169
require.resolve('babel-plugin-module-resolver'),
169170
{
170171
alias: {
171-
'styled-jsx/style': require.resolve('styled-jsx/style')
172+
'babel-runtime': babelRuntimePath,
173+
react: require.resolve('react'),
174+
'react-dom': require.resolve('react-dom'),
175+
'react-dom/server': require.resolve('react-dom/server'),
176+
'next/link': require.resolve('../../lib/link'),
177+
'next/prefetch': require.resolve('../../lib/prefetch'),
178+
'next/css': require.resolve('../../lib/css'),
179+
'next/head': require.resolve('../../lib/head'),
180+
'next/document': require.resolve('../../server/document'),
181+
'next/router': require.resolve('../../lib/router')
172182
}
173183
}
174184
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy