shithub: mycel

Download patch

ref: 1d50aea6c14615b107116dac70e71454099ece5d
parent: dad0d6351deb0de70f34de84b3bd7f50d614e45c
author: Philip Silva <philip.silva@protonmail.com>
date: Sat May 8 13:55:00 EDT 2021

6to5

diff: cannot open b/cmd/6to5//null: file does not exist: 'b/cmd/6to5//null'
--- /dev/null
+++ b/cmd/6to5/main.go
@@ -1,0 +1,36 @@
+// Conversion of ES6+ into ES5.1 (wip)
+//
+// TODO: turn into a script that uses devjs
+package main
+
+import (
+	"fmt"
+	"github.com/jvatic/goja-babel"
+	"io"
+	"log"
+	"os"
+)
+
+func Main() (err error) {
+	babel.Init(1) // Setup 1 transformer (can be any number > 0)
+	r, err := babel.Transform(os.Stdin, map[string]interface{}{
+		"plugins": []string{
+			"transform-block-scoping",
+			"transform-destructuring",
+			"transform-spread",
+			"transform-parameters",
+		},
+	})
+	if err != nil {
+		return fmt.Errorf("transform: %v", err)
+	}
+	_, err = io.Copy(os.Stdout, r)
+
+	return
+}
+
+func main() {
+	if err := Main(); err != nil {
+		log.Fatalf("%v",err)
+	}
+}