From 52b0951db67aee1dda6e69b6d8582b5de36e92a9 Mon Sep 17 00:00:00 2001 From: Luiz Corte Real Date: Mon, 12 Aug 2019 17:37:20 -0300 Subject: [PATCH 1/2] Remove external dependencies from exported files --- src/compiler/index.ts | 3 +-- src/compiler/preprocess/index.ts | 20 +++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/compiler/index.ts b/src/compiler/index.ts index 4987c18a15..ba68231837 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -1,6 +1,5 @@ export { default as compile } from './compile/index'; 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 From 9e36293a8c652844f56cfaab5a0d9e9000757456 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 14 Aug 2019 21:13:17 -0400 Subject: [PATCH 2/2] Reinstate walk --- src/compiler/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/index.ts b/src/compiler/index.ts index ba68231837..14d55f5470 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -1,5 +1,6 @@ export { default as compile } from './compile/index'; export { default as parse } from './parse/index'; export { default as preprocess } from './preprocess/index'; +export { walk } from 'estree-walker'; export const VERSION = '__VERSION__';