mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
types: align compiler-sfc type exports with v3
This commit is contained in:
parent
b3432ffa8f
commit
457fe6d222
@ -57,7 +57,7 @@ const isBuiltInDir = makeMap(
|
||||
`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`
|
||||
)
|
||||
|
||||
export interface ScriptCompileOptions {
|
||||
export interface SFCScriptCompileOptions {
|
||||
/**
|
||||
* Production mode. Used to determine whether to generate hashed CSS variables
|
||||
*/
|
||||
@ -87,7 +87,7 @@ export interface ImportBinding {
|
||||
*/
|
||||
export function compileScript(
|
||||
sfc: SFCDescriptor,
|
||||
options: ScriptCompileOptions = {}
|
||||
options: SFCScriptCompileOptions = {}
|
||||
): SFCScriptBlock {
|
||||
let { filename, script, scriptSetup, source } = sfc
|
||||
const isProd = !!options.isProd
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
StylePreprocessorResults
|
||||
} from './stylePreprocessors'
|
||||
|
||||
export interface StyleCompileOptions {
|
||||
export interface SFCStyleCompileOptions {
|
||||
source: string
|
||||
filename: string
|
||||
id: string
|
||||
@ -21,11 +21,11 @@ export interface StyleCompileOptions {
|
||||
postcssPlugins?: any[]
|
||||
}
|
||||
|
||||
export interface AsyncStyleCompileOptions extends StyleCompileOptions {
|
||||
export interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
|
||||
isAsync?: boolean
|
||||
}
|
||||
|
||||
export interface StyleCompileResults {
|
||||
export interface SFCStyleCompileResults {
|
||||
code: string
|
||||
map: any | void
|
||||
rawResult: LazyResult | void
|
||||
@ -33,20 +33,20 @@ export interface StyleCompileResults {
|
||||
}
|
||||
|
||||
export function compileStyle(
|
||||
options: StyleCompileOptions
|
||||
): StyleCompileResults {
|
||||
options: SFCStyleCompileOptions
|
||||
): SFCStyleCompileResults {
|
||||
return doCompileStyle({ ...options, isAsync: false })
|
||||
}
|
||||
|
||||
export function compileStyleAsync(
|
||||
options: StyleCompileOptions
|
||||
): Promise<StyleCompileResults> {
|
||||
options: SFCStyleCompileOptions
|
||||
): Promise<SFCStyleCompileResults> {
|
||||
return Promise.resolve(doCompileStyle({ ...options, isAsync: true }))
|
||||
}
|
||||
|
||||
export function doCompileStyle(
|
||||
options: AsyncStyleCompileOptions
|
||||
): StyleCompileResults {
|
||||
options: SFCAsyncStyleCompileOptions
|
||||
): SFCStyleCompileResults {
|
||||
const {
|
||||
filename,
|
||||
id,
|
||||
@ -94,7 +94,7 @@ export function doCompileStyle(
|
||||
if (options.isAsync) {
|
||||
return result
|
||||
.then(
|
||||
(result: LazyResult): StyleCompileResults => ({
|
||||
(result: LazyResult): SFCStyleCompileResults => ({
|
||||
code: result.css || '',
|
||||
map: result.map && result.map.toJSON(),
|
||||
errors,
|
||||
@ -102,7 +102,7 @@ export function doCompileStyle(
|
||||
})
|
||||
)
|
||||
.catch(
|
||||
(error: Error): StyleCompileResults => ({
|
||||
(error: Error): SFCStyleCompileResults => ({
|
||||
code: '',
|
||||
map: undefined,
|
||||
errors: [...errors, error.message],
|
||||
@ -127,7 +127,7 @@ export function doCompileStyle(
|
||||
}
|
||||
|
||||
function preprocess(
|
||||
options: StyleCompileOptions,
|
||||
options: SFCStyleCompileOptions,
|
||||
preprocessor: StylePreprocessor
|
||||
): StylePreprocessorResults {
|
||||
return preprocessor(
|
||||
|
@ -13,7 +13,7 @@ import * as _compiler from 'web/entry-compiler'
|
||||
import { prefixIdentifiers } from './prefixIdentifiers'
|
||||
import { WarningMessage } from 'types/compiler'
|
||||
|
||||
export interface TemplateCompileOptions {
|
||||
export interface SFCTemplateCompileOptions {
|
||||
source: string
|
||||
filename: string
|
||||
compiler?: VueTemplateCompiler
|
||||
@ -31,7 +31,7 @@ export interface TemplateCompileOptions {
|
||||
bindings?: BindingMetadata
|
||||
}
|
||||
|
||||
export interface TemplateCompileResult {
|
||||
export interface SFCTemplateCompileResult {
|
||||
ast: Object | undefined
|
||||
code: string
|
||||
source: string
|
||||
@ -40,8 +40,8 @@ export interface TemplateCompileResult {
|
||||
}
|
||||
|
||||
export function compileTemplate(
|
||||
options: TemplateCompileOptions
|
||||
): TemplateCompileResult {
|
||||
options: SFCTemplateCompileOptions
|
||||
): SFCTemplateCompileResult {
|
||||
const { preprocessLang } = options
|
||||
const preprocessor = preprocessLang && consolidate[preprocessLang]
|
||||
if (preprocessor) {
|
||||
@ -68,7 +68,7 @@ export function compileTemplate(
|
||||
}
|
||||
|
||||
function preprocess(
|
||||
options: TemplateCompileOptions,
|
||||
options: SFCTemplateCompileOptions,
|
||||
preprocessor: any
|
||||
): string {
|
||||
const { source, filename, preprocessOptions } = options
|
||||
@ -99,8 +99,8 @@ function preprocess(
|
||||
}
|
||||
|
||||
function actuallyCompile(
|
||||
options: TemplateCompileOptions
|
||||
): TemplateCompileResult {
|
||||
options: SFCTemplateCompileOptions
|
||||
): SFCTemplateCompileResult {
|
||||
const {
|
||||
source,
|
||||
compiler = _compiler,
|
||||
|
@ -8,8 +8,8 @@ export { generateCodeFrame } from 'compiler/codeframe'
|
||||
// types
|
||||
export { SFCBlock, SFCCustomBlock, SFCDescriptor } from './parseComponent'
|
||||
export {
|
||||
TemplateCompileOptions,
|
||||
TemplateCompileResult
|
||||
SFCTemplateCompileOptions,
|
||||
SFCTemplateCompileResult
|
||||
} from './compileTemplate'
|
||||
export { StyleCompileOptions, StyleCompileResults } from './compileStyle'
|
||||
export { ScriptCompileOptions } from './compileScript'
|
||||
export { SFCStyleCompileOptions, SFCStyleCompileResults } from './compileStyle'
|
||||
export { SFCScriptCompileOptions } from './compileScript'
|
||||
|
Loading…
Reference in New Issue
Block a user