Skip to content

Instantly share code, notes, and snippets.

@devversion
Last active December 1, 2022 10:28
Show Gist options
  • Save devversion/dec0dea26e348c509921bf62079b60be to your computer and use it in GitHub Desktop.
Save devversion/dec0dea26e348c509921bf62079b60be to your computer and use it in GitHub Desktop.
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy