From fd27a52c671eb86ac8274782c94770ee69938cdb Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Mon, 12 Dec 2016 23:09:02 -0500 Subject: [PATCH 1/2] failing test for custom runtime-helpers moduleName (#95) --- test/samples/runtime-helpers-custom-name/.babelrc | 6 ++++++ test/samples/runtime-helpers-custom-name/main.js | 3 +++ test/test.js | 15 +++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 test/samples/runtime-helpers-custom-name/.babelrc create mode 100644 test/samples/runtime-helpers-custom-name/main.js diff --git a/test/samples/runtime-helpers-custom-name/.babelrc b/test/samples/runtime-helpers-custom-name/.babelrc new file mode 100644 index 0000000..d0d4906 --- /dev/null +++ b/test/samples/runtime-helpers-custom-name/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ "es2015-rollup" ], + "plugins": [ + ["transform-runtime", { "moduleName": "custom-name" }] + ] +} diff --git a/test/samples/runtime-helpers-custom-name/main.js b/test/samples/runtime-helpers-custom-name/main.js new file mode 100644 index 0000000..b0cee91 --- /dev/null +++ b/test/samples/runtime-helpers-custom-name/main.js @@ -0,0 +1,3 @@ +export default class Foo { + +} diff --git a/test/test.js b/test/test.js index 45def60..4430af0 100644 --- a/test/test.js +++ b/test/test.js @@ -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', From 1eb55ac2d5bd556275043113c5cbf611fe995791 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Mon, 12 Dec 2016 23:10:41 -0500 Subject: [PATCH 2/2] =?UTF-8?q?allow=20custom=20runtime-helpers=20moduleNa?= =?UTF-8?q?me=20=E2=80=93=20fixes=20#95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/preflightCheck.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preflightCheck.js b/src/preflightCheck.js index e0f90b8..56cc9f5 100644 --- a/src/preflightCheck.js +++ b/src/preflightCheck.js @@ -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;