mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
32 lines
985 B
JavaScript
32 lines
985 B
JavaScript
|
// 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'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|