add basic module structure

This commit is contained in:
2016-10-12 01:41:30 +02:00
parent 45e57b3a84
commit 7e65012621
9 changed files with 129 additions and 4 deletions

View File

@ -1,5 +1,54 @@
import * as plugins from './smartsystem.plugins'
export class Smartsystem {
import * as q from 'q'
import { Objectmap } from 'lik'
let systemjs = require('systemjs')
class Smartsystem {
lazyModules = new Objectmap<LazyModule>()
/**
* add lazyModule to Smartsystem
*/
addLazyModule(lazyModuleArg: LazyModule) {
this.lazyModules.add(lazyModuleArg)
}
loadLazyModule(lazyModuleArg: LazyModule)
}
// create the internal smartsystem
let smartsystem = new Smartsystem()
/**
* defines a LazyModule
*/
export class LazyModule<T> {
name: string
cwd: string
constructor(nameArg: string, cwdArg: string = process.cwd()){
this.name = nameArg
this.cwd = cwdArg
smartsystem.addLazyModule(this)
}
/**
* loads the module
*/
load(): q.Promise<T> {
let done = q.defer<T>()
let loadedModule: T
systemjs.import(this.name).then((m) => {
loadedModule = m
done.resolve(loadedModule)
})
return done.promise
}
/**
* loads additional lazy modules specified as arguments and returns them in the promise for easy use
*/
loadAlso(...args: LazyModule<any>[]) {
}
}

View File

@ -1 +0,0 @@
import * as lik from 'lik'