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.js

32 lines
985 B
JavaScript
Raw Normal View History

2018-10-05 21:40:36 +00:00
// 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'
}
}
}
}
}