Browse Source

Update babel and defconf, use es5-shim

master v0.12.0
Tyler Sommer 4 months ago
parent
commit
214e01504f
Signed by: tyler-sommer
GPG Key ID: C09C010500DBD008
  1. 6
      cmd/squircy/defconf/config.toml
  2. 20
      cmd/squircy/defconf/package.json
  3. 20
      package.json
  4. 20
      plugins/babel/transformer/babel.go
  5. 1
      plugins/node_compat/plugin.go
  6. 16
      testdata/package.json

6
cmd/squircy/defconf/config.toml

@ -4,6 +4,7 @@ extra_plugins=[
"node_compat.so",
"squircy2_compat.so",
"script.so",
"discord.so",
]
[irc]
@ -34,3 +35,8 @@ data_path="data"
[node_compat]
enable_exec=false
[discord]
token=""
#owner=""
#activity=""

20
cmd/squircy/defconf/package.json

@ -1,16 +1,16 @@
{
"private": true,
"dependencies": {
"@babel/standalone": "7.5.5",
"assert": "2.0.0",
"assert-polyfill": "0.0.0",
"buffer": "5.2.1",
"core-js-bundle": "3.1.4",
"@babel/standalone": "^7.16.11",
"assert": "^2.0.0",
"assert-polyfill": "^0.0.0",
"buffer": "^6.0.0",
"core-js-bundle": "^3.1.4",
"es5-shim": "^4.6.5",
"error-polyfill": "0.1.2",
"process": "0.11.10",
"regenerator-runtime": "0.13.3",
"regenerator-transform": "0.14.1"
},
"resolutions": {
"util": "0.12.1"
"readable-stream": "3.6.0",
"regenerator-runtime": "^0.13.3",
"regenerator-transform": "^0.14.1"
}
}

20
package.json

@ -4,16 +4,14 @@
"license": "MIT",
"private": true,
"dependencies": {
"@babel/standalone": "7.5.5",
"assert": "2.0.0",
"assert-polyfill": "0.0.0",
"buffer": "5.2.1",
"core-js-bundle": "3.1.4",
"process": "0.11.10",
"regenerator-runtime": "0.13.3",
"regenerator-transform": "0.14.1"
},
"resolutions": {
"util": "0.12.1"
"@babel/standalone": "^7.16.11",
"assert": "^2.0.0",
"assert-polyfill": "^0.0.0",
"buffer": "^6.0.0",
"core-js-bundle": "^3.1.4",
"es5-shim": "^4.6.5",
"process": "^0.11.10",
"regenerator-runtime": "^0.13.3",
"regenerator-transform": "^0.14.1"
}
}

20
plugins/babel/transformer/babel.go

@ -16,27 +16,11 @@ func New(r *goja.Runtime) (*Babel, error) {
v, err := b.runtime.RunString(`
this.global = this.global || this;
this.process = this.process || require('process/browser');
// core-js does not set this up correctly, so we do it explicitly here
Object.setPrototypeOf = function(O, proto) {
if(! (O instanceof Object)) {
throw new TypeError("Expected object");
}
if(proto !== null && ! (proto instanceof Object)) {
throw new TypeError("Expected prototype to be object or null");
}
O.__proto__ = proto;
return O;
};
Object.getPrototypeOf = function(O) {
if(! (O instanceof Object)) {
throw new TypeError("Expected object");
}
return O.__proto__;
}
require('es5-shim');
require('core-js-bundle');
this.Babel = require('@babel/standalone');
var plugin = require('regenerator-transform');
(function(src) {
(function(src) {
var res = Babel.transform(src, {presets: ['es2015','es2016','es2017'], plugins: [plugin]});
return res.code;
})`)

1
plugins/node_compat/plugin.go

@ -71,7 +71,6 @@ func (p *nodeCompatPlugin) HandleRuntimeInit(r *goja.Runtime) {
}
_, err := r.RunString(`this.global = this.global || this;
require('core-js-bundle');
this.process = this.process || require('process/browser');
require('regenerator-runtime');`)
if err != nil {

16
testdata/package.json vendored

@ -1,18 +1,16 @@
{
"private": true,
"dependencies": {
"@babel/standalone": "7.5.5",
"assert": "2.0.0",
"@babel/standalone": "^7.16.11",
"assert": "^2.0.0",
"assert-polyfill": "^0.0.0",
"buffer": "5.2.1",
"core-js-bundle": "3.1.4",
"buffer": "^6.0.0",
"core-js-bundle": "^3.1.4",
"es5-shim": "^4.6.5",
"error-polyfill": "0.1.2",
"process": "0.11.10",
"readable-stream": "3.6.0",
"regenerator-runtime": "0.13.3",
"regenerator-transform": "0.14.1"
},
"resolutions": {
"util": "0.12.1"
"regenerator-runtime": "^0.13.3",
"regenerator-transform": "^0.14.1"
}
}

Loading…
Cancel
Save