import MagicString from 'magic-string' import LRU from 'lru-cache' import { walkIdentifiers, isFunctionType } from './babelUtils' import { BindingMetadata, BindingTypes } from './types' import { SFCDescriptor, SFCScriptBlock } from './parseComponent' import { parse as _parse, parseExpression, ParserOptions, ParserPlugin } from '@babel/parser' import { generateCodeFrame } from 'compiler/codeframe' import { camelize, capitalize, isBuiltInTag, makeMap } from 'shared/util' import { parseHTML } from 'compiler/parser/html-parser' import { baseOptions as webCompilerOptions } from 'web/compiler/options' import { Node, Declaration, ObjectPattern, ObjectExpression, ArrayPattern, Identifier, ExportSpecifier, TSType, TSTypeLiteral, TSFunctionType, ObjectProperty, ArrayExpression, Statement, CallExpression, RestElement, TSInterfaceBody, Program, ObjectMethod, LVal, Expression } from '@babel/types' import { walk } from 'estree-walker' import { RawSourceMap } from 'source-map' import { warnOnce } from './warn' import { isReservedTag } from 'web/util' import { bindRE, dirRE, onRE, slotRE } from 'compiler/parser' import { parseText } from 'compiler/parser/text-parser' import { DEFAULT_FILENAME } from './parseComponent' import { CSS_VARS_HELPER, genCssVarsCode, genNormalScriptCssVarsCode } from './cssVars' import { rewriteDefault } from './rewriteDefault' // Special compiler macros const DEFINE_PROPS = 'defineProps' const DEFINE_EMITS = 'defineEmits' const DEFINE_EXPOSE = 'defineExpose' const WITH_DEFAULTS = 'withDefaults' // constants const DEFAULT_VAR = `__default__` const isBuiltInDir = makeMap( `once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is` ) export interface SFCScriptCompileOptions { /** * Scope ID for prefixing injected CSS variables. * 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[] } export interface ImportBinding { isType: boolean imported: string source: string isFromSetup: boolean isUsedInTemplate: boolean } /** * Compile `