Skip to content

Commit

Permalink
Fix Babel helper binding renaming
Browse files Browse the repository at this point in the history
The renaming from `babelHelpers.foo =` to a function declaration
`function babelHelpers_foo()` was incorrect as the helpers are
defined as expressions.

This puts back the helper functions being defined as function
expressions but keeps the better-minifiable `babelHelpers_` bindings.

See: rollup#19 (comment)
  • Loading branch information
ericf committed Jan 7, 2016
1 parent f58ec45 commit 835245c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export default function babel ( options ) {

return buildExternalHelpers( helpers, 'var' )
.replace( /var babelHelpers = {};\n/, '' )
.replace( /babelHelpers\.(.+) = function(?: \w+)?/g, 'function babelHelpers_$1' )
.replace( /babelHelpers\.(.+) = /g, 'var babelHelpers_$1 = ' )
.replace( 'babelHelpers;', '' ) // not sure where this comes from...
.trim() + '\n';
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe( 'rollup-plugin-babel', function () {
var generated = bundle.generate();
var code = generated.code;

assert.ok( code.indexOf( 'function babelHelpers_classCallCheck' ) !== -1, generated.code );
assert.ok( code.indexOf( 'babelHelpers_classCallCheck =' ) !== -1, generated.code );
assert.ok( code.indexOf( 'var _createClass =' ) === -1, generated.code );
});
});
Expand Down

0 comments on commit 835245c

Please sign in to comment.