From dfab78e840bdc099354f7a419c440232599b06dc Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Fri, 10 Dec 2021 16:48:40 +0800 Subject: [PATCH] chore: tweaks --- src/plugins/es5.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/es5.ts b/src/plugins/es5.ts index 4d1c263c..756e1abb 100644 --- a/src/plugins/es5.ts +++ b/src/plugins/es5.ts @@ -1,3 +1,4 @@ +import { PrettyError } from '../errors' import { Plugin } from '../plugin' import { localRequire } from '../utils' @@ -18,6 +19,13 @@ export const es5 = (): Plugin => { return } const swc: typeof import('@swc/core') = localRequire('@swc/core') + + if (!swc) { + throw new PrettyError( + '@swc/core is required for es5 target. Please install it with `npm install @swc/core -D`' + ) + } + const result = await swc.transform(code, { filename: info.path, sourceMaps: this.options.sourcemap,