add require module

This commit is contained in:
pengfei.zhou
2019-07-18 18:29:47 +08:00
parent 13c5719af1
commit 723c5455ab
9 changed files with 88 additions and 24 deletions

View File

@@ -14,11 +14,13 @@ import { loge } from "../util/log";
* hego.__require__,
* ])
* // load module in global scope
* Reflect.apply(hego.registerModule,this,[
* Reflect.apply(hego.jsRegisterModule,this,[
* moduleName,
* Reflect.apply(function(__module){
* return function(module,export,require){
* })(__module,__module.exports,hego.__require__)
* (function(module,exports,require){
* //module content
* })(__module,__module.exports,hego.__require__);
* return __module.exports
* },this,[{exports:{}}])
* ])
*
@@ -83,7 +85,7 @@ export class Context {
})
})
}
registor(instance: Object) {
register(instance: Object) {
this.entity = instance
}
}

View File

@@ -5,7 +5,7 @@ export function Registor<T extends { new(...args: any[]): {} }>(constructor: T)
const ret = class extends constructor {
context = context
}
context.registor(new ret)
context.register(new ret)
return ret
}