1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/packages/next/build/babel/plugins/next-to-next-server.ts
Tim Neutkens 9112f63eba
Move phases back to next/constants (#6104)
* Move phases back to next/constants

* Fix typescript error
2019-01-23 14:10:12 +01:00

23 lines
722 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/config') {
path.node.source.value = 'next-server/config'
}
if (source === 'next/head') {
path.node.source.value = 'next-server/head'
}
}
}
}
}