mirror of https://github.com/lukechilds/rollup.git
Browse Source
warn if exporting an IIFE that looks like a function declaration, and wrap in parens if necessarygh-786
Rich Harris
8 years ago
committed by
GitHub
7 changed files with 50 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||
const assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'uses original name of default export function (#1011)', |
|||
warnings: warnings => { |
|||
assert.deepEqual( warnings, [ |
|||
'foo.js (1:15) Ambiguous default export (is a call expression, but looks like a function declaration). See https://github.com/rollup/rollup/wiki/Troubleshooting#ambiguous-default-export' |
|||
]); |
|||
} |
|||
}; |
@ -0,0 +1,6 @@ |
|||
export default function foo ( a, b ) { |
|||
assert.equal( a, b ); |
|||
return 3; |
|||
} |
|||
|
|||
( 1 + 1, 2 ); |
@ -0,0 +1,2 @@ |
|||
import x from './foo.js'; |
|||
assert.equal( x, 3 ); |
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'wraps a function expression callee in parens to avoid it being parsed as function declaration (#1011)' |
|||
}; |
@ -0,0 +1,4 @@ |
|||
export default function foo ( x ) { |
|||
assert.equal( x, 42 ); |
|||
global.ran = true; |
|||
}( 42 ); |
@ -0,0 +1,2 @@ |
|||
import './foo.js'; |
|||
assert.ok( global.ran ); |
Loading…
Reference in new issue