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) { if (!moduleOpts) {
return 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 // Allows passing runtime options to each module
const options = moduleOpts.options || {} const options = moduleOpts.options || (typeof moduleOpts === 'object' ? moduleOpts : {})
const originalSrc = moduleOpts.src || moduleOpts const originalSrc = moduleOpts.src || moduleOpts
// Resolve module // Resolve module
let module = originalSrc let module = originalSrc