1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Make sure const/async is transpiled (#5760)

* Make sure const/async is transpiled

* Use babel common compilation instead
This commit is contained in:
Tim Neutkens 2018-11-28 17:53:49 +01:00 committed by GitHub
parent 4594b7cb07
commit fb92fdef54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 3 deletions

View file

@ -273,9 +273,9 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
},
{
test: /\.(js|jsx)$/,
include: [dir, NEXT_PROJECT_ROOT_DIST_CLIENT, DEFAULT_PAGES_DIR],
include: [dir, NEXT_PROJECT_ROOT_DIST_CLIENT, DEFAULT_PAGES_DIR, /next-server[\\/]dist[\\/]lib/],
exclude: (path) => {
if (path.indexOf(NEXT_PROJECT_ROOT_DIST_CLIENT) === 0 || path.indexOf(DEFAULT_PAGES_DIR) === 0) {
if (path.indexOf(NEXT_PROJECT_ROOT_DIST_CLIENT) === 0 || path.indexOf(DEFAULT_PAGES_DIR) === 0 || /next-server[\\/]dist[\\/]lib/.exec(path)) {
return false
}

View file

@ -2,6 +2,7 @@ import babelLoader from 'babel-loader'
module.exports = babelLoader.custom(babel => {
const presetItem = babel.createConfigItem(require('../../babel/preset'), {type: 'preset'})
const commonJsItem = babel.createConfigItem(require('@babel/plugin-transform-modules-commonjs'), {type: 'plugin'})
const configs = new Set()
@ -36,6 +37,16 @@ module.exports = babelLoader.custom(babel => {
options.presets = [...options.presets, presetItem]
}
options.overrides = [
...(options.overrides || []),
{
test: /next-server[\\/]dist[\\/]lib/,
plugins: [
commonJsItem
]
}
]
return options
}
}

View file

@ -73,7 +73,7 @@ function throwIfNoRouter () {
export default SingletonRouter
// Reexport the withRoute HOC
export { default as withRouter } from '../lib/with-router'
export { default as withRouter } from './with-router'
// INTERNAL APIS
// -------------

View file

@ -40,6 +40,7 @@
"@babel/plugin-proposal-class-properties": "7.1.0",
"@babel/plugin-proposal-object-rest-spread": "7.0.0",
"@babel/plugin-syntax-dynamic-import": "7.0.0",
"@babel/plugin-transform-modules-commonjs": "7.1.0",
"@babel/plugin-transform-runtime": "7.1.0",
"@babel/preset-env": "7.1.0",
"@babel/preset-react": "7.0.0",