Skip to content

Commit

Permalink
Fixed issue with reading .code from null (untranspiled file due to ig…
Browse files Browse the repository at this point in the history
…nore/only options) (#193)
  • Loading branch information
Andarist committed Apr 11, 2020
1 parent 7642ec3 commit 0d9c8f2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/rollup-plugin-babel/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export default function babel ( options ) {

const transformed = transform( code, localOpts );

if (!transformed) {
return { code };
}

return {
code: transformed.code,
map: transformed.map
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": [ ["@babel/env", { "modules": false, "loose": true } ] ],
"ignore": ["ignored.js"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default class Ignored {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ignored';
6 changes: 6 additions & 0 deletions packages/rollup-plugin-babel/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,10 @@ describe( 'rollup-plugin-babel', function () {
assert.equal( code.indexOf( 'var typeof' ), -1, code );
});
});

it( 'handles babelrc with ignore option used', () => {
return bundle('samples/ignored-file/main.js').then(({ code }) => {
assert.ok( code.indexOf('class Ignored') !== -1 );
});
});
});

0 comments on commit 0d9c8f2

Please sign in to comment.