defineExpose.ts 480 B

12345678910111213141516171819
  1. import type { Node } from '@babel/types'
  2. import { isCallOf } from './utils'
  3. import type { ScriptCompileContext } from './context'
  4. export const DEFINE_EXPOSE = 'defineExpose'
  5. export function processDefineExpose(
  6. ctx: ScriptCompileContext,
  7. node: Node,
  8. ): boolean {
  9. if (isCallOf(node, DEFINE_EXPOSE)) {
  10. if (ctx.hasDefineExposeCall) {
  11. ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node)
  12. }
  13. ctx.hasDefineExposeCall = true
  14. return true
  15. }
  16. return false
  17. }