Skip to content

Commit

Permalink
Merge pull request #90 from DrewML/update-babel-warning
Browse files Browse the repository at this point in the history
Remove recommendation to change Babel preset from lib
  • Loading branch information
Rich-Harris authored and Andarist committed Dec 17, 2019
1 parent 831c049 commit b91d7f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/rollup-plugin-babel/src/preflightCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function preflightCheck ( options, dir ) {

const check = transform( 'export default class Foo {}', options ).code;

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;
Expand Down
8 changes: 4 additions & 4 deletions packages/rollup-plugin-babel/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe( 'rollup-plugin-babel', function () {
assert.ok( false, 'promise should not fulfil' );
})
.catch( function ( err ) {
assert.ok( /es2015-rollup/.test( err.message ), 'Expected an error about external helpers or module transform, got "' + err.message + '"' );
assert.ok( /configuring-babel/.test( err.message ), 'Expected an error about external helpers or module transform, got "' + err.message + '"' );
});
});

Expand All @@ -149,7 +149,7 @@ describe( 'rollup-plugin-babel', function () {
entry: 'samples/runtime-helpers/main.js',
plugins: [ babelPlugin({ runtimeHelpers: true }) ],
onwarn: function ( msg ) {
assert.equal( msg, `Treating 'babel-runtime/helpers/classCallCheck' as external dependency` );
assert.equal( msg, 'Treating \'babel-runtime/helpers/classCallCheck\' as external dependency' );
}
}).then( function ( bundle ) {
var cjs = bundle.generate({ format: 'cjs' }).code;
Expand All @@ -162,7 +162,7 @@ describe( 'rollup-plugin-babel', function () {
entry: 'samples/named-function-helper/main.js',
plugins: [ babelPlugin() ],
onwarn: function ( msg ) {
assert.equal( msg, `Treating 'babel-runtime/helpers/classCallCheck' as external dependency` );
assert.equal( msg, 'Treating \'babel-runtime/helpers/classCallCheck\' as external dependency' );
}
}).then( function ( bundle ) {
var cjs = bundle.generate({ format: 'cjs' }).code;
Expand All @@ -187,7 +187,7 @@ describe( 'rollup-plugin-babel', function () {
}).then( () => {
console.warn = consoleWarn;
assert.deepEqual( messages, [
`The 'classCallCheck' 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`
'The \'classCallCheck\' 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'
]);
});
});
Expand Down

0 comments on commit b91d7f3

Please sign in to comment.