mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
b4ade0a3cd
This reverts commit 9112f63eba
.
26 lines
834 B
TypeScript
26 lines
834 B
TypeScript
import {PluginObj} from '@babel/core'
|
|
import {NodePath} from '@babel/traverse'
|
|
import {ImportDeclaration} from '@babel/types'
|
|
// Rewrite imports using next/<something> to next-server/<something>
|
|
export default function NextToNextServer (): PluginObj {
|
|
return {
|
|
visitor: {
|
|
ImportDeclaration (path: NodePath<ImportDeclaration>) {
|
|
const source = path.node.source.value
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|