Skip to content

Commit

Permalink
* [html5] fix compatibility problem & support deps arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRaindrop committed Jan 20, 2017
1 parent baa7cb4 commit 00e7079
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion html5/services/amd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const amdService = {

// create a amd service.
create: (id, env, config) => {
if (!env.framework.match(/Vue/i)) {
return
}

const mod = {}
modules[id] = mod
const amdObject = {
Expand Down Expand Up @@ -54,7 +58,18 @@ const amdService = {
}
const exports = {}
const module = { exports }
const ret = servMod.factory(amdObject.require, exports, module)
const { deps } = servMod
let ret
if (deps && deps.length >= 1) {
/**
* to support:
* define(name, ['foo', 'bar'], function (foo, bar) { ... })
*/
const args = deps.map(depName => require(depName))
ret = servMod.factory(...args)
} else {
ret = servMod.factory(amdObject.require, exports, module)
}
servMod.cached = ret || module.exports
return servMod.cached
}
Expand Down

0 comments on commit 00e7079

Please sign in to comment.