feat(module): easier options

Allow using babel style array and flatten options
This commit is contained in:
Pooya Parsa 2017-05-31 19:24:53 +04:30
parent 79b97093d0
commit 44c6a25247

View File

@ -95,8 +95,15 @@ class Module {
if (!moduleOpts) {
return
}
// Allow using babel style array options
if(Array.isArray(moduleOpts)) {
moduleOpts = {
src: moduleOpts[0],
options: moduleOpts[1]
}
}
// Allows passing runtime options to each module
const options = moduleOpts.options || {}
const options = moduleOpts.options || (typeof moduleOpts === 'object' ? moduleOpts : {})
const originalSrc = moduleOpts.src || moduleOpts
// Resolve module
let module = originalSrc