mirror of https://github.com/lukechilds/rollup.git
17 changed files with 110 additions and 30 deletions
@ -0,0 +1,5 @@ |
|||||
|
export default function ensureArray ( thing ) { |
||||
|
if ( Array.isArray( thing ) ) return thing; |
||||
|
if ( thing == undefined ) return []; |
||||
|
return [ thing ]; |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
import { readFileSync } from 'sander'; |
||||
|
|
||||
|
export function defaultLoader ( path, options ) { |
||||
|
// TODO support plugins and transformers?
|
||||
|
return readFileSync( path, { encoding: 'utf-8' }); |
||||
|
} |
@ -1,11 +1,22 @@ |
|||||
import { dirname, isAbsolute, resolve } from 'path'; |
import { dirname, isAbsolute, resolve } from 'path'; |
||||
|
|
||||
export function defaultResolver ( importee, importer ) { |
export function defaultResolver ( importee, importer, options ) { |
||||
// absolute paths are left untouched
|
// absolute paths are left untouched
|
||||
if ( isAbsolute( importee ) ) return importee; |
if ( isAbsolute( importee ) ) return importee; |
||||
|
|
||||
// external modules stay external
|
// we try to resolve external modules
|
||||
if ( importee[0] !== '.' ) return false; |
if ( importee[0] !== '.' ) { |
||||
|
// unless we want to keep it external, that is
|
||||
|
if ( ~options.external.indexOf( importee ) ) return null; |
||||
|
|
||||
|
return resolveExternal( importee, importer, options ); |
||||
|
} |
||||
|
|
||||
return resolve( dirname( importer ), importee ).replace( /\.js$/, '' ) + '.js'; |
return resolve( dirname( importer ), importee ).replace( /\.js$/, '' ) + '.js'; |
||||
} |
} |
||||
|
|
||||
|
function resolveExternal ( id, importer, options ) { |
||||
|
// for now, only node_modules is supported, and only jsnext:main
|
||||
|
|
||||
|
throw new Error( "TODO" ); |
||||
|
} |
||||
|
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'imports external modules from nested internal modules' |
description: 'imports external modules from nested internal modules', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
||||
|
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'imports default from external module' |
description: 'imports default from external module', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'imports names from an external module' |
description: 'imports names from an external module', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'imports a namespace from an external module and renames it' |
description: 'imports a namespace from an external module and renames it', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
||||
|
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'imports a namespace from an external module' |
description: 'imports a namespace from an external module', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'deconflicts imports (redux)' |
description: 'deconflicts imports (redux)', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
||||
|
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'deconflicts imports' |
description: 'deconflicts imports', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
||||
|
@ -1,3 +1,6 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'external modules are not shadowed' |
description: 'external modules are not shadowed', |
||||
|
options: { |
||||
|
external: [ 'path' ] |
||||
|
} |
||||
}; |
}; |
||||
|
Loading…
Reference in new issue