How to use @babel/plugin-proposal-nullish-coalescing-operator - 6 common examples

To help you get started, we’ve selected a few @babel/plugin-proposal-nullish-coalescing-operator 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 facebook / metro / packages / metro-babel-register / src / babel-register.js View on Github external
*/

'use strict';

const escapeRegExp = require('escape-string-regexp');
const path = require('path');
require('./node-polyfills');

var _only = [];

const PLUGINS = [
  [require('@babel/plugin-transform-flow-strip-types').default],
  [require('@babel/plugin-proposal-object-rest-spread').default],
  [require('@babel/plugin-proposal-class-properties').default],
  [require('@babel/plugin-transform-modules-commonjs').default],
  [require('@babel/plugin-proposal-nullish-coalescing-operator').default],
  [require('@babel/plugin-proposal-optional-catch-binding').default],
  [require('@babel/plugin-proposal-optional-chaining').default],
];

if (/^v[0-7]\./.test(process.version)) {
  PLUGINS.push([require('@babel/plugin-transform-async-to-generator').default]);
}

function registerOnly(onlyList) {
  // This prevents `babel-register` from transforming the code of the
  // plugins/presets that we are require-ing themselves before setting up the
  // actual config.
  require('@babel/register')({only: [], babelrc: false, configFile: false});
  require('@babel/register')(config(onlyList));
}
github facebook / metro / packages / metro-babel-register / src / babel-register.js View on Github external
* @format
 */
'use strict';

const escapeRegExp = require('escape-string-regexp');
const path = require('path');
require('./node-polyfills');

var _only = [];

const PLUGINS = [
  [require('@babel/plugin-transform-flow-strip-types').default],
  [require('@babel/plugin-proposal-object-rest-spread').default],
  [require('@babel/plugin-proposal-class-properties').default],
  [require('@babel/plugin-transform-modules-commonjs').default],
  [require('@babel/plugin-proposal-nullish-coalescing-operator').default],
  [require('@babel/plugin-proposal-optional-catch-binding').default],
  [require('@babel/plugin-proposal-optional-chaining').default],
];

if (/^v[0-7]\./.test(process.version)) {
  PLUGINS.push([require('@babel/plugin-transform-async-to-generator').default]);
}

function registerOnly(onlyList) {
  // This prevents `babel-register` from transforming the code of the
  // plugins/presets that we are require-ing themselves before setting up the
  // actual config.
  require('@babel/register')({only: [], babelrc: false});
  require('@babel/register')(config(onlyList));
}
github SUI-Components / sui / packages / babel-preset-sui / src / index.js View on Github external
function plugins(api, opts = {}) {
  return cleanList([
    require('@babel/plugin-syntax-dynamic-import').default,
    require('@babel/plugin-syntax-export-default-from').default,
    require('@babel/plugin-syntax-export-namespace-from').default,
    require('@babel/plugin-proposal-optional-chaining').default,
    require('@babel/plugin-proposal-nullish-coalescing-operator').default,
    [require('@babel/plugin-proposal-decorators').default, {legacy: true}],
    [require('@babel/plugin-proposal-class-properties').default, {loose: true}],
    [
      require('babel-plugin-transform-react-remove-prop-types').default,
      {
        wrap: true
      }
    ],
    [
      require('@babel/plugin-proposal-object-rest-spread').default,
      {useBuiltIns: true} // asume Object.assign is available by browser or polyfill
    ],
    [
      require('@babel/plugin-transform-runtime').default,
      {
        corejs: false,
github electron-userland / electron-builder / packages / app-builder-lib / src / ProtonFramework.ts View on Github external
function testOnlyBabel(babel: any, babelOptions: any, nodeVersion: string) {
  // out test dir can be located outside of electron-builder node_modules and babel cannot resolve string names of preset
  babelOptions.presets = [
    [require("@babel/preset-env").default, {targets: {node: nodeVersion}}],
    require("@babel/preset-react"),
  ]
  babelOptions.plugins = [
    // stage 0
    require("@babel/plugin-proposal-function-bind").default,

    // stage 1
    require("@babel/plugin-proposal-export-default-from").default,
    require("@babel/plugin-proposal-logical-assignment-operators").default,
    [require("@babel/plugin-proposal-optional-chaining").default, {loose: false}],
    [require("@babel/plugin-proposal-pipeline-operator").default, {proposal: "minimal"}],
    [require("@babel/plugin-proposal-nullish-coalescing-operator").default, {loose: false}],
    require("@babel/plugin-proposal-do-expressions").default,

    // stage 2
    [require("@babel/plugin-proposal-decorators").default, {legacy: true}],
    require("@babel/plugin-proposal-function-sent").default,
    require("@babel/plugin-proposal-export-namespace-from").default,
    require("@babel/plugin-proposal-numeric-separator").default,
    require("@babel/plugin-proposal-throw-expressions").default,

    // stage 3
    require("@babel/plugin-syntax-dynamic-import").default,
    require("@babel/plugin-syntax-import-meta").default,
    [require("@babel/plugin-proposal-class-properties").default, {loose: false}],
    require("@babel/plugin-proposal-json-strings").default,
  ]
  babelOptions.babelrc = false
github facebook / create-react-app / packages / babel-preset-react-app / create.js View on Github external
absoluteRuntime: absoluteRuntimePath,
        },
      ],
      isEnvProduction && [
        // Remove PropTypes from production build
        require('babel-plugin-transform-react-remove-prop-types').default,
        {
          removeImport: true,
        },
      ],
      // Adds syntax support for import()
      require('@babel/plugin-syntax-dynamic-import').default,
      // Adds syntax support for optional chaining (?.)
      require('@babel/plugin-proposal-optional-chaining').default,
      // Adds syntax support for default value using ?? operator
      require('@babel/plugin-proposal-nullish-coalescing-operator').default,
      isEnvTest &&
        // Transform dynamic import to require
        require('babel-plugin-dynamic-import-node'),
    ].filter(Boolean),
    overrides: [
      isFlowEnabled && {
        exclude: /\.tsx?$/,
        plugins: [require('@babel/plugin-transform-flow-strip-types').default],
      },
      isTypeScriptEnabled && {
        test: /\.tsx?$/,
        plugins: [
          [
            require('@babel/plugin-proposal-decorators').default,
            { legacy: true },
          ],
github christophehurpeau / babel-preset-modern-browsers / lib / index.js View on Github external
: require('@babel/plugin-syntax-async-generators'),

      es2019 &&
        (edge
          ? require('@babel/plugin-proposal-optional-catch-binding')
          : require('@babel/plugin-syntax-optional-catch-binding')),

      /* shippedProposals */
      shippedProposals &&
        (edge
          ? require('@babel/plugin-proposal-json-strings')
          : require('@babel/plugin-syntax-json-strings')),
      shippedProposals &&
        require('@babel/plugin-proposal-optional-chaining').default,
      shippedProposals &&
        require('@babel/plugin-proposal-nullish-coalescing-operator').default,
    ].filter(Boolean),
  };
};

@babel/plugin-proposal-nullish-coalescing-operator

Remove nullish coalescing operator

MIT
Latest version published 2 years ago

Package Health Score

72 / 100
Full package analysis

Popular @babel/plugin-proposal-nullish-coalescing-operator functions