mirror of https://github.com/lukechilds/rollup.git
Arpad Borsos
10 years ago
4 changed files with 41 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||
module.exports = { |
|||
description: 'method of external named import used inside prototype method', |
|||
context: { |
|||
// override require here, making "foo" appear as a global module
|
|||
require: function ( name ) { |
|||
if ( name === 'bar' ) { |
|||
return require( './bar' ); |
|||
} |
|||
return require( name ); |
|||
} |
|||
}, |
|||
options: { |
|||
external: [ 'bar' ] |
|||
}, |
|||
}; |
@ -0,0 +1,5 @@ |
|||
exports.bar = { |
|||
foobar: function () { |
|||
return 42; |
|||
} |
|||
}; |
@ -0,0 +1,16 @@ |
|||
import { bar } from 'bar'; |
|||
|
|||
export default function Foo() { |
|||
// XXX: one does not even have to call the method, simply having it defined
|
|||
// on the prototype triggers the failure
|
|||
//return this.bar();
|
|||
return bar.foobar(); |
|||
} |
|||
|
|||
// XXX: this prototype definition throws it of, comment it out and it at least
|
|||
// fails at runtime because it generates wrong code
|
|||
Foo.prototype.bar = function () { |
|||
// XXX: it also has to be a nested function, simply calling `bar()` here
|
|||
// works, or at least it fails ar runtime like the case above
|
|||
return bar.foobar(); |
|||
}; |
@ -0,0 +1,5 @@ |
|||
// XXX: it has to be an imported module, otherwise it compiles and fails at
|
|||
// runtime
|
|||
import Foo from './foo.js'; |
|||
|
|||
assert.equal( new Foo(), 42 ); |
Loading…
Reference in new issue