├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | dist 4 | *.log 5 | .* 6 | !.gitignore 7 | !.npmignore 8 | !.babelrc 9 | !.travis.yml 10 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | tests 3 | coverage 4 | .* 5 | *.log 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '5.0' 4 | - '4.0' 5 | notifications: 6 | email: false 7 | sudo: false 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Gajus Kuizinas (http://gajus.com/) 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the Gajus Kuizinas (http://gajus.com/) nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL ANUARY BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated 2 | 3 | As of Babel version [v6.13.0](https://github.com/babel/babel/blob/master/CHANGELOG.md#v6130-2016-08-04), `babel-preset-es2015` supports `modules` option. 4 | 5 | Use [preset options](https://babeljs.io/docs/plugins/#pluginpresets-options) to [disable transformation of the ES6 module syntax](https://babeljs.io/docs/plugins/preset-es2015/#options): 6 | 7 | ```json 8 | { 9 | "presets": [ 10 | [ 11 | "es2015", 12 | { 13 | "modules": false 14 | } 15 | ] 16 | ] 17 | } 18 | ``` 19 | 20 | # babel-preset-es2015-webpack 21 | 22 | [![NPM version](http://img.shields.io/npm/v/babel-preset-es2015-webpack.svg?style=flat-square)](https://www.npmjs.org/package/babel-preset-es2015-webpack) 23 | [![Travis build status](http://img.shields.io/travis/gajus/babel-preset-es2015-webpack/master.svg?style=flat-square)](https://travis-ci.org/gajus/babel-preset-es2015-webpack) 24 | [![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical) 25 | 26 | Babel preset for all es2015 plugins except [`babel-plugin-transform-es2015-modules-commonjs`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-commonjs). 27 | 28 | This preset is used to enable ES2015 code compilation down to ES5. webpack 2 natively supports ES6 [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) and [`export`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) statements. webpack 2 leverages the [static structure of the ES6 modules](http://exploringjs.com/es6/ch_modules.html#static-module-structure) to perform tree shaking. 29 | 30 | For an introduction to tree shaking and webpack 2 see [Tree-shaking with webpack 2 and Babel 6](http://www.2ality.com/2015/12/webpack-tree-shaking.html). 31 | 32 | ## Install 33 | 34 | ```sh 35 | npm install babel-preset-es2015-webpack --save-dev 36 | ``` 37 | 38 | ## Usage 39 | 40 | Add to `.babelrc`: 41 | 42 | ```json 43 | { 44 | "presets": [ 45 | "es2015-webpack" 46 | ] 47 | } 48 | ``` 49 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var babelPresetEs2015, 2 | commonJsPlugin, 3 | es2015PluginList, 4 | es2015WebpackPluginList; 5 | 6 | babelPresetEs2015 = require('babel-preset-es2015'); 7 | 8 | try { 9 | // npm ^3 10 | commonJsPlugin = require('babel-plugin-transform-es2015-modules-commonjs'); 11 | } catch (error) { 12 | 13 | } 14 | 15 | if (!commonJsPlugin) { 16 | try { 17 | // npm ^2 18 | commonJsPlugin = require('babel-preset-es2015/node_modules/babel-plugin-transform-es2015-modules-commonjs'); 19 | } catch (error) { 20 | 21 | } 22 | } 23 | 24 | if (!commonJsPlugin) { 25 | throw new Error('Cannot resolve "babel-plugin-transform-es2015-modules-commonjs".'); 26 | } 27 | 28 | es2015PluginList = babelPresetEs2015.plugins; 29 | 30 | es2015WebpackPluginList = es2015PluginList.filter(function (es2015Plugin) { 31 | return es2015Plugin !== commonJsPlugin; 32 | }); 33 | 34 | if (es2015PluginList.length !== es2015WebpackPluginList.length + 1) { 35 | throw new Error('Cannot remove "babel-plugin-transform-es2015-modules-commonjs" from the plugin list.'); 36 | } 37 | 38 | module.exports = { 39 | plugins: es2015WebpackPluginList 40 | }; 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-preset-es2015-webpack", 3 | "description": "Babel preset for all es2015 plugins except babel-plugin-transform-es2015-modules-commonjs.", 4 | "version": "6.4.2", 5 | "main": "./index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/gajus/babel-preset-es2015-webpack" 9 | }, 10 | "keywords": [ 11 | "babel", 12 | "preset", 13 | "es2015", 14 | "webpack" 15 | ], 16 | "author": { 17 | "name": "Gajus Kuizinas", 18 | "email": "gajus@gajus.com", 19 | "url": "http://gajus.com" 20 | }, 21 | "license": "BSD-3-Clause", 22 | "scripts": { 23 | "test": "" 24 | }, 25 | "dependencies": { 26 | "babel-preset-es2015": "^6.6.0" 27 | } 28 | } 29 | --------------------------------------------------------------------------------