Socket
Socket
Sign inDemoInstall

rollup-plugin-babel

Package Overview
Dependencies
Maintainers
4
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-babel - npm Package Compare versions

Comparing version 2.6.1 to 2.7.0

dist/rollup-plugin-babel.es.js

9

CHANGELOG.md
# rollup-plugin-babel changelog
## 2.7.0
* Add `externalHelpersWhitelist` option ([#92](https://github.com/rollup/rollup-plugin-babel/pull/92))
* Ignore `only` option during preflight checks ([#98](https://github.com/rollup/rollup-plugin-babel/issues/98))
* Use `options.onwarn` if available ([#84](https://github.com/rollup/rollup-plugin-babel/issues/84))
* Update documentation and dependencies
## 2.6.1
Return a `name`
* Return a `name`

@@ -7,0 +14,0 @@ ## 2.6.0

46

dist/rollup-plugin-babel.cjs.js

@@ -18,6 +18,6 @@ 'use strict';

var warned = {};
function warnOnce ( msg ) {
if ( warned[ msg ] ) return;
function warnOnce ( warn, msg ) {
if ( warned[ msg ] ) { return; }
warned[ msg ] = true;
console.warn( msg ); // eslint-disable-line no-console
warn( msg );
}

@@ -38,2 +38,3 @@

options = assign( {}, options );
delete options.only;
options.filename = path.join( dir, 'x.js' );

@@ -45,7 +46,7 @@

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( 'export default' ) && !~check.indexOf( 'export { Foo as default }' ) ) { throw new Error( 'It looks like your Babel configuration specifies a module transformer. Please disable it. 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;
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; }

@@ -72,4 +73,4 @@ else {

if ( options.sourceMap !== false ) options.sourceMaps = true;
if ( options.sourceMaps !== false ) options.sourceMaps = true;
if ( options.sourceMap !== false ) { options.sourceMaps = true; }
if ( options.sourceMaps !== false ) { options.sourceMaps = true; }
delete options.sourceMap;

@@ -81,10 +82,20 @@

var externalHelpers;
if ( options.externalHelpers ) externalHelpers = true;
if ( options.externalHelpers ) { externalHelpers = true; }
delete options.externalHelpers;
var externalHelpersWhitelist = null;
if ( options.externalHelpersWhitelist ) { externalHelpersWhitelist = options.externalHelpersWhitelist; }
delete options.externalHelpersWhitelist;
var warn = function (msg) { return console.warn(msg); }; // eslint-disable-line no-console
return {
name: 'babel',
options: function options$1 ( options ) {
warn = options.onwarn || warn;
},
resolveId: function resolveId ( id ) {
if ( id === HELPERS ) return id;
if ( id === HELPERS ) { return id; }
},

@@ -96,3 +107,3 @@

var helpers = babelCore.buildExternalHelpers( null, 'var' )
var helpers = babelCore.buildExternalHelpers( externalHelpersWhitelist, 'var' )
.replace( pattern, 'var _$1' )

@@ -107,4 +118,4 @@ .replace( /^babelHelpers\./gm, 'export var ' ) +

transform: function transform$1 ( code, id ) {
if ( !filter( id ) ) return null;
if ( id === HELPERS ) return null;
if ( !filter( id ) ) { return null; }
if ( id === HELPERS ) { return null; }

@@ -120,3 +131,3 @@ var helpers = preflightCheck( options, path.dirname( id ) );

if ( helpers === BUNDLED ) {
if ( !externalHelpers ) transformed.code += "\n\nimport * as babelHelpers from '" + HELPERS + "';";
if ( !externalHelpers ) { transformed.code += "\n\nimport * as babelHelpers from '" + HELPERS + "';"; }
} else if ( helpers === RUNTIME && !runtimeHelpers ) {

@@ -127,3 +138,3 @@ throw new Error( 'Runtime helpers are not enabled. Either exclude the transform-runtime Babel plugin or pass the `runtimeHelpers: true` option. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information' );

if ( inlineHelpers[ helper ] ) {
warnOnce( ("The '" + helper + "' Babel helper is used more than once in your code. It's strongly recommended that you use the \"external-helpers\" plugin or the \"es2015-rollup\" preset. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information") );
warnOnce( warn, ("The '" + helper + "' Babel helper is used more than once in your code. It's strongly recommended that you use the \"external-helpers\" plugin or the \"es2015-rollup\" preset. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information") );
}

@@ -144,2 +155,3 @@

module.exports = babel;
module.exports = babel;
//# sourceMappingURL=rollup-plugin-babel.cjs.js.map
{
"name": "rollup-plugin-babel",
"version": "2.6.1",
"version": "2.7.0",
"description": "Seamless integration between Rollup and Babel.",
"main": "dist/rollup-plugin-babel.cjs.js",
"jsnext:main": "dist/rollup-plugin-babel.es6.js",
"jsnext:main": "dist/rollup-plugin-babel.es.js",
"files": [
"src",
"dist",
"dist/rollup-plugin-babel.cjs.js",
"dist/rollup-plugin-babel.es.js",
"README"

@@ -41,9 +42,10 @@ ],

"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015-rollup": "^1.1.1",
"buble": "^0.10.6",
"eslint": "^2.11.1",
"mocha": "^2.5.3",
"rollup": "^0.29.0",
"rollup-plugin-buble": "^0.10.0",
"source-map": "^0.5.6"
"babel-preset-es2015-rollup": "^3.0.0",
"buble": "^0.14.2",
"eslint": "^3.12.0",
"mocha": "^3.2.0",
"rollup": "^0.37.0",
"rollup-plugin-buble": "^0.14.0",
"source-map": "^0.5.6",
"source-map-support": "^0.4.6"
},

@@ -50,0 +52,0 @@ "repository": {

@@ -42,4 +42,8 @@ # rollup-plugin-babel

All options are as per the [Babel documentation](https://babeljs.io/), except `options.externalHelpers` (a boolean value indicating whether to bundle in the babel helpers), `options.include` and `options.exclude` (each a minimatch pattern, or array of minimatch patterns), which determine which files are transpiled by Babel (by default, all files are transpiled).
All options are as per the [Babel documentation](https://babeljs.io/), except the following:
* `options.externalHelpers`: a boolean value indicating whether to bundle in the babel helpers
* `options.include` and `options.exclude`: each a minimatch pattern, or array of minimatch patterns, which determine which files are transpiled by Babel (by default, all files are transpiled)
* `options.externalHelpersWhitelist`: an array which gives explicit control over which babelHelper functions are allowed in the bundle (by default, every helper is allowed)
Babel will respect `.babelrc` files – this is generally the best place to put your configuration.

@@ -60,6 +64,4 @@

tl;dr: use the `es2015-rollup` preset instead of `es2015`.
```bash
npm install --save-dev babel-preset-es2015-rollup
npm install --save-dev babel-preset-es2015 babel-plugin-external-helpers
```

@@ -70,3 +72,13 @@

{
"presets": [ "es2015-rollup" ]
"presets": [
[
"es2015",
{
"modules": false
}
]
],
"plugins": [
"external-helpers"
]
}

@@ -77,3 +89,3 @@ ```

The `es2015` preset includes the [transform-es2015-modules-commonjs](http://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/) plugin, which converts ES6 modules to CommonJS – preventing Rollup from working. Instead, you should either use the `es2015-rollup` preset, which excludes that plugin, or otherwise ensure that the `modules-commonjs` plugin is excluded. Rollup will throw an error if this is incorrectly configured.
The `es2015` preset includes the [transform-es2015-modules-commonjs](http://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/) plugin, which converts ES6 modules to CommonJS – preventing Rollup from working. Since Babel 6.3 it's possible to deactivate module transformation with `"modules": false`. So there is no need to use the old workaround with `babel-preset-es2015-rollup`, that work for Babel <6.13. Rollup will throw an error if this is incorrectly configured.

@@ -104,3 +116,3 @@ ### Helpers

babel({
plugins: ['external-helpers-2'],
plugins: ['external-helpers'],
externalHelpers: true

@@ -107,0 +119,0 @@ })

@@ -29,5 +29,15 @@ import { dirname } from 'path';

let externalHelpersWhitelist = null;
if ( options.externalHelpersWhitelist ) externalHelpersWhitelist = options.externalHelpersWhitelist;
delete options.externalHelpersWhitelist;
let warn = msg => console.warn(msg); // eslint-disable-line no-console
return {
name: 'babel',
options ( options ) {
warn = options.onwarn || warn;
},
resolveId ( id ) {

@@ -41,3 +51,3 @@ if ( id === HELPERS ) return id;

const helpers = buildExternalHelpers( null, 'var' )
const helpers = buildExternalHelpers( externalHelpersWhitelist, 'var' )
.replace( pattern, 'var _$1' )

@@ -69,3 +79,3 @@ .replace( /^babelHelpers\./gm, 'export var ' ) +

if ( inlineHelpers[ helper ] ) {
warnOnce( `The '${helper}' Babel helper is used more than once in your code. It's strongly recommended that you use the "external-helpers" plugin or the "es2015-rollup" preset. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information` );
warnOnce( warn, `The '${helper}' Babel helper is used more than once in your code. It's strongly recommended that you use the "external-helpers" plugin or the "es2015-rollup" preset. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information` );
}

@@ -72,0 +82,0 @@

@@ -14,2 +14,3 @@ import { join } from 'path';

options = assign( {}, options );
delete options.only;
options.filename = join( dir, 'x.js' );

@@ -21,3 +22,3 @@

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( 'export default' ) && !~check.indexOf( 'export { Foo as default }' ) ) throw new Error( 'It looks like your Babel configuration specifies a module transformer. Please disable it. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information' );

@@ -24,0 +25,0 @@ if ( ~check.indexOf( 'import _classCallCheck from "babel-runtime' ) ) helpers = RUNTIME;

@@ -9,6 +9,6 @@ export function assign ( target, source ) {

let warned = {};
export function warnOnce ( msg ) {
export function warnOnce ( warn, msg ) {
if ( warned[ msg ] ) return;
warned[ msg ] = true;
console.warn( msg ); // eslint-disable-line no-console
warn( msg );
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc