Remove external dependencies from exported files

pull/3400/head
Luiz Corte Real 5 years ago committed by Tech
parent 4f26363fe0
commit 52b0951db6

@ -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__';
export const VERSION = '__VERSION__';

@ -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<string, string | boolean>;
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(\s[^]*?)?>([^]*?)<\/script>/gi,
async (match, attributes = '', content) => {
const processed: Processed = await fn({
const processed = await fn({
content,
attributes: parse_attributes(attributes),
filename

Loading…
Cancel
Save