diff --git a/packages/bytemd/build.mjs b/packages/bytemd/scripts/build.mjs similarity index 82% rename from packages/bytemd/build.mjs rename to packages/bytemd/scripts/build.mjs index 9db9db5..a9a70d4 100644 --- a/packages/bytemd/build.mjs +++ b/packages/bytemd/scripts/build.mjs @@ -5,18 +5,7 @@ import { preprocess } from 'svelte/compiler' import glob from 'fast-glob' import { build } from 'vite' import { resolveModule } from 'local-pkg' -import sveltePreprocess from 'svelte-preprocess' - -export const sveltePreprocessor = sveltePreprocess({ - typescript: true, - // https://github.com/sveltejs/svelte/issues/189#issuecomment-586142198 - replace: [ - [/(>)[\s]*([<{])/g, '$1$2'], - [/({[/:][a-z]+})[\s]*([<{])/g, '$1$2'], - [/({[#:][a-z]+ .+?})[\s]*([<{])/g, '$1$2'], - [/([>}])[\s]+(<|{[/#:][a-z][^}]*})/g, '$1$2'], - ], -}) +import { sveltePreprocessor } from './utils.mjs' const pkgName = 'decode-named-character-reference' const resolveOptions = { diff --git a/packages/bytemd/scripts/utils.mjs b/packages/bytemd/scripts/utils.mjs new file mode 100644 index 0000000..4bd6752 --- /dev/null +++ b/packages/bytemd/scripts/utils.mjs @@ -0,0 +1,13 @@ +// @ts-check +import sveltePreprocess from 'svelte-preprocess' + +export const sveltePreprocessor = sveltePreprocess({ + typescript: true, + // https://github.com/sveltejs/svelte/issues/189#issuecomment-586142198 + replace: [ + [/(>)[\s]*([<{])/g, '$1$2'], + [/({[/:][a-z]+})[\s]*([<{])/g, '$1$2'], + [/({[#:][a-z]+ .+?})[\s]*([<{])/g, '$1$2'], + [/([>}])[\s]+(<|{[/#:][a-z][^}]*})/g, '$1$2'], + ], +}) diff --git a/packages/bytemd/tsdv.config.mjs b/packages/bytemd/tsdv.config.mjs index 6d2dd6f..055423e 100644 --- a/packages/bytemd/tsdv.config.mjs +++ b/packages/bytemd/tsdv.config.mjs @@ -1,7 +1,7 @@ // @ts-check import { defineConfig } from 'tsdv' import { svelte } from '@sveltejs/vite-plugin-svelte' -import { sveltePreprocessor } from './build.mjs' +import { sveltePreprocessor } from './scripts/utils.mjs' // nullish coalescing in es2020 // TODO: 'decode-named-character-reference'