From cf39b8b3a43427929de526343406683f8c6b5d04 Mon Sep 17 00:00:00 2001 From: Maxim Matyunin Date: Mon, 6 Jan 2020 13:27:58 +0900 Subject: [PATCH] add test --- src/compiler/preprocess/index.ts | 12 +++++++++--- test/preprocess/samples/strict-order/_config.js | 11 +++++++++++ test/preprocess/samples/strict-order/input.svelte | 11 +++++++++++ test/preprocess/samples/strict-order/output.svelte | 11 +++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 test/preprocess/samples/strict-order/_config.js create mode 100644 test/preprocess/samples/strict-order/input.svelte create mode 100644 test/preprocess/samples/strict-order/output.svelte diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index 0b83c05deb..60609f0275 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -184,19 +184,25 @@ export default async function preprocess( if (p.markup) { processed = await process_markup(source, p.markup, filename); source = processed.source; - if (processed.dependencies.length) dependencies.push(...processed.dependencies); + if (processed.dependencies && processed.dependencies.length) { + dependencies.push(...processed.dependencies); + } } if (p.script) { processed = await process_script(source, p.script, filename); source = processed.source; - if (processed.dependencies.length) dependencies.push(...processed.dependencies); + if (processed.dependencies && processed.dependencies.length) { + dependencies.push(...processed.dependencies); + } } if (p.style) { processed = await process_style(source, p.style, filename); source = processed.source; - if (processed.dependencies.length) dependencies.push(...processed.dependencies); + if (processed.dependencies && processed.dependencies.length) { + dependencies.push(...processed.dependencies); + } } }); diff --git a/test/preprocess/samples/strict-order/_config.js b/test/preprocess/samples/strict-order/_config.js new file mode 100644 index 0000000000..e47e14b929 --- /dev/null +++ b/test/preprocess/samples/strict-order/_config.js @@ -0,0 +1,11 @@ +export default { + strictOrder: false, + preprocess: [ + { + style: ({ content }) => ({ code: content.replace(/one/g, 'two') }), + }, + { + markup: ({ content }) => ({ code: content.replace(/two/g, 'three') }), + }, + ], +}; diff --git a/test/preprocess/samples/strict-order/input.svelte b/test/preprocess/samples/strict-order/input.svelte new file mode 100644 index 0000000000..3bf89c6b95 --- /dev/null +++ b/test/preprocess/samples/strict-order/input.svelte @@ -0,0 +1,11 @@ +

one

+ + + + \ No newline at end of file diff --git a/test/preprocess/samples/strict-order/output.svelte b/test/preprocess/samples/strict-order/output.svelte new file mode 100644 index 0000000000..3bf89c6b95 --- /dev/null +++ b/test/preprocess/samples/strict-order/output.svelte @@ -0,0 +1,11 @@ +

one

+ + + + \ No newline at end of file