How to use the @babel/standalone.transform function in @babel/standalone

To help you get started, we’ve selected a few @babel/standalone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blocks / blocks / packages / blocks-ui / src / queries.js View on Github external
export const getBlocksUsage = code => {
  try {
    const plugin = new BabelPluginGetBlocksUsage()

    transform(code, {
      plugins: [babelPluginSyntaxJsx, plugin.plugin]
    })

    return plugin.state.usage
  } catch (e) {
    console.log(e)
  }
}
github SUI-Components / sui / packages / sui-studio / src / components / preview / index.js View on Github external
const getCompiledCode = ({code, scope}) => {
  const codeToCompile = `
    (function (${Object.keys(scope).join(', ')}, mountNode) {
      ${code}
    });`

  return transform(codeToCompile, TRANSFORM_PRESETS).code
}
github aceHubert / material-ui-slider / libs / markdown / canvas.jsx View on Github external
}).then(({args, argv}) => {
      const code = transform(`
        class Demo extends React.Component {
          ${value}
        }

        ReactDOM.render(, document.getElementById('${this.playerId}'))
      `, {
        presets: ['es2015', 'react']
      }).code

      args.push(code)

      const Fn = Function
      new Fn(...args).apply(this, argv)

      this.source[2] = value
    }).catch((err) => {
github jdf2e / yep-react / demo / Demo.jsx View on Github external
renderSource(code) {
    let finalCode = code.replace('mountNode', `document.getElementById("demo-${this.props.demo.order}")`);
    finalCode = finalCode.replace(/import[^;]+?;/g, '');
    const transformedCode = transform(finalCode, {
      presets: ['es2015', 'react'],
      plugins: ['proposal-class-properties', 'proposal-object-rest-spread'],
    }).code;

    const args = ['context', 'React', 'ReactDOM', 'PropTypes', 'jsonp', 'ComponentCard'];
    const argv = [this, React, ReactDOM, PropTypes, jsonp, ComponentCard];

    Object.keys(Components).forEach(name => {
      args.push(name);
      argv.push(Components[name]);
    });

    args.push(transformedCode);

    ReactDOM.unmountComponentAtNode(document.getElementById(`demo-${this.props.demo.order}`));
github bootstrap-vue / bootstrap-vue / docs / utils / compile-js.js View on Github external
export default function compileJs(code) {
  if (!code) {
    return ''
  }
  return transform(code, transformOptions).code || ''
}
github chrismaltby / gb-studio / src / lib / plugins / plugins.js View on Github external
const compiler = code =>
  babel.transform(code, {
    plugins: [importExportPlugin, jsxPlugin]
  }).code;
github freeCodeCamp / freeCodeCamp / client / src / templates / Challenges / rechallenge / transformers.js View on Github external
const babelTransformCode = options => code =>
  Babel.transform(code, options).code;