const { compile, preprocess } = require('svelte'); async parse(inputCode) { let svelteOptions = { compilerOptions: { generate: 'dom', format: 'cjs', store: true, filename: this.relativeName, css: false }, preprocess: undefined }; const customConfig = await this.getConfig(['.svelterc', 'svelte.config.js', 'package.json']); if (customConfig) { svelteOptions = Object.assign(svelteOptions, customConfig.svelte || customConfig); } if (svelteOptions.preprocess) { const preprocessed = await preprocess(inputCode, svelteOptions.preprocess); inputCode = preprocessed.toString(); } return compile(inputCode, svelteOptions.compilerOptions); }