20 lines
480 B
TypeScript
20 lines
480 B
TypeScript
import type { Node } from '@babel/types'
|
|
import { isCallOf } from './utils'
|
|
import type { ScriptCompileContext } from './context'
|
|
|
|
export const DEFINE_EXPOSE = 'defineExpose'
|
|
|
|
export function processDefineExpose(
|
|
ctx: ScriptCompileContext,
|
|
node: Node,
|
|
): boolean {
|
|
if (isCallOf(node, DEFINE_EXPOSE)) {
|
|
if (ctx.hasDefineExposeCall) {
|
|
ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node)
|
|
}
|
|
ctx.hasDefineExposeCall = true
|
|
return true
|
|
}
|
|
return false
|
|
}
|