rollup-plugin-babel
Advanced tools
Comparing version 1.0.0 to 2.0.0
# rollup-plugin-babel changelog | ||
## 2.0.0 | ||
* Babel 6 compatible | ||
## 1.0.0 | ||
* First release |
16
index.js
@@ -0,1 +1,2 @@ | ||
var path = require( 'path' ); | ||
var babel = require( 'babel-core' ); | ||
@@ -21,14 +22,7 @@ var createFilter = require( 'rollup-pluginutils' ).createFilter; | ||
// ensure es6.modules are blacklisted | ||
if ( options.whitelist ) { | ||
index = options.whitelist.indexOf( 'es6.modules' ); | ||
if ( ~index ) options.whitelist.splice( index, 1 ); | ||
} | ||
// preflight check | ||
var check = babel.transform( 'export default class Foo {}', assign({ filename: path.resolve( 'test.js' ) }, options ) ).code; | ||
if ( ~check.indexOf( 'function _classCallCheck' ) ) throw new Error( 'External helpers are not enabled. Please add the "external-helpers-2" plugin or use the "es2015-rollup" preset. See https://github.com/rollup/rollup-plugin-babel#TK for more information' ); | ||
if ( !~check.indexOf( 'export default' ) ) throw new Error( 'It looks like your Babel configuration specifies a module transformer. Please disable it. If you\'re using the "es2015" preset, consider using "es2015-rollup" instead. See https://github.com/rollup/rollup-plugin-babel#TK for more information' ); | ||
if ( !options.blacklist ) options.blacklist = []; | ||
index = options.blacklist.indexOf( 'es6.modules' ); | ||
if ( !~index ) options.blacklist.push( 'es6.modules' ); | ||
options.externalHelpers = true; | ||
return { | ||
@@ -35,0 +29,0 @@ transform: function ( code, id ) { |
{ | ||
"name": "rollup-plugin-babel", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"devDependencies": { | ||
@@ -14,5 +14,5 @@ "eslint": "^1.7.2", | ||
"dependencies": { | ||
"babel-core": "^5.8.25", | ||
"babel-core": "6", | ||
"rollup-pluginutils": "^1.1.0" | ||
} | ||
} |
# rollup-plugin-babel | ||
**experimental, depends on unreleased version of Rollup** | ||
Seamless integration between Rollup and Babel. | ||
@@ -11,3 +9,3 @@ | ||
* run the code through Babel first, being careful to disable the `es6.modules` transformer, or | ||
* run the code through Babel first, being careful to exclude the module transformer, or | ||
* run the code through Rollup first, and *then* pass it to Babel. | ||
@@ -51,4 +49,36 @@ | ||
## Babel 5 | ||
The latest version of rollup-plugin-babel is designed to work with Babel 6. To use rollup-plugin-babel with Babel 5, install a 1.x version: | ||
```bash | ||
npm install --save-dev rollup-plugin-babel@1 | ||
``` | ||
## Babel 6 | ||
With Babel 5, rollup-plugin-babel overrides the configuration to ensure that module syntax is left alone and that external helpers are collected for inclusion at the top of the bundle. | ||
Babel 6 works differently – there's no `blacklist` or `externalHelpers` options. Instead of using the `es2015` preset, install and use [babel-preset-es2015-rollup](https://github.com/rollup/babel-preset-es2015-rollup): | ||
```js | ||
// .babelrc | ||
{ | ||
"presets": [ "es2015-rollup" ] | ||
} | ||
``` | ||
If you're not using the preset, be sure to include the external helpers plugin: | ||
```js | ||
// .babelrc | ||
{ | ||
"plugins": [ "external-helpers-2" ] | ||
} | ||
``` | ||
## License | ||
MIT |
@@ -8,3 +8,6 @@ var assert = require( 'assert' ); | ||
describe( 'rollup-plugin-babel', function () { | ||
this.timeout( 5000 ); | ||
it( 'runs code through babel', function () { | ||
var start = Date.now(); | ||
return rollup.rollup({ | ||
@@ -14,6 +17,11 @@ entry: 'samples/basic/main.js', | ||
}).then( function ( bundle ) { | ||
console.log( 'bundled in %s ms', Date.now() - start ); | ||
start = Date.now(); | ||
const generated = bundle.generate(); | ||
console.log( 'generated in %s ms', Date.now() - start ); | ||
const code = generated.code; | ||
assert.ok( code.indexOf( 'const' ) === -1, generated.code ); | ||
assert.ok( code.indexOf( 'const' ) === -1, code ); | ||
}); | ||
@@ -31,2 +39,3 @@ }); | ||
assert.ok( code.indexOf( 'babelHelpers.classCallCheck =' ) !== -1, generated.code ); | ||
assert.ok( code.indexOf( 'var _createClass =' ) === -1, generated.code ); | ||
}); | ||
@@ -33,0 +42,0 @@ }); |
7491
107
83
+ Addedbabel-code-frame@6.26.0(transitive)
+ Addedbabel-core@6.26.3(transitive)
+ Addedbabel-generator@6.26.1(transitive)
+ Addedbabel-helpers@6.24.1(transitive)
+ Addedbabel-messages@6.23.0(transitive)
+ Addedbabel-register@6.26.0(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbabel-template@6.26.0(transitive)
+ Addedbabel-traverse@6.26.0(transitive)
+ Addedbabel-types@6.26.0(transitive)
+ Addedbabylon@6.18.0(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddetect-indent@4.0.0(transitive)
+ Addedglobals@9.18.0(transitive)
+ Addedhome-or-tmp@2.0.0(transitive)
+ Addedinvariant@2.2.4(transitive)
+ Addedjs-tokens@3.0.2(transitive)
+ Addedjsesc@1.3.0(transitive)
+ Addedjson5@0.5.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedrepeating@2.0.1(transitive)
+ Addedsource-map-support@0.4.18(transitive)
- Removedacorn@5.7.4(transitive)
- Removedalign-text@0.1.4(transitive)
- Removedalter@0.2.0(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedast-traverse@0.1.1(transitive)
- Removedast-types@0.8.120.9.6(transitive)
- Removedbabel-core@5.8.38(transitive)
- Removedbabel-plugin-constant-folding@1.0.1(transitive)
- Removedbabel-plugin-dead-code-elimination@1.0.2(transitive)
- Removedbabel-plugin-eval@1.0.1(transitive)
- Removedbabel-plugin-inline-environment-variables@1.0.1(transitive)
- Removedbabel-plugin-jscript@1.0.4(transitive)
- Removedbabel-plugin-member-expression-literals@1.0.1(transitive)
- Removedbabel-plugin-property-literals@1.0.1(transitive)
- Removedbabel-plugin-proto-to-assign@1.0.4(transitive)
- Removedbabel-plugin-react-constant-elements@1.0.3(transitive)
- Removedbabel-plugin-react-display-name@1.0.3(transitive)
- Removedbabel-plugin-remove-console@1.0.1(transitive)
- Removedbabel-plugin-remove-debugger@1.0.1(transitive)
- Removedbabel-plugin-runtime@1.0.7(transitive)
- Removedbabel-plugin-undeclared-variables-check@1.0.2(transitive)
- Removedbabel-plugin-undefined-to-void@1.1.6(transitive)
- Removedbabylon@5.8.38(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedbreakable@1.0.0(transitive)
- Removedcamelcase@1.2.1(transitive)
- Removedcenter-align@0.1.3(transitive)
- Removedcliui@2.1.0(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcommoner@0.10.8(transitive)
- Removedcore-js@1.2.7(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddefined@1.0.1(transitive)
- Removeddefs@1.1.1(transitive)
- Removeddetect-indent@3.0.1(transitive)
- Removeddetective@4.7.1(transitive)
- Removedesprima@2.7.33.1.3(transitive)
- Removedesprima-fb@15001.1001.0-dev-harmony-fb(transitive)
- Removedfs-readdir-recursive@0.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedglob@5.0.15(transitive)
- Removedglobals@6.4.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhome-or-tmp@1.0.0(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-integer@1.0.7(transitive)
- Removedjs-tokens@1.0.1(transitive)
- Removedjsesc@0.5.0(transitive)
- Removedjson5@0.4.0(transitive)
- Removedkind-of@3.2.2(transitive)
- Removedlazy-cache@1.0.4(transitive)
- Removedlcid@1.0.0(transitive)
- Removedleven@1.0.2(transitive)
- Removedlodash@3.10.1(transitive)
- Removedlongest@1.0.1(transitive)
- Removedminimatch@2.0.10(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedos-locale@1.4.0(transitive)
- Removedoutput-file-sync@1.1.2(transitive)
- Removedpath-exists@1.0.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedq@1.5.1(transitive)
- Removedrecast@0.10.330.11.23(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerator@0.8.40(transitive)
- Removedregexpu@1.3.0(transitive)
- Removedregjsgen@0.2.0(transitive)
- Removedregjsparser@0.1.5(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedrepeating@1.1.3(transitive)
- Removedresolve@1.22.8(transitive)
- Removedright-align@0.1.3(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsimple-fmt@0.1.0(transitive)
- Removedsimple-is@0.2.0(transitive)
- Removedsource-map@0.1.32(transitive)
- Removedsource-map-support@0.2.10(transitive)
- Removedstable@0.1.8(transitive)
- Removedstringmap@0.2.2(transitive)
- Removedstringset@0.2.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedthrough@2.3.8(transitive)
- Removedtry-resolve@1.0.1(transitive)
- Removedtryor@0.1.2(transitive)
- Removeduser-home@1.1.1(transitive)
- Removedwindow-size@0.1.4(transitive)
- Removedwordwrap@0.0.2(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@3.27.0(transitive)
Updatedbabel-core@6