import MagicString from 'magic-string' import { BindingMetadata, BindingTypes, createRoot, NodeTypes, transform, parserOptions, UNREF, SimpleExpressionNode, isFunctionType, walkIdentifiers } from '@vue/compiler-dom' import { SFCDescriptor, SFCScriptBlock } from './parse' import { parse as _parse, ParserOptions, ParserPlugin } from '@babel/parser' import { babelParserDefaultPlugins, camelize, capitalize, generateCodeFrame, makeMap } from '@vue/shared' import { Node, Declaration, ObjectPattern, ObjectExpression, ArrayPattern, Identifier, ExportSpecifier, TSType, TSTypeLiteral, TSFunctionType, ObjectProperty, ArrayExpression, Statement, CallExpression, RestElement, TSInterfaceBody, AwaitExpression, Program, ObjectMethod } from '@babel/types' import { walk } from 'estree-walker' import { RawSourceMap } from 'source-map' import { CSS_VARS_HELPER, genCssVarsCode, genNormalScriptCssVarsCode } from './cssVars' import { compileTemplate, SFCTemplateCompileOptions } from './compileTemplate' import { warnOnce } from './warn' import { rewriteDefault } from './rewriteDefault' import { createCache } from './cache' import { shouldTransform as shouldTransformRef, transformAST as transformRefAST } from '@vue/ref-transform' // Special compiler macros const DEFINE_PROPS = 'defineProps' const DEFINE_EMITS = 'defineEmits' const DEFINE_EXPOSE = 'defineExpose' const WITH_DEFAULTS = 'withDefaults' const isBuiltInDir = makeMap( `once,memo,if,else,else-if,slot,text,html,on,bind,model,show,cloak,is` ) export interface SFCScriptCompileOptions { /** * Scope ID for prefixing injected CSS varialbes. * This must be consistent with the `id` passed to `compileStyle`. */ id: string /** * Production mode. Used to determine whether to generate hashed CSS variables */ isProd?: boolean /** * Enable/disable source map. Defaults to true. */ sourceMap?: boolean /** * https://babeljs.io/docs/en/babel-parser#plugins */ babelParserPlugins?: ParserPlugin[] /** * (Experimental) Enable syntax transform for using refs without `.value` * https://github.com/vuejs/rfcs/discussions/369 * @default true */ refTransform?: boolean /** * @deprecated use `refTransform` instead. */ refSugar?: boolean /** * Compile the template and inline the resulting render function * directly inside setup(). * - Only affects `