Skip to content

Commit

Permalink
Merge pull request #56 from rollup/gh-55
Browse files Browse the repository at this point in the history
typeof
  • Loading branch information
Rich-Harris authored and Andarist committed Dec 17, 2019
1 parent 77976ac commit 6cb1cb2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/rollup-plugin-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test": "mocha",
"prepublish": "npm run test",
"pretest": "npm run build",
"build": "rollup -c -f cjs -o dist/rollup-plugin-babel.cjs.js && rollup -c -f es6 -o dist/rollup-plugin-babel.es6.js",
"build": "rollup -c",
"prebuild": "rm -rf dist/*"
},
"dependencies": {
Expand All @@ -42,7 +42,7 @@
"buble": "^0.10.6",
"eslint": "^2.11.1",
"mocha": "^2.5.3",
"rollup": "^0.26.7",
"rollup": "^0.27.0",
"rollup-plugin-buble": "^0.10.0",
"source-map": "^0.5.6"
},
Expand Down
6 changes: 5 additions & 1 deletion packages/rollup-plugin-babel/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ var external = Object.keys( require( './package.json' ).dependencies );
export default {
entry: 'src/index.js',
plugins: [ buble() ],
external: external
external: external,
targets: [
{ dest: 'dist/rollup-plugin-babel.cjs.js', format: 'cjs' },
{ dest: 'dist/rollup-plugin-babel.es6.js', format: 'es6' }
]
};
3 changes: 3 additions & 0 deletions packages/rollup-plugin-babel/test/samples/typeof/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function bar ( a ) {
return typeof a;
}
3 changes: 3 additions & 0 deletions packages/rollup-plugin-babel/test/samples/typeof/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function foo ( a ) {
return typeof a;
}
4 changes: 4 additions & 0 deletions packages/rollup-plugin-babel/test/samples/typeof/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import foo from './foo.js';
import bar from './bar.js';

console.log( typeof foo, typeof bar, foo( 1 ), bar( 2 ) );
10 changes: 10 additions & 0 deletions packages/rollup-plugin-babel/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,14 @@ describe( 'rollup-plugin-babel', function () {
assert.deepEqual( messages, []);
});
});

it( 'produces valid code with typeof helper', () => {
return rollup.rollup({
entry: 'samples/typeof/main.js',
plugins: [ babelPlugin() ]
}).then( bundle => {
var generated = bundle.generate();
assert.equal( generated.code.indexOf( 'var typeof' ), -1, generated.code );
});
});
});

0 comments on commit 6cb1cb2

Please sign in to comment.