Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #109 from rollup/gh-95
Browse files Browse the repository at this point in the history
Allow custom runtime-helpers moduleName
  • Loading branch information
Rich-Harris committed Dec 13, 2016
2 parents 6406fa5 + 1eb55ac commit 6ebbbe9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/preflightCheck.js
Expand Up @@ -22,7 +22,7 @@ export default function preflightCheck ( options, dir ) {

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 ( /import _classCallCheck from ["']babel-runtime/.test( check ) ) helpers = RUNTIME;
if ( ~check.indexOf( 'import _classCallCheck from' ) ) helpers = RUNTIME;
else if ( ~check.indexOf( 'function _classCallCheck' ) ) helpers = INLINE;
else if ( ~check.indexOf( 'babelHelpers' ) ) helpers = BUNDLED;

Expand Down
6 changes: 6 additions & 0 deletions test/samples/runtime-helpers-custom-name/.babelrc
@@ -0,0 +1,6 @@
{
"presets": [ "es2015-rollup" ],
"plugins": [
["transform-runtime", { "moduleName": "custom-name" }]
]
}
3 changes: 3 additions & 0 deletions test/samples/runtime-helpers-custom-name/main.js
@@ -0,0 +1,3 @@
export default class Foo {

}
15 changes: 15 additions & 0 deletions test/test.js
Expand Up @@ -157,6 +157,21 @@ describe( 'rollup-plugin-babel', function () {
});
});

it( 'allows transform-runtime to be used with custom moduleName', function () {
return rollup.rollup({
entry: 'samples/runtime-helpers-custom-name/main.js',
plugins: [
babelPlugin({ runtimeHelpers: true })
],
onwarn: function ( msg ) {
assert.equal( msg, 'Treating \'custom-name/helpers/classCallCheck\' as external dependency' );
}
}).then( function ( bundle ) {
var cjs = bundle.generate({ format: 'cjs' }).code;
assert.ok( !~cjs.indexOf( 'babelHelpers' ) );
});
});

it( 'correctly renames helpers (#22)', () => {
return rollup.rollup({
entry: 'samples/named-function-helper/main.js',
Expand Down

0 comments on commit 6ebbbe9

Please sign in to comment.