How to use the @babel/standalone/babel.js.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 EffectNode / EffectNode-GUI / src / components / parts / EffectNode / ExecEnv / babel.worker.js View on Github external
// text
        let css = JSON.stringify(src)
        let code = `
          var css = ${css};
          var head = document.head || document.getElementsByTagName('head')[0];
          var style = document.createElement('style');
          style.type = 'text/css';
          if (style.styleSheet) {
            style.styleSheet.cssText = css;
          } else {
            style.appendChild(document.createTextNode(css));
          }
          head.appendChild(style);
        `

        output = Babel.transform(code + `export default ` + css, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
        setTimeout(() => {
          resolve({ output })
        }, 10)
      } else if (path.split('.').pop() === 'vue') {
        // vue file

        let info = VueCompo.getCompoInfo(src)
        var scopeID = 'data-s-' + (Math.ceil(Math.random() * 100000)).toString(36)
        let css = JSON.stringify(info.style)
        info.template = info.template.replace('>', `${scopeID}>`)

        /* eslint-disable */

        let code = `
          var css = ${css};
          var head = document.head || document.getElementsByTagName('head')[0];
github EffectNode / EffectNode-GUI / src / components / parts / EffectNode / ExecEnv / babel.worker.js View on Github external
return new Promise((resolve, reject) => {
    var output

    try {
      if (path.split('.').pop() === 'js') {
        // js
        output = Babel.transform(src, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
        setTimeout(() => {
          resolve({ output })
        }, 10)
      } else if (path.split('.').pop() === 'json') {
        // json
        output = Babel.transform(`export default ${JSON.stringify(JSON.parse(src))};`, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
        setTimeout(() => {
          resolve({ output })
        }, 10)
      } else if (path.split('.').pop() === 'html') {
        // dont include html in the js file
        output = ''
        setTimeout(() => {
          resolve({ output })
        }, 10)
      } else if (path.split('.').pop() === 'css') {
        // text
        let css = JSON.stringify(src)
        let code = `
          var css = ${css};
          var head = document.head || document.getElementsByTagName('head')[0];
          var style = document.createElement('style');
github EffectNode / EffectNode-GUI / src / components / parts / EffectNode / ExecEnv / babel.worker.js View on Github external
return new Promise((resolve, reject) => {
    var output

    try {
      if (path.split('.').pop() === 'js') {
        // js
        output = Babel.transform(src, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
        setTimeout(() => {
          resolve({ output })
        }, 10)
      } else if (path.split('.').pop() === 'json') {
        // json
        output = Babel.transform(`export default ${JSON.stringify(JSON.parse(src))};`, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
        setTimeout(() => {
          resolve({ output })
        }, 10)
      } else if (path.split('.').pop() === 'html') {
        // dont include html in the js file
        output = ''
        setTimeout(() => {
          resolve({ output })
        }, 10)
      } else if (path.split('.').pop() === 'css') {