diff --git a/src/compiler/index.ts b/src/compiler/index.ts index 4987c18a15..14d55f5470 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -3,4 +3,4 @@ export { default as parse } from './parse/index'; export { default as preprocess } from './preprocess/index'; export { walk } from 'estree-walker'; -export const VERSION = '__VERSION__'; \ No newline at end of file +export const VERSION = '__VERSION__'; diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index 6c069525ef..51668a93f7 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -1,10 +1,14 @@ -import { SourceMap } from 'magic-string'; +export interface Processed { + code: string; + map?: object | string; + dependencies?: string[]; +} export interface PreprocessorGroup { markup?: (options: { content: string; filename: string; - }) => { code: string; map?: SourceMap | string; dependencies?: string[] }; + }) => Processed; style?: Preprocessor; script?: Preprocessor; } @@ -13,13 +17,7 @@ export type Preprocessor = (options: { content: string; attributes: Record; filename?: string; -}) => { code: string; map?: SourceMap | string; dependencies?: string[] }; - -interface Processed { - code: string; - map?: SourceMap | string; - dependencies?: string[]; -} +}) => Processed; function parse_attributes(str: string) { const attrs = {}; @@ -85,7 +83,7 @@ export default async function preprocess( const style = preprocessors.map(p => p.style).filter(Boolean); for (const fn of markup) { - const processed: Processed = await fn({ + const processed = await fn({ content: source, filename }); @@ -98,7 +96,7 @@ export default async function preprocess( source, /([^]*?)<\/script>/gi, async (match, attributes = '', content) => { - const processed: Processed = await fn({ + const processed = await fn({ content, attributes: parse_attributes(attributes), filename