mirror of https://github.com/lukechilds/rollup.git
Rich Harris
10 years ago
8 changed files with 49 additions and 25 deletions
@ -0,0 +1,11 @@ |
|||
import { dirname, isAbsolute, resolve } from 'path'; |
|||
|
|||
export function defaultResolver ( importee, importer ) { |
|||
// absolute paths are left untouched
|
|||
if ( isAbsolute( importee ) ) return importee; |
|||
|
|||
// external modules stay external
|
|||
if ( importee[0] !== '.' ) return false; |
|||
|
|||
return resolve( dirname( importer ), importee ).replace( /\.js$/, '' ) + '.js'; |
|||
} |
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'imports external modules from nested internal modules' |
|||
}; |
@ -0,0 +1,6 @@ |
|||
import { relative } from 'path'; |
|||
|
|||
var path = 'a/b/c'; |
|||
var path2 = 'a/c/b'; |
|||
|
|||
export default relative( path, path2 ); |
@ -0,0 +1,8 @@ |
|||
import { relative } from 'path'; |
|||
import foo from './foo'; |
|||
|
|||
var path = 'foo/bar/baz'; |
|||
var path2 = 'foo/baz/bar'; |
|||
|
|||
assert.equal( relative( path, path2 ), '../../baz/bar' ); |
|||
assert.equal( foo, '../../c/b' ); |
@ -1,3 +1,3 @@ |
|||
module.exports = { |
|||
description: 'Non-existent modules are assumed to be external' |
|||
description: 'Non-absolute and non-relative modules are assumed to be external' |
|||
}; |
Loading…
Reference in new issue