How to use Modules/Classes in Typescript with Requirejs
<p>I'm attempting to start using RequireJs from within MS CRM, but I'm confused as to how to use Require JS with my current TypeScript files.</p>

<p>Currently, each form in CRM has it's own Typescript file, that looks something like this:</p>

<pre class="lang-ts prettyprint-override"><code>// File Path .\_Contoso\scripts\Contact.ts
module Contoso {
    export class Contact {

        private static instance = new Contact();

        //#region Form Properties

        static fields = { }

        //#endregion Form Properties

        //#region onLoad / onSave

        static onLoad(): void {
            Contact.instance.onLoad();
        }

        private onLoad = (): void =&gt; { ...}

        static onSave(): void { Contact.instance.onSave(); }

        private onSave = (): void =&gt; { ... }

        //#endregion onLoad / onSave
    }
}
</code></pre>

<p>Each file may contain dependencies on one or more common files/classes:</p>

<pre class="lang-ts prettyprint-override"><code>// File Path .\_Abc\scripts\CommonLib.ts
module ABC_Corp {
    export class CommonLib {
        ... 
    }
}

// File Path .\_Abc\scripts\RestLib.ts
module ABC_Corp {
    export class RestLib {
        ... 
    }
}


// File Path .\_Abc\scripts\RoleLib.ts
module ABC_Corp {
    export class RoleLib {
        ... 
    }
}
</code></pre>

<p>These files all currently live in a VS Website Project.  Whenever I save the ts files, it generates the JS and I deploy those files to CRM.</p>

<p>Now, enter RequireJS.  Since the only supported hook in CRM for JS file execution to begin is the "OnLoad" and "onSave" events, I have created a Contoso.Require file that will read the require configuration from the CRM OnLoad function call, and then call the appropriate onLoad method on the form script.  This is all working in order to load the main form JS, and call the onLoad function.  My problem is I have to define in the CRM OnLoad Event, the required JS files, rather than having each file define what files are required by it.   How do I define what files are required by each class/file?</p>