##// END OF EJS Templates
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version

File last commit:

r115:691199f665e0 ioc ts support
r146:f3f5c56d3b3e v1.4.0-rc5 default
Show More
ResolverHelper.ts
45 lines | 1.4 KiB | video/mp2t | TypeScriptLexer
/ src / amd / ts / di / ResolverHelper.ts
cin
working on support commonjs modules format
r59 import { Uuid } from "../Uuid";
cin
fixed regression with requirejs loader
r73 import { argumentNotEmptyString, getGlobal } from "../safe";
cin
Minor fixes and improvements...
r71 import { TraceSource } from "../log/TraceSource";
cin
working on support commonjs modules format
r59 import m = require("module");
const sandboxId = Uuid();
cin
added properties to the build project...
r99 define(sandboxId, ["require"], (r: any) => r);
cin
working on support commonjs modules format
r59
cin
fixed regression with requirejs loader
r73 const globalRequire = getGlobal().require as Require || requirejs;
cin
working on support commonjs modules format
r59
const trace = TraceSource.get(m.id);
cin
fixed regression with requirejs loader
r73 trace.debug("globalRequire = {0}", globalRequire);
cin
working on support commonjs modules format
r59
class ModuleResolver {
cin
corrected code to support ts strict mode...
r115 _base: string | undefined;
cin
working on support commonjs modules format
r59 _require: Require;
constructor(req: Require, base?: string) {
this._base = base;
cin
Minor fixes and improvements...
r71 this._require = req;
cin
working on support commonjs modules format
r59 }
resolve(moduleName: string) {
argumentNotEmptyString(moduleName, "moduleName");
const resolvedName = moduleName[0] === "." && this._base ? [this._base, moduleName].join("/") : moduleName;
trace.debug(`${moduleName} -> ${resolvedName}`);
const req = this._require;
return new Promise<any>((cb, eb) => {
req([resolvedName], cb, eb);
});
}
}
cin
Minor fixes and improvements...
r71 export function makeResolver(moduleName: string, contextRequire: Require) {
const base = moduleName && moduleName.split("/").slice(0, -1).join("/");
cin
Added support for commonjs module format, all tests are pass.
r60
cin
fixed regression with requirejs loader
r73 const req = contextRequire || globalRequire;
if (!req)
throw new Error("A global require isn't defined, the contextRequire parameter is mandatory");
const resolver = new ModuleResolver(req, base);
cin
working on support commonjs modules format
r59 return (id: string) => resolver.resolve(id);
}