2020-11-06 03:33:14 +01:00
|
|
|
import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core'
|
2020-08-05 22:21:40 +02:00
|
|
|
|
|
|
|
export default function NextPageDisallowReExportAllExports(): PluginObj<any> {
|
|
|
|
return {
|
|
|
|
visitor: {
|
|
|
|
ExportAllDeclaration(path: NodePath<types.ExportAllDeclaration>) {
|
|
|
|
const err = new SyntaxError(
|
|
|
|
`Using \`export * from '...'\` in a page is disallowed. Please use \`export { default } from '...'\` instead.\n` +
|
2021-03-29 10:25:00 +02:00
|
|
|
`Read more: https://nextjs.org/docs/messages/export-all-in-page`
|
2020-08-05 22:21:40 +02:00
|
|
|
)
|
|
|
|
;(err as any).code = 'BABEL_PARSE_ERROR'
|
|
|
|
;(err as any).loc =
|
|
|
|
path.node.loc?.start ?? path.node.loc?.end ?? path.node.loc
|
|
|
|
throw err
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|