How to use @babel/plugin-syntax-import-meta - 3 common examples

To help you get started, we’ve selected a few @babel/plugin-syntax-import-meta 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 github / babel-preset-github / index.js View on Github external
module.exports = function babelPresetGitHub(api, { useBuiltIns = false, env = true, modules = false, targets = {} }) {
  targets = Object.assign({}, { browsers: defaultBrowsers }, targets)
  if (targets.browsers === 'mobile') targets.browsers = mobileBrowsers
  if (targets.browsers === 'default') targets.browsers = defaultBrowsers
  const presets = []
  const plugins = [
    // ES2019
    // Stage 3 with good signals for Stage 4
    // Chrome 64+, Firefox 62+, Safari TP42, Opera 51+
    require('@babel/plugin-syntax-import-meta').default,
    // Chrome 63+, Firefox (https://mzl.la/2LMSnOf), Safari TP25, Opera 50+
    require('@babel/plugin-syntax-dynamic-import').default,
    // Non-standard
    require('@babel/plugin-transform-flow-strip-types').default,
    // Custom 
    require('babel-plugin-transform-invariant-location'),
  ]
  const fullBrowsers = browserslist(targets.browsers)
  const needsRestSpread = browserslist(['Edge > 0', 'Safari < 11.1']).some(browser => fullBrowsers.includes(browser))
  if (env) {
    presets.push([require('@babel/preset-env').default, { modules, targets, useBuiltIns: useBuiltIns ? 'entry' : false }])
  } else if (needsRestSpread) {
    plugins.push([require('@babel/plugin-proposal-object-rest-spread'), { useBuiltIns }])
  }
  return { plugins, presets };
};
github wearereasonablepeople / webpacker / loaders / utils.js View on Github external
const jsFeatures = () => [
  // old Stage 1
  require('@babel/plugin-proposal-export-default-from').default,

  // old Stage 2
  [require('@babel/plugin-proposal-decorators').default, {legacy: true}],

  // old 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,
];
github electron-userland / electron-builder / packages / app-builder-lib / src / ProtonFramework.ts View on Github external
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
  return babel
}

@babel/plugin-syntax-import-meta

Allow parsing of import.meta

MIT
Latest version published 4 years ago

Package Health Score

88 / 100
Full package analysis

Popular @babel/plugin-syntax-import-meta functions