diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts
index 26c89f01d6..0b83c05deb 100644
--- a/src/compiler/preprocess/index.ts
+++ b/src/compiler/preprocess/index.ts
@@ -80,7 +80,7 @@ async function process_markup(
return {
source: processed ? processed.code : source,
- dependencies: processed.dependencies,
+ dependencies: processed.dependencies
};
}
@@ -91,28 +91,29 @@ async function process_script(
) {
const dependencies = [];
- const s = await replace_async(
- source,
- /|` : match;
+ source = await replace_async(
+ source,
+ /|` : match;
+ }
+ );
return {
- source: s,
+ source,
dependencies,
};
}
@@ -124,7 +125,7 @@ async function process_style(
) {
const dependencies = [];
- const s = await replace_async(
+ source = await replace_async(
source,
/|` : match;
}
);
return {
- source: s,
+ source,
dependencies,
};
}
-async function asyncForEach(array, callback) {
- // eslint-disable-next-line
+async function async_for_each(array, callback) {
for (let index = 0; index < array.length; index++) {
- // eslint-disable-next-line
await callback(array[index], index, array);
}
}
-
export default async function preprocess(
source: string,
preprocessor: PreprocessorGroup | PreprocessorGroup[],
@@ -164,11 +165,12 @@ export default async function preprocess(
) {
// @ts-ignore todo: doublecheck
const filename = (options && options.filename) || preprocessor.filename; // legacy
+ const strictOrder = options && options.strictOrder;
const dependencies = [];
const preprocessors = Array.isArray(preprocessor) ? preprocessor : [preprocessor];
- const order = options.strictOrder
+ const order = strictOrder
? preprocessors
: [
...preprocessors.map(({ markup }) => ({ markup })),
@@ -176,27 +178,25 @@ export default async function preprocess(
...preprocessors.map(({ style }) => ({ style })),
];
- console.log(preprocessors);
-
- await asyncForEach(order, async p => {
+ await async_for_each(order, async p => {
let processed;
if (p.markup) {
processed = await process_markup(source, p.markup, filename);
source = processed.source;
- dependencies.push(processed.dependencies);
+ if (processed.dependencies.length) dependencies.push(...processed.dependencies);
}
if (p.script) {
processed = await process_script(source, p.script, filename);
source = processed.source;
- dependencies.push(processed.dependencies);
+ if (processed.dependencies.length) dependencies.push(...processed.dependencies);
}
if (p.style) {
processed = await process_style(source, p.style, filename);
source = processed.source;
- dependencies.push(processed.dependencies);
+ if (processed.dependencies.length) dependencies.push(...processed.dependencies);
}
});