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 02ab732096
Remove next/asset (#6046)
* Remove next/asset

Reasoning described in #5970

* Remove next/asset tests

* Bring back asset-page
2019-01-14 01:32:20 +01:00

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'
}
}
}
}
}