Skip to content

Commit

Permalink
refactor: Update MinifyJS function to support different target versions
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Jun 27, 2024
1 parent c58e9a3 commit c4b0bb9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion runtime/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 22,18 @@ func TypeScript(tsCode string, option api.TransformOptions) (string, error) {
}

// MinifyJS minify the javascript code
func MinifyJS(jsCode string) (string, error) {
func MinifyJS(jsCode string, target ...api.Target) (string, error) {

t := api.ES2015
if len(target) > 0 {
t = target[0]
}
result := api.Transform(jsCode, api.TransformOptions{
Loader: api.LoaderJS,
MinifyWhitespace: true,
MinifyIdentifiers: true,
MinifySyntax: true,
Target: t,
})

if len(result.Errors) > 0 {
Expand Down

0 comments on commit c4b0bb9

Please sign in to comment.