mirror of https://github.com/lukechilds/rollup.git
Rich-Harris
9 years ago
6 changed files with 50 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||
var fs = require( 'fs' ); |
|||
|
|||
module.exports = { |
|||
description: 'uses custom loaders, falling back to default', |
|||
options: { |
|||
load: [ |
|||
function ( id ) { |
|||
if ( /foo\.js/.test( id ) ) { |
|||
return fs.readFileSync( id, 'utf-8' ).replace( '@', 1 ); |
|||
} |
|||
}, |
|||
function ( id ) { |
|||
if ( /bar\.js/.test( id ) ) { |
|||
return fs.readFileSync( id, 'utf-8' ).replace( '@', 2 ); |
|||
} |
|||
} |
|||
] |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
export default '@'; |
@ -0,0 +1 @@ |
|||
export default '@'; |
@ -0,0 +1 @@ |
|||
export default '@'; |
@ -0,0 +1,7 @@ |
|||
import foo from './foo'; |
|||
import bar from './bar'; |
|||
import baz from './baz'; |
|||
|
|||
assert.equal( foo, '1' ); |
|||
assert.equal( bar, '2' ); |
|||
assert.equal( baz, '@' ); |
@ -0,0 +1,21 @@ |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'resolver error is not caught', |
|||
options: { |
|||
resolveId: [ |
|||
function () { |
|||
throw new Error( 'nope' ); |
|||
}, |
|||
function ( importee, importer ) { |
|||
return 'main'; |
|||
} |
|||
], |
|||
load: function ( id ) { |
|||
if ( id === 'main' ) return 'assert.ok( false );' |
|||
} |
|||
}, |
|||
error: function ( err ) { |
|||
assert.equal( err.message, 'nope' ); |
|||
} |
|||
}; |
Loading…
Reference in new issue