diff --git a/src/index.ts b/src/index.ts index 5ac6e93..b67112b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -209,13 +209,18 @@ export default function VuePlugin(opts: VuePluginOptions = {}): Plugin { ? hash(path.basename(filename) + source) : hash(filename + source)) descriptors.set(filename, descriptor) + + const styles = await Promise.all( + descriptor.styles.map(async style => { + const compiled = await compiler.compileStyleAsync(filename, scopeId, style) + if (compiled.errors.length > 0) throw Error(compiled.errors[0]) + return compiled + }) + ) + const input: any = { scopeId, - styles: await Promise.all( - descriptor.styles.map(style => - compiler.compileStyleAsync(filename, scopeId, style) - ) - ), + styles, customBlocks: [] } diff --git a/test/forward-style-compiler-errors.spec.ts b/test/forward-style-compiler-errors.spec.ts new file mode 100644 index 0000000..16259af --- /dev/null +++ b/test/forward-style-compiler-errors.spec.ts @@ -0,0 +1,16 @@ +import pluginVue from '..' +describe("forward-style-compiler-errors", () => { + it("throws", async () => { + let plugin = pluginVue() + await expect((plugin as any).transform(` + + + `, 'virtual-file.vue' + ) + ).rejects.toBeInstanceOf(Error) + }) +})