##// END OF EJS Templates
changed the project structure
changed the project structure

File last commit:

r49:1a91da7b15f7 di-typescript
r49:1a91da7b15f7 di-typescript
Show More
RequireJsHelper.ts
35 lines | 1.1 KiB | video/mp2t | TypeScriptLexer
/ src / amd / ts / di / RequireJsHelper.ts
cin
working on multi-platform support
r48 import { Uuid } from "../Uuid";
import { argumentNotEmptyString } from "../safe";
import { TraceSource } from "../log/TraceSource";
export const rjs = require;
declare function define(name: string, modules: string[], cb?: (...args: any[]) => any, eb?: (e) => any): void;
declare function define(modules: string[], cb?: (...args: any[]) => any, eb?: (e) => any): void;
const trace = TraceSource.get("@implab/core/di/RequireJsHelper");
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
changed the project structure
r49 return new Promise<Require>(fulfill => {
cin
working on multi-platform support
r48 define(shim, ["require"], r => {
trace.debug("shim resolved");
return r;
});
require([shim], fulfill);
});
}