mirror of https://github.com/lukechilds/rollup.git
Rich Harris
10 years ago
6 changed files with 56 additions and 9 deletions
@ -0,0 +1,35 @@ |
|||||
|
var path = require( 'path' ); |
||||
|
var fs = require( 'fs' ); |
||||
|
var assert = require( 'assert' ); |
||||
|
|
||||
|
var cachedModules = { |
||||
|
'@main.js': 'import foo from "./foo"; export default foo();' |
||||
|
}; |
||||
|
|
||||
|
module.exports = { |
||||
|
description: 'applies custom resolver to entry point', |
||||
|
//solo: true,
|
||||
|
options: { |
||||
|
resolvePath: function ( importee, importer ) { |
||||
|
if ( importer === undefined ) { |
||||
|
return '@' + path.relative( __dirname, importee ); |
||||
|
} |
||||
|
|
||||
|
if ( importer[0] === '@' ) { |
||||
|
return path.resolve( __dirname, importee ) + '.js'; |
||||
|
} |
||||
|
|
||||
|
return path.resolve( path.dirname( importer ), importee ) + '.js'; |
||||
|
}, |
||||
|
load: function ( moduleId ) { |
||||
|
if ( moduleId[0] === '@' ) { |
||||
|
return cachedModules[ moduleId ]; |
||||
|
} |
||||
|
|
||||
|
return fs.readFileSync( moduleId, 'utf-8' ); |
||||
|
} |
||||
|
}, |
||||
|
exports: function ( exports ) { |
||||
|
assert.equal( exports, 42 ); |
||||
|
} |
||||
|
}; |
@ -0,0 +1,3 @@ |
|||||
|
export default function () { |
||||
|
return 21; |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
import bar from './bar'; |
||||
|
|
||||
|
export default function () { |
||||
|
return bar() * 2; |
||||
|
} |
Loading…
Reference in new issue