##// END OF EJS Templates
working version...
working version all tests are passed removed _localInstall task

File last commit:

r51:43a2828f8abe v1.2.0-rc di-typescript
r51:43a2828f8abe v1.2.0-rc di-typescript
Show More
RequireJsHelper.ts
41 lines | 1.0 KiB | video/mp2t | TypeScriptLexer
/ src / amd / ts / di / RequireJsHelper.ts
cin
working on multi-platform support
r48 import { Uuid } from "../Uuid";
cin
tests moved under src/ folder...
r50 import { argumentNotEmptyString, argumentNotNull } from "../safe";
cin
working on multi-platform support
r48 import { TraceSource } from "../log/TraceSource";
cin
working version...
r51 import m = require("module");
cin
working on multi-platform support
r48
cin
working version...
r51 const trace = TraceSource.get(m.id);
cin
working on multi-platform support
r48
cin
changed the project structure
r49 export async function createContextRequire(moduleName: string): Promise<Require> {
cin
working on multi-platform support
r48 argumentNotEmptyString(moduleName, "moduleName");
const parts = moduleName.split("/");
if (parts[0] === ".")
throw new Error("An absolute module path is required");
if (parts.length > 1)
parts.splice(-1, 1, Uuid());
else
parts.push(Uuid());
const shim = parts.join("/");
trace.debug(`define shim ${shim}`);
cin
tests moved under src/ folder...
r50 return new Promise<Require>(cb => {
cin
working on multi-platform support
r48 define(shim, ["require"], r => {
trace.debug("shim resolved");
return r;
});
cin
tests moved under src/ folder...
r50 require([shim], cb);
cin
working on multi-platform support
r48 });
}
cin
tests moved under src/ folder...
r50
export function makeResolver(req: Require) {
argumentNotNull(req, "req");
return (name: string) => {
return new Promise<any>((cb, eb) => {
req([name], cb, eb);
});
};
}