import deindent from 'de-indent' import { parseHTML } from 'compiler/parser/html-parser' import { makeMap } from 'shared/util' import { ASTAttr, WarningMessage } from 'types/compiler' import { BindingMetadata, RawSourceMap } from './types' import type { ImportBinding } from './compileScript' export const DEFAULT_FILENAME = 'anonymous.vue' const splitRE = /\r?\n/g const replaceRE = /./g const isSpecialTag = makeMap('script,style,template', true) export interface SFCCustomBlock { type: string content: string attrs: { [key: string]: string | true } start: number end: number src?: string map?: RawSourceMap } export interface SFCBlock extends SFCCustomBlock { lang?: string scoped?: boolean module?: string | boolean } export interface SFCScriptBlock extends SFCBlock { type: 'script' setup?: string | boolean bindings?: BindingMetadata imports?: Record /** * import('\@babel/types').Statement */ scriptAst?: any[] /** * import('\@babel/types').Statement */ scriptSetupAst?: any[] } export interface SFCDescriptor { source: string filename: string template: SFCBlock | null script: SFCScriptBlock | null scriptSetup: SFCScriptBlock | null styles: SFCBlock[] customBlocks: SFCCustomBlock[] cssVars: string[] errors: (string | WarningMessage)[] /** * compare with an existing descriptor to determine whether HMR should perform * a reload vs. re-render. * * Note: this comparison assumes the prev/next script are already identical, * and only checks the special case where `