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

Allow custom runtime-helpers moduleName #109

Merged
merged 3 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/preflightCheck.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class Foo {

}
15 changes: 15 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
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