Skip to content

Commit 8811a33

Browse files
arunodarauchg
authored andcommitted
Remove default next pages compilation from the main babel-loader. (#731)
* Remove default next pages compilation from the main babel-loader. This will fix the issue when the user ignore node_modules via our .babelrc option. * Change babel-loaders 'query' to 'options'. That's what's supported/recommended in webpack 2
1 parent b7e57f9 commit 8811a33

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

server/build/babel/preset.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module.exports = {
2727
'next/head': require.resolve('../../../lib/head'),
2828
'next/document': require.resolve('../../../server/document'),
2929
'next/router': require.resolve('../../../lib/router'),
30-
'styled-jsx/style': require.resolve('styled-jsx/style')
30+
'styled-jsx/style': require.resolve('styled-jsx/style'),
31+
'ansi-html': require.resolve('ansi-html')
3132
}
3233
}
3334
]

server/build/webpack.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,23 @@ export default async function createCompiler (dir, { dev = false, quiet = false
143143
}, {
144144
loader: 'babel-loader',
145145
include: nextPagesDir,
146+
exclude (str) {
147+
return /node_modules/.test(str) && str.indexOf(nextPagesDir) !== 0
148+
},
146149
options: {
147150
babelrc: false,
148151
cacheDirectory: true,
149152
sourceMaps: dev ? 'both' : false,
150-
plugins: [
151-
[
152-
require.resolve('babel-plugin-module-resolver'),
153-
{
154-
alias: {
155-
'ansi-html': require.resolve('ansi-html'),
156-
'styled-jsx/style': require.resolve('styled-jsx/style')
157-
}
158-
}
159-
]
160-
]
153+
presets: [require.resolve('./babel/preset')]
161154
}
162155
}, {
163156
test: /\.js(\?[^?]*)?$/,
164157
loader: 'babel-loader',
165-
include: [dir, nextPagesDir],
158+
include: [dir],
166159
exclude (str) {
167-
return /node_modules/.test(str) && str.indexOf(nextPagesDir) !== 0
160+
return /node_modules/.test(str)
168161
},
169-
query: mainBabelOptions
162+
options: mainBabelOptions
170163
}])
171164

172165
let webpackConfig = {

0 commit comments

Comments
 (0)