Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

babel-preset-es2015-maybe-webpack

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-preset-es2015-maybe-webpack

An es2015 preset that can dynamically exclude the ES6 module plugin based on env.

latest
Source
npmnpm
Version
1.3.1
Version published
Weekly downloads
4
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

babel-preset-es2015-maybe-webpack

Using Webpack2 with Babel is difficult. Webpack >= 2 understands ES6 import/export natively, so you don't want to use the full babel-preset-es2015. You want to have all of your babel options in your .babelrc, but there is no good way to override a single preset in babel-loader while keeping the rest of your .babelrc intact, including envs.

This preset is for you if you've already tried to parse your .babelrc yourself (hint, use json5).

How it Works

Add the following to the top of your webpack config:

process.env.WEBPACK_VERSION = require('webpack/package.json').version;

If this preset detects that Webpack >= 2 is being used, it will exclude transform-es2015-modules-commonjs.

Install

Install both this preset, and the core 'babel-preset-es2015' that it modifies:

$ npm install --save-dev babel-preset-es2015-maybe-webpack babel-preset-es2015

Usage

Hint: You can get [loose] mode by using es2015-maybe-webpack/loose.

.babelrc

{
  "presets": ["es2015-maybe-webpack"]
}

Via CLI

$ babel script.js --presets es2015-maybe-webpack

Via Node API

require("babel-core").transform("code", {
  presets: ["es2015-maybe-webpack"]
})

Keywords

babel

FAQs

Package last updated on 21 Jun 2017

Did you know?

Socket

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