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

Add next-to-next-server

This commit is contained in:
Tim Neutkens 2018-10-05 23:40:36 +02:00
parent 93586573e8
commit 0f6cff88bc
3 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,31 @@
// Rewrite imports using next/<something> to next-server/<something>
export default function ({ types: t, template }) {
return {
visitor: {
ImportDeclaration (path) {
const source = path.node.source.value
if (source === 'next/asset') {
path.node.source.value = 'next-server/asset'
}
if (source === 'next/dynamic') {
path.node.source.value = 'next-server/dynamic'
}
if (source === 'next/constants') {
path.node.source.value = 'next-server/constants'
}
if (source === 'next/config') {
path.node.source.value = 'next-server/config'
}
if (source === 'next/head') {
path.node.source.value = 'next-server/head'
}
if (source === 'next/link') {
path.node.source.value = 'next-server/link'
}
if (source === 'next/router') {
path.node.source.value = 'next-server/router'
}
}
}
}
}

View file

@ -47,6 +47,7 @@ module.exports = (context, opts = {}) => ({
require('babel-plugin-react-require'),
require('@babel/plugin-syntax-dynamic-import'),
require('./plugins/react-loadable-plugin'),
require('./plugins/next-to-next-server'),
[require('@babel/plugin-proposal-class-properties'), opts['class-properties'] || {}],
require('@babel/plugin-proposal-object-rest-spread'),
[require('@babel/plugin-transform-runtime'), {

View file

@ -32,7 +32,7 @@ function externalsConfig (dir, isServer) {
return externals
}
const notExternalModules = ['next/app', 'next/document', 'next/error']
const notExternalModules = ['next/app', 'next/document', 'next/error', 'http-status']
externals.push((context, request, callback) => {
if (notExternalModules.indexOf(request) !== -1) {