import {PluginObj} from '@babel/core' import {NodePath} from '@babel/traverse' import {ImportDeclaration} from '@babel/types' // Rewrite imports using next/ to next-server/ export default function NextToNextServer (): PluginObj { return { visitor: { ImportDeclaration (path: NodePath) { const source = path.node.source.value if (source === 'next/dynamic') { path.node.source.value = 'next-server/dynamic' } if (source === 'next/config') { path.node.source.value = 'next-server/config' } if (source === 'next/head') { path.node.source.value = 'next-server/head' } } } } }