chore: tweaks

This commit is contained in:
EGOIST 2021-12-10 16:48:40 +08:00
parent 7f2660c8ef
commit dfab78e840

View File

@ -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,