Vue Babel Preset Env

Posted on  by admin

Modified3 years, 1 month ago. Attempting to create a new vue project. Right out of the gate I'm getting an error that I cannot resolve:. In the auto-generated package.json (below) @babel/preset-env isn't listed as a dev dependency, but I assume it gets added automatically as a dependency of some of the vue stuff?


Browserslist Integration

Any idea what is going on? Here are auto-generated files:. 22 gold badges1515 silver badges2626 bronze badges. 2626 bronze badges. Latest ECMAScript features (babel-preset-env).

  • modules: false
    • Object rest spread and dynamic import. Transform Vue JSX.
  • Transform generator and async/await. Type: booleanDefault: false. Disable runtime transform. do not add helpers and polyfill for unsupported features of target environment, eg: Object.assign, Promise. As we're using babel-plugin-transform-runtime to polyfill your code without polluting globals, something like "foobar".includes("foo") will not work since that would require modification of existing builtins.
  • Commit your changes: git commit -am 'Add some feature'. Push to the branch: git push origin my-new-feature. Submit a pull request :D.


latest (4 years ago) . @babel/preset-env is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills) are needed by your target environment(s).

This both makes your life easier and JavaScript bundles smaller! @babel/preset-env would not be possible if not for a number of awesome open-source projects, like browserslist, compat-table, and electron-to-chromium.


Browse other questions tagged vue.jsbabeljs or ask your own question.

We leverage these data sources to maintain mappings of which version of our supported target environments gained support of a JavaScript syntax or browser feature, as well as a mapping of those syntaxes and features to Babel transform plugins and core-js polyfills.


  • Note: @babel/preset-env won't include any JavaScript syntax proposals less than Stage 3 because at that stage in the TC39 process, it wouldn't be implemented by any browsers anyway.

15 Versions

  • Those would need to be included manually. The shippedProposals option will include Stage 3 proposals that some browsers have already implemented.

You may already have this configuration file as it is used by many tools in the ecosystem, like autoprefixer, stylelint, eslint-plugin-compat and many others.


  • By default @babel/preset-env will use browserslist config sourcesunless either the targets or ignoreBrowserslistConfig options are set. Please note that if you are relying on browserslist's defaults query (either explicitly or by having no browserslist config), you will want to check out the No targets section for information on preset-env's behavior.

string | Array | { [string]: string }, defaults to the top-level targets option if no browserslist-related option is specified in @babel/preset-env's docs, otherwise to {}.

Current Tags

  • For usage, refer to the targets option documentation.
  • boolean, defaults to false. Added in: v7.9.0. Note: These optimizations will be enabled by default in Babel 8.

By default, @babel/preset-env (and Babel plugins in general) grouped ECMAScript syntax features into collections of closely related smaller features.

These groups can be large and include a lot of edge cases, for example "function arguments" includes destructured, default and rest parameters. From this grouping information, Babel enables or disables each group based on the browser support target you specify to @babel/preset-env’s targets option.

When this option is enabled, @babel/preset-env tries to compile the broken syntax to the closest non-broken modern syntax supported by your target browsers.

Depending on your targets and on how many modern syntax you are using, this can lead to a significant size reduction in the compiled app. This option merges the features of @babel/preset-modules without having to use another preset.

  1. boolean, defaults to false. Enable more spec compliant, but potentially slower, transformations for any plugins in this preset that support them. boolean, defaults to false. Enable "loose" transformations for any plugins in this preset that allow them.

  2. ⚠️ Consider migrating to the top level assumptions available since Babel 7.13. "amd" | "umd" | "systemjs" | "commonjs" | "cjs" | "auto" | false, defaults to "auto".

  3. Enable transformation of ES module syntax to another module type. Note that cjs is just an alias for commonjs. Setting this to false will preserve ES modules. Use this only if you intend to ship native ES Modules to browsers. If you are using a bundler with Babel, the default modules: "auto" is always preferred. By default @babel/preset-env uses caller data to determine whether ES modules and module features (e.g.

import()) should be transformed. Generally caller data will be specified in the bundler plugins (e.g.


  • babel-loader, @rollup/plugin-babel) and thus it is not recommended to pass caller data yourself -- The passed caller may overwrite the one from bundler plugins and in the future you may get suboptimal results if bundlers supports new module features.

boolean, defaults to false. Outputs to console.log the polyfills and transform plugins enabled by preset-env and, if applicable, which one of your targets that needed it.

Array, defaults to []. An array of plugins to always include. Valid options include any:. Babel plugins - both with (@babel/plugin-transform-spread) and without prefix (plugin-transform-spread) are supported.


Plugin names can be fully or partially specified (or using RegExp). Acceptable inputs:. Full name (string): "es.math.sign". Partial name (string): "es.math.*" (resolves to all plugins with es.math prefix).

How Does it Work?

  • RegExp Object: /^transform-.*$/ or new RegExp("^transform-modules-.*").

Note that the above . is the RegExp equivalent to match any character, and not the actual '.'


  • Also note that to match any character .* is used in RegExp as opposed to * in glob format.

This option is useful if there is a bug in a native implementation, or a combination of a non-supported feature + a supported one doesn't work.


  • For example, Node 4 supports native classes but not spread.
  • If super is used with a spread argument, then the @babel/plugin-transform-classes transform needs to be included, as it is not possible to transpile a spread with super otherwise.

Ineffective browserslist queries

  • NOTE: The include and exclude options only work with the plugins included with this preset; so, for example, including @babel/plugin-proposal-do-expressions or excluding @babel/plugin-proposal-function-bind will throw errors.
  • To use a plugin not included with this preset, add them to your "plugins" directly.
  • Array, defaults to [].
  • An array of plugins to always exclude/remove.
  • The possible options are the same as the include option.
  • This option is useful for "blacklisting" a transform like @babel/plugin-transform-regenerator if you don't use generators and don't want to include regeneratorRuntime (when using useBuiltIns) or for using another plugin like fast-async instead of Babel's async-to-gen.
  • "usage" | "entry" | false, defaults to false.
  • This option configures how @babel/preset-env handles polyfills.
  • When either the usage or entry options are used, @babel/preset-env will add direct references to core-js modules as bare imports (or requires).
  • This means core-js will be resolved relative to the file itself and needs to be accessible.
  • Since @babel/polyfill was deprecated in 7.4.0, we recommend directly adding core-js and setting the version via the corejs option.
  • NOTE: Only use import "core-js"; and import "regenerator-runtime/runtime"; once in your whole app.If you are using @babel/polyfill, it already includes both core-js and regenerator-runtime: importing it twice will throw an error.Multiple imports or requires of those packages might cause global collisions and other issues that are hard to trace.We recommend creating a single entry file that only contains the import statements.
  • This option enables a new plugin that replaces the import "core-js/stable"; and import "regenerator-runtime/runtime" statements (or require("core-js") and require("regenerator-runtime/runtime")) with individual requires to different core-js entry points based on environment.
  • Out (different based on environment).
  • Importing "core-js" loads polyfills for every possible ECMAScript feature: what if you know that you only need some of them?
  • When using [email protected], @babel/preset-env is able to optimize every single core-js entrypoint and their combinations.
  • For example, you might want to only polyfill array methods and new Math proposals:.
  • Out (different based on environment).
  • You can read core-js's documentation for more information about the different entry points.
  • NOTE: When using [email protected] (either explicitly using the corejs: "2" option or implicitly), @babel/preset-env will also transform imports and requires of @babel/polyfill.This behavior is deprecated because it isn't possible to use @babel/polyfill with different core-js versions.
  • Adds specific imports for polyfills when they are used in each file.
  • We take advantage of the fact that a bundler will load the same polyfill only once.
  • Out (if environment doesn't support it).
  • Out (if environment supports it).
  • Don't add polyfills automatically per file, and don't transform import "core-js" or import "@babel/polyfill" to individual polyfills.
  • Added in: v7.4.0.
  • string or { version: string, proposals: boolean }, defaults to "2.0".
  • The version string can be anysupported core-js versions.
  • For example, "3.8" or "2.0".
  • This option only has an effect when used alongside useBuiltIns: usage or useBuiltIns: entry, and ensures @babel/preset-env injects the polyfills supported by your core-js version.
  • It is recommended to specify the minorversion otherwise "3" will be interpreted as "3.0" which may not include polyfills for the latest features.
  • By default, only polyfills for stable ECMAScript features are injected: if you want to polyfill proposals, you have three different options:.
  • when using useBuiltIns: "entry", you can directly import a proposal polyfill: import "core-js/proposals/string-replace-all".
  • when using useBuiltIns: "usage" you have two different alternatives:set the shippedProposals option to true.
  • This will enable polyfills and transforms for proposal which have already been shipped in browsers for a while.use corejs: { version: "3.8", proposals: true }.
  • This will enable polyfilling of every proposal supported by [email protected]
  • set the shippedProposals option to true.
  • This will enable polyfills and transforms for proposal which have already been shipped in browsers for a while.
  • use corejs: { version: "3.8", proposals: true }.
  • This will enable polyfilling of every proposal supported by [email protected]
  • boolean, defaults to false.
  • With Babel 7's JavaScript config file support, you can force all transforms to be run if env is set to production.
  • NOTE: targets.uglify is deprecated and will be removed in the next major infavor of this.
  • By default, this preset will run all the transforms needed for the targetedenvironment(s).
  • Enable this option if you want to force running alltransforms, which is useful if the output will be run through UglifyJS or anenvironment that only supports ES5.
  • NOTE: If you require an alternative minifier which does support ES6 syntax,we recommend Terser.
  • string, defaults to process.cwd().
  • The starting point where the config search for browserslist will start, and ascend to the system root until found.
  • boolean, defaults to false.
  • Toggles whether or not browserslist config sources are used, which includes searching for any browserslist files or referencing the browserslist key inside package.json.
  • This is useful for projects that use a browserslist config for files that won't be compiled with Babel.
  • Added in: v7.10.0string, defaults to undefined.
  • The Browserslist environment to use.
  • boolean, defaults to false.
  • Toggles enabling support for builtin/feature proposals that have shipped in browsers.
  • If your target environments have native support for a feature proposal, its matching parser syntax plugin is enabled instead of performing any transform.
  • Note that this does not enable the same transformations as @babel/preset-stage-3, since proposals can continue to change before landing in browsers.
  • The following are currently supported:.
  • Builtins injected when using useBuiltIns: "usage".
  • (only supported by [email protected]).
  • esnext.string.match-all (only supported by [email protected]).
  • Import assertions (parsing only).
  • Materialized FeaturesThese features were behind shippedProposals flag in older Babel versions.
  • They are now generally available.
  • You can read more about configuring preset options here.
  • While op_mini all is a valid browserslist query, preset-env currently ignores it due to lack of support data for Opera Mini.
  • Vue.js babel.config.js与babelrc(同一目录中的Vue+;Express).
  • Vue.js babel.config.js与babelrc(同一目录中的Vue+;Express),vue.js,babeljs,babel-preset-env,babel-cli,Vue.js,Babeljs,Babel Preset Env,Babel Cli,您可以直接跳到本节的最后一部分,了解确切的问题?对于完整上下文,请从头开始阅读以下是我启动Vue项目的方式:vue create awesome-frontend选择所有默认值,并在根目录中找到包含以下内容的babel.config.js文件:module.exports = { presets: [ '@vue/cli-plugin-babel/preset' ]}import express from "express";const app = expres.
  • 4.0.0-rc.0... 3 years ago
  • 4.0.0-beta.3... 3 years ago
  • 3.10.0... 3 years ago
  • 4.0.0-beta.2... 3 years ago
  • 4.0.0-beta.1... 3 years ago
  • 4.0.0-beta.0... 3 years ago
  • 4.0.0-alpha.5... 3 years ago
  • 4.0.0-alpha.4... 3 years ago
  • 3.9.2... 3 years ago
  • 4.0.0-alpha.3... 3 years ago
  • 3.9.0... 3 years ago
  • 4.0.0-alpha.2... 3 years ago
  • 3.8.0... 3 years ago
  • 4.0.0-alpha.1... 3 years ago
  • 4.0.0-alpha.0... 3 years ago
  • 3.7.0... 3 years ago
  • 3.6.0... 3 years ago
  • 3.5.5... 3 years ago
  • 3.5.4... 3 years ago
  • 3.5.3... 3 years ago
  • 3.5.2... 3 years ago
  • 3.5.1... 3 years ago
  • 3.5.0... 3 years ago
  • 3.4.1... 3 years ago
  • 3.4.0... 3 years ago
  • 3.3.0... 3 years ago
  • 3.2.2... 3 years ago
  • 3.2.0... 3 years ago
  • 3.1.1... 4 years ago
  • 3.1.0... 4 years ago
  • 3.0.5... 4 years ago
  • 3.0.4... 4 years ago
  • 3.0.1... 4 years ago
  • 3.0.0... 4 years ago
  • 3.0.0-rc.12... 4 years ago
  • 3.0.0-rc.11... 4 years ago
  • 3.0.0-rc.10... 4 years ago
  • 3.0.0-rc.9... 4 years ago
  • 3.0.0-rc.8... 4 years ago
  • 3.0.0-rc.7... 4 years ago
  • 3.0.0-rc.6... 4 years ago
  • 3.0.0-rc.5... 4 years ago
  • 3.0.0-rc.4... 4 years ago
  • 3.0.0-rc.3... 4 years ago
  • 3.0.0-rc.2... 4 years ago
  • 3.0.0-rc.1... 4 years ago
  • 3.0.0-beta.16... 4 years ago
  • 3.0.0-beta.15... 4 years ago
  • 3.0.0-beta.14... 4 years ago
  • 3.0.0-beta.13... 4 years ago
  • 3.0.0-beta.12... 4 years ago
  • 3.0.0-beta.11... 4 years ago
  • 3.0.0-beta.10... 4 years ago
  • 3.0.0-beta.9... 4 years ago
  • 3.0.0-beta.8... 4 years ago
  • 3.0.0-beta.7... 4 years ago
  • 3.0.0-beta.6... 4 years ago
  • 3.0.0-beta.5... 4 years ago
  • 3.0.0-beta.4... 4 years ago
  • 3.0.0-beta.3... 4 years ago
  • 3.0.0-beta.2... 4 years ago
  • 3.0.0-beta.1... 4 years ago
  • 3.0.0-alpha.13... 4 years ago
  • 3.0.0-alpha.12... 4 years ago
  • 3.0.0-alpha.11... 4 years ago
  • 3.0.0-alpha.10... 4 years ago
  • 3.0.0-alpha.9... 4 years ago
  • 3.0.0-alpha.8... 4 years ago
  • 3.0.0-alpha.7... 4 years ago
  • 3.0.0-alpha.6... 4 years ago
  • 3.0.0-alpha.5... 4 years ago
  • 3.0.0-alpha.4... 4 years ago
  • 3.0.0-alpha.3... 4 years ago
  • 3.0.0-alpha.2... 4 years ago
  • 3.0.0-alpha.1... 4 years ago
  • 5.0.0-rc.2... 4 months ago
  • 5.0.0-rc.3... 3 months ago
  • 5.0.0... 3 months ago
  • 5.0.1... 3 months ago
  • 5.0.2... 2 months ago
  • 5.0.3... 2 months ago
  • 4.5.16... 2 months ago
  • 5.0.4... 2 months ago
  • 4.5.17... 2 months ago