Last active
December 1, 2022 10:28
-
-
Save devversion/dec0dea26e348c509921bf62079b60be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const babel = require('@babel/core'); | |
const reproduce = true; | |
const res = babel.transformSync( | |
` | |
const variableNeeded = true; | |
class X { | |
x = true; | |
constructor() { | |
console.log("Constructed"); | |
} | |
someMethod() { | |
console.log("Some method"); | |
} | |
static b = true; | |
static { | |
this.a = true; | |
} | |
} | |
const el = document.createElement('span'); | |
el.innerText = 'Hello'; | |
document.body.appendChild(el); | |
`, | |
{ | |
plugins: [['@babel/plugin-proposal-class-properties', {}]], | |
presets: [ | |
[ | |
require('@babel/preset-env').default, | |
{ | |
bugfixes: true, | |
modules: false, | |
targets: [ | |
'last 1 Chrome version', | |
'last 1 Firefox version', | |
'last 2 Edge major versions', | |
...(reproduce ? ['last 2 Safari major versions'] : []), | |
...(reproduce ? ['last 2 iOS major versions'] : []), | |
'Firefox ESR', | |
], | |
exclude: ['transform-typeof-symbol'], | |
}, | |
], | |
], | |
} | |
); | |
console.error(res.code); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment