Socket
Socket
Sign inDemoInstall

@babel/preset-env

Package Overview
Dependencies
164
Maintainers
4
Versions
163
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/preset-env

A Babel preset for each environment.


Version published
Weekly downloads
25M
increased by2.47%
Maintainers
4
Install size
11.9 MB
Created
Weekly downloads
 

Package description

What is @babel/preset-env?

The @babel/preset-env package is a Babel 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 is done by using compatibility tables to determine which features need to be transformed or polyfilled. It helps in writing next-gen JavaScript code while ensuring backward compatibility.

What are @babel/preset-env's main functionalities?

Transforming ES2015+ syntax to be ES5 compatible

This code sample shows an ES6 arrow function, which @babel/preset-env can transform into a function expression compatible with ES5 environments.

const arrowFunction = () => console.log('Hello, World!');

Optional configuration for browser or Node.js environment targets

This JSON configuration for Babel specifies which browsers should be supported by the output code, allowing @babel/preset-env to tailor the transformations and polyfills to only what is necessary for those environments.

{
  "presets": [
    ["@babel/preset-env", {
      "targets": {
        "browsers": ["last 2 versions", "> 1%", "ie >= 11"]
      }
    }]
  ]
}

Polyfilling missing features based on the target environment

This code sample uses `Array.from` and `Set`, which may not be available in older environments. @babel/preset-env can include the necessary polyfills for these features when configured with `useBuiltIns: 'usage'`.

Array.from(new Set([1, 2, 3]));

Other packages similar to @babel/preset-env

Changelog

Source

v7.20.2 (2022-11-04)

:bug: Bug Fix
  • babel-core, babel-helper-create-class-features-plugin, babel-helper-module-transforms, babel-helper-plugin-utils, babel-helper-simple-access, babel-node, babel-plugin-transform-block-scoping, babel-plugin-transform-classes, babel-plugin-transform-react-constant-elements, babel-preset-env, babel-standalone, babel-types
    • #15124 fix: @babel/node repl and enable no-use-before-define rule (@liuxingbaoyu)
  • babel-plugin-transform-typescript
    • #15121 fix: tsSatisfiesExpression check with different duplicated @babel/types versions (@liuxingbaoyu)
  • babel-parser
  • babel-generator
  • babel-plugin-proposal-decorators, babel-plugin-proposal-object-rest-spread, babel-plugin-transform-jscript
    • #15113 fix: wrap anonymous class expression within statement (@JLHwung)
  • babel-plugin-transform-destructuring

Readme

Source

@babel/preset-env

A Babel preset for each environment.

See our website @babel/preset-env for more information or the issues associated with this package.

Install

Using npm:

npm install --save-dev @babel/preset-env

or using yarn:

yarn add @babel/preset-env --dev

FAQs

Last updated on 04 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc