import { codeFrameColumns } from "@babel/code-frame" ; import { getWorker } from "../worker-client" ; import { Plugin } from "rollup" ; import { MinifyOptions } from "terser" ; export default function terser ( options ) { return { name : "terser" , renderChunk ( code , chunk , outputOptions ) { const normalizedOptions = { ... options , module : outputOptions . format === "es" , } ; const result = getWorker ( ) . transformTerser ( code , JSON . stringify ( normalizedOptions ) ) . catch ( ( error ) => { const { message , line , col : column } = error ; console . error ( codeFrameColumns ( code , { start : { line , column } } , { message } ) ) ; throw error ; } ) ; return result ; } , } ; }