rollup-plugin-babel
Advanced tools
Comparing version 2.3.3 to 2.3.4
# rollup-plugin-babel changelog | ||
## 2.3.4 | ||
* Ensure class transformer is present for preflight check, and only run check once per directory ([#23](https://github.com/rollup/rollup-plugin-babel/issues/23)) | ||
## 2.3.3 | ||
@@ -4,0 +8,0 @@ |
'use strict'; | ||
var path = require('path'); | ||
var babelCore = require('babel-core'); | ||
@@ -10,12 +11,24 @@ var rollupPluginutils = require('rollup-pluginutils'); | ||
function preflightCheck(localOpts) { | ||
var check = babelCore.transform('export default class Foo {}', localOpts).code; | ||
var preflightCheckResults = {}; | ||
if (! ~check.indexOf('export default') && ! ~check.indexOf('export { Foo as 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'); | ||
function preflightCheck(options, dir) { | ||
var helpers = undefined; | ||
if (~check.indexOf('import _classCallCheck from "babel-runtime')) return RUNTIME; | ||
if (~check.indexOf('function _classCallCheck')) return INLINE; | ||
if (~check.indexOf('babelHelpers')) return BUNDLED; | ||
if (!preflightCheckResults[dir]) { | ||
options = assign({}, options); | ||
options.filename = path.join(dir, 'x.js'); | ||
throw new Error('An unexpected situation arose. Please raise an issue at https://github.com/rollup/rollup-plugin-babel/issues. Thanks!'); | ||
if (!options.plugins) options.plugins = []; | ||
options.plugins.push('transform-es2015-classes'); | ||
var check = babelCore.transform('export default class Foo {}', options).code; | ||
if (! ~check.indexOf('export default') && ! ~check.indexOf('export { Foo as 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#configuring-babel for more information'); | ||
if (~check.indexOf('import _classCallCheck from "babel-runtime')) helpers = RUNTIME;else if (~check.indexOf('function _classCallCheck')) helpers = INLINE;else if (~check.indexOf('babelHelpers')) helpers = BUNDLED;else { | ||
throw new Error('An unexpected situation arose. Please raise an issue at https://github.com/rollup/rollup-plugin-babel/issues. Thanks!'); | ||
} | ||
} | ||
return preflightCheckResults[dir] = helpers; | ||
} | ||
@@ -57,4 +70,4 @@ | ||
var helpers = preflightCheck(options, path.dirname(id)); | ||
var localOpts = assign({ filename: id }, options); | ||
var helpers = preflightCheck(localOpts); | ||
@@ -61,0 +74,0 @@ var transformed = babelCore.transform(code, localOpts); |
@@ -0,1 +1,2 @@ | ||
import { join, dirname } from 'path'; | ||
import { transform, buildExternalHelpers } from 'babel-core'; | ||
@@ -8,12 +9,24 @@ import { createFilter } from 'rollup-pluginutils'; | ||
function preflightCheck(localOpts) { | ||
var check = transform('export default class Foo {}', localOpts).code; | ||
var preflightCheckResults = {}; | ||
if (! ~check.indexOf('export default') && ! ~check.indexOf('export { Foo as 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'); | ||
function preflightCheck(options, dir) { | ||
var helpers = undefined; | ||
if (~check.indexOf('import _classCallCheck from "babel-runtime')) return RUNTIME; | ||
if (~check.indexOf('function _classCallCheck')) return INLINE; | ||
if (~check.indexOf('babelHelpers')) return BUNDLED; | ||
if (!preflightCheckResults[dir]) { | ||
options = assign({}, options); | ||
options.filename = join(dir, 'x.js'); | ||
throw new Error('An unexpected situation arose. Please raise an issue at https://github.com/rollup/rollup-plugin-babel/issues. Thanks!'); | ||
if (!options.plugins) options.plugins = []; | ||
options.plugins.push('transform-es2015-classes'); | ||
var check = transform('export default class Foo {}', options).code; | ||
if (! ~check.indexOf('export default') && ! ~check.indexOf('export { Foo as 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#configuring-babel for more information'); | ||
if (~check.indexOf('import _classCallCheck from "babel-runtime')) helpers = RUNTIME;else if (~check.indexOf('function _classCallCheck')) helpers = INLINE;else if (~check.indexOf('babelHelpers')) helpers = BUNDLED;else { | ||
throw new Error('An unexpected situation arose. Please raise an issue at https://github.com/rollup/rollup-plugin-babel/issues. Thanks!'); | ||
} | ||
} | ||
return preflightCheckResults[dir] = helpers; | ||
} | ||
@@ -55,4 +68,4 @@ | ||
var helpers = preflightCheck(options, dirname(id)); | ||
var localOpts = assign({ filename: id }, options); | ||
var helpers = preflightCheck(localOpts); | ||
@@ -59,0 +72,0 @@ var transformed = transform(code, localOpts); |
{ | ||
"name": "rollup-plugin-babel", | ||
"version": "2.3.3", | ||
"version": "2.3.4", | ||
"description": "Seamless integration between Rollup and Babel.", | ||
@@ -23,2 +23,3 @@ "main": "dist/rollup-plugin-babel.cjs.js", | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
@@ -33,2 +34,3 @@ "test": "mocha --compilers js:babel-register", | ||
"babel-core": "6", | ||
"babel-plugin-transform-es2015-classes": "^6.3.15", | ||
"object-assign": "^4.0.1", | ||
@@ -35,0 +37,0 @@ "rollup-pluginutils": "^1.1.0" |
@@ -0,1 +1,2 @@ | ||
import { dirname, join } from 'path'; | ||
import { buildExternalHelpers, transform } from 'babel-core'; | ||
@@ -8,12 +9,28 @@ import { createFilter } from 'rollup-pluginutils'; | ||
function preflightCheck ( localOpts ) { | ||
var check = transform( 'export default class Foo {}', localOpts ).code; | ||
let preflightCheckResults = {}; | ||
if ( !~check.indexOf( 'export default' ) && !~check.indexOf( 'export { Foo as 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' ); | ||
function preflightCheck ( options, dir ) { | ||
let helpers; | ||
if ( ~check.indexOf( 'import _classCallCheck from "babel-runtime' ) ) return RUNTIME; | ||
if ( ~check.indexOf( 'function _classCallCheck' ) ) return INLINE; | ||
if ( ~check.indexOf( 'babelHelpers' ) ) return BUNDLED; | ||
if ( !preflightCheckResults[ dir ] ) { | ||
options = assign( {}, options ); | ||
options.filename = join( dir, 'x.js' ); | ||
throw new Error( 'An unexpected situation arose. Please raise an issue at https://github.com/rollup/rollup-plugin-babel/issues. Thanks!' ); | ||
if ( !options.plugins ) options.plugins = []; | ||
options.plugins.push( 'transform-es2015-classes' ); | ||
const check = transform( 'export default class Foo {}', options ).code; | ||
if ( !~check.indexOf( 'export default' ) && !~check.indexOf( 'export { Foo as 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#configuring-babel for more information' ); | ||
if ( ~check.indexOf( 'import _classCallCheck from "babel-runtime' ) ) helpers = RUNTIME; | ||
else if ( ~check.indexOf( 'function _classCallCheck' ) ) helpers = INLINE; | ||
else if ( ~check.indexOf( 'babelHelpers' ) ) helpers = BUNDLED; | ||
else { | ||
throw new Error( 'An unexpected situation arose. Please raise an issue at https://github.com/rollup/rollup-plugin-babel/issues. Thanks!' ); | ||
} | ||
} | ||
return preflightCheckResults[ dir ] = helpers; | ||
} | ||
@@ -55,4 +72,4 @@ | ||
const helpers = preflightCheck( options, dirname( id ) ); | ||
var localOpts = assign({ filename: id }, options ); | ||
const helpers = preflightCheck( localOpts ); | ||
@@ -59,0 +76,0 @@ var transformed = transform( code, localOpts ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
18678
8
0
259
4
+ Addedbabel-helper-define-map@6.26.0(transitive)
+ Addedbabel-helper-function-name@6.24.1(transitive)
+ Addedbabel-helper-get-function-arity@6.24.1(transitive)
+ Addedbabel-helper-optimise-call-expression@6.24.1(transitive)
+ Addedbabel-helper-replace-supers@6.24.1(transitive)
+ Addedbabel-plugin-transform-es2015-classes@6.24.1(transitive)