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 compile } from './compile/index';
export { default as parse } from './parse/index'; export { default as parse } from './parse/index';
export { default as preprocess } from './preprocess/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 { export interface PreprocessorGroup {
markup?: (options: { markup?: (options: {
content: string; content: string;
filename: string; filename: string;
}) => { code: string; map?: SourceMap | string; dependencies?: string[] }; }) => Processed;
style?: Preprocessor; style?: Preprocessor;
script?: Preprocessor; script?: Preprocessor;
} }
@ -13,13 +17,7 @@ export type Preprocessor = (options: {
content: string; content: string;
attributes: Record<string, string | boolean>; attributes: Record<string, string | boolean>;
filename?: string; filename?: string;
}) => { code: string; map?: SourceMap | string; dependencies?: string[] }; }) => Processed;
interface Processed {
code: string;
map?: SourceMap | string;
dependencies?: string[];
}
function parse_attributes(str: string) { function parse_attributes(str: string) {
const attrs = {}; const attrs = {};
@ -85,7 +83,7 @@ export default async function preprocess(
const style = preprocessors.map(p => p.style).filter(Boolean); const style = preprocessors.map(p => p.style).filter(Boolean);
for (const fn of markup) { for (const fn of markup) {
const processed: Processed = await fn({ const processed = await fn({
content: source, content: source,
filename filename
}); });
@ -98,7 +96,7 @@ export default async function preprocess(
source, source,
/<script(\s[^]*?)?>([^]*?)<\/script>/gi, /<script(\s[^]*?)?>([^]*?)<\/script>/gi,
async (match, attributes = '', content) => { async (match, attributes = '', content) => {
const processed: Processed = await fn({ const processed = await fn({
content, content,
attributes: parse_attributes(attributes), attributes: parse_attributes(attributes),
filename filename

Loading…
Cancel
Save