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:
parent
93586573e8
commit
0f6cff88bc
31
packages/next/build/babel/plugins/next-to-next-server.js
Normal file
31
packages/next/build/babel/plugins/next-to-next-server.js
Normal 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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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'), {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue