How to use the @babel/standalone.registerPlugin 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 alangpierce / sucrase / website / src / Babel.ts View on Github external
/**
 * Single file expressing all Babel dependencies and applying all plugins so that they will be
 * in a single webpack chunk.
 */
// @ts-ignore
import {registerPlugin, transform} from "@babel/standalone";

// @ts-ignore
import NumericSeparatorPlugin from "@babel/plugin-proposal-numeric-separator";
// @ts-ignore
import DynamicImportPlugin from "babel-plugin-dynamic-import-node";
// @ts-ignore
import ReactHotLoaderPlugin from "react-hot-loader/dist/babel.development";

registerPlugin("proposal-numeric-separator", NumericSeparatorPlugin);
registerPlugin("dynamic-import-node", DynamicImportPlugin);
registerPlugin("react-hot-loader", ReactHotLoaderPlugin);

export {transform};
github zerobias / effector / website / editor / src / evaluator / compiler.js View on Github external
// import PresetReact from '@babel/preset-react'
//$todo
// import PresetFlow from '@babel/preset-flow'
//$todo
// import PluginStrictMode from '@babel/plugin-transform-strict-mode'
//$todo
// import PluginClassProps from '@babel/plugin-proposal-class-properties'
//$todo
// import PluginNullish from '@babel/plugin-proposal-nullish-coalescing-operator'
//$todo
// import PluginOptional from '@babel/plugin-proposal-optional-chaining'
//$todo
import {transform, registerPlugin, registerPreset} from '@babel/standalone'
import {babelOptions} from './domain'

registerPlugin('syntax-bigint', PluginBigInt)

// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)

// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
//   '@babel/plugin-proposal-nullish-coalescing-operator',
//   PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)

registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
  visitor: {
github zerobias / effector / website / editor / src / evaluator / compiler.js View on Github external
import {babelOptions} from './domain'

registerPlugin('syntax-bigint', PluginBigInt)

// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)

// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
//   '@babel/plugin-proposal-nullish-coalescing-operator',
//   PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)

registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
  visitor: {
    ImportDeclaration(path) {
      path.remove()
    },
    ExportDefaultDeclaration(path) {
      path.remove()
    },
    ExportNamedDeclaration(path) {
      if (babel.types.isVariableDeclaration(path.node.declaration)) {
        path.replaceWith(path.node.declaration)
      } else {
        path.remove()
      }
    },
github zerobias / effector / website / editor / src / evaluator / compiler.js View on Github external
registerPlugin('syntax-bigint', PluginBigInt)

// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)

// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
//   '@babel/plugin-proposal-nullish-coalescing-operator',
//   PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)

registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
  visitor: {
    ImportDeclaration(path) {
      path.remove()
    },
    ExportDefaultDeclaration(path) {
      path.remove()
    },
    ExportNamedDeclaration(path) {
      if (babel.types.isVariableDeclaration(path.node.declaration)) {
        path.replaceWith(path.node.declaration)
      } else {
        path.remove()
      }
    },
  },
}))
github zerobias / effector / website / editor / src / evaluator / compiler.js View on Github external
registerPlugin('syntax-bigint', PluginBigInt)

// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)

// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
//   '@babel/plugin-proposal-nullish-coalescing-operator',
//   PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)

registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
  visitor: {
    ImportDeclaration(path) {
      path.remove()
    },
    ExportDefaultDeclaration(path) {
      path.remove()
    },
    ExportNamedDeclaration(path) {
      if (babel.types.isVariableDeclaration(path.node.declaration)) {
        path.replaceWith(path.node.declaration)
      } else {
        path.remove()
      }
    },
  },
github freeCodeCamp / freeCodeCamp / client / src / templates / Challenges / rechallenge / transformers.js View on Github external
const loopsPerTimeoutCheck = 2000;

function loopProtectCB(line) {
  console.log(
    `Potential infinite loop detected on line ${line}. Tests may fail if this is not changed.`
  );
}

function testLoopProtectCB(line) {
  console.log(
    `Potential infinite loop detected on line ${line}. Tests may be failing because of this.`
  );
}

Babel.registerPlugin('loopProtection', protect(protectTimeout, loopProtectCB));
Babel.registerPlugin(
  'testLoopProtection',
  protect(testProtectTimeout, testLoopProtectCB, loopsPerTimeoutCheck)
);

const babelOptionsJSX = {
  plugins: ['loopProtection'],
  presets: [presetEnv, presetReact]
};

const babelOptionsJS = {
  plugins: ['testLoopProtection'],
  presets: [presetEnv]
};

const babelOptionsJSPreview = {
  ...babelOptionsJS,
github neo-one-suite / neo-one / packages / neo-one-editor / src / engine / main / transpile / transpile.ts View on Github external
const initialize = () => {
  if (initialized) {
    return;
  }
  initialized = true;

  Babel.registerPreset('@babel/preset-react', babelPresetReact);
  Babel.registerPlugin('@babel/plugin-proposal-class-properties', babelPluginProposalClassProperties);
  Babel.registerPlugin('@babel/plugin-proposal-object-rest-spread', babelPluginProposalObjectRestSprerad);
  Babel.registerPlugin('@babel/plugin-proposal-optional-catch-binding', babelPluginProposalOptionalCatchBinding);
  Babel.registerPlugin('@babel/plugin-proposal-async-generator-functions', babelPluginProposalAsyncGeneratorFunctions);
  Babel.registerPlugin('@babel/plugin-proposal-numeric-separator', babelPluginProposalNumericSeparator);
  Babel.registerPlugin('@babel/plugin-transform-typescript', babelPluginTransformTypeScript);
  Babel.registerPlugin('@babel/plugin-transform-modules-commonjs', babelPluginTransformModulesCommonJS);
};
github neo-one-suite / neo-one / packages / neo-one-editor / src / engine / main / transpile / transpile.ts View on Github external
const initialize = () => {
  if (initialized) {
    return;
  }
  initialized = true;

  Babel.registerPreset('@babel/preset-react', babelPresetReact);
  Babel.registerPlugin('@babel/plugin-proposal-class-properties', babelPluginProposalClassProperties);
  Babel.registerPlugin('@babel/plugin-proposal-object-rest-spread', babelPluginProposalObjectRestSprerad);
  Babel.registerPlugin('@babel/plugin-proposal-optional-catch-binding', babelPluginProposalOptionalCatchBinding);
  Babel.registerPlugin('@babel/plugin-proposal-async-generator-functions', babelPluginProposalAsyncGeneratorFunctions);
  Babel.registerPlugin('@babel/plugin-proposal-numeric-separator', babelPluginProposalNumericSeparator);
  Babel.registerPlugin('@babel/plugin-transform-typescript', babelPluginTransformTypeScript);
  Babel.registerPlugin('@babel/plugin-transform-modules-commonjs', babelPluginTransformModulesCommonJS);
};
github kirjavascript / nibblrjr / irc / context / loop-protect.js View on Github external
const babel = require('@babel/standalone');
const protect = require('loop-protect');

babel.registerPlugin('loopProtection', protect(100));

function transform(source) {
    try {
        return babel.transform(source, {
            plugins: [
                'loopProtection',
            ],
        }).code
    } catch (e) {
        return source;
    }
}

module.exports = {
    loopProtect: transform,
};
github neo-one-suite / neo-one / packages / neo-one-editor / src / engine / main / transpile / transpile.ts View on Github external
const initialize = () => {
  if (initialized) {
    return;
  }
  initialized = true;

  Babel.registerPreset('@babel/preset-react', babelPresetReact);
  Babel.registerPlugin('@babel/plugin-proposal-class-properties', babelPluginProposalClassProperties);
  Babel.registerPlugin('@babel/plugin-proposal-object-rest-spread', babelPluginProposalObjectRestSprerad);
  Babel.registerPlugin('@babel/plugin-proposal-optional-catch-binding', babelPluginProposalOptionalCatchBinding);
  Babel.registerPlugin('@babel/plugin-proposal-async-generator-functions', babelPluginProposalAsyncGeneratorFunctions);
  Babel.registerPlugin('@babel/plugin-proposal-numeric-separator', babelPluginProposalNumericSeparator);
  Babel.registerPlugin('@babel/plugin-transform-typescript', babelPluginTransformTypeScript);
  Babel.registerPlugin('@babel/plugin-transform-modules-commonjs', babelPluginTransformModulesCommonJS);
};