Skip to content

Commit

Permalink
Expose define also as require.define
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jul 17, 2018
1 parent d49f334 commit 818b11e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ namespace AMDLoader {
* Non standard extension to fetch loader events
*/
getStats(): LoaderEvent[];

/**
* The define function
*/
define(id: 'string', dependencies: string[], callback: any): void;
define(id: 'string', callback: any): void;
define(dependencies: string[], callback: any): void;
define(callback: any): void;
}

export interface IModuleConfiguration {
Expand Down
3 changes: 3 additions & 0 deletions src/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ namespace AMDLoader {
RequireFunc.getStats = function (): LoaderEvent[] {
return moduleManager.getLoaderEvents();
};
RequireFunc.define = function () {
return DefineFunc.apply(null, arguments);
}

export function init(): void {
if (typeof global.require !== 'undefined' || typeof require !== 'undefined') {
Expand Down
7 changes: 7 additions & 0 deletions src/loader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ declare namespace AMDLoader {
* Non standard extension to fetch loader events
*/
getStats(): LoaderEvent[];
/**
* The define function
*/
define(id: 'string', dependencies: string[], callback: any): void;
define(id: 'string', callback: any): void;
define(dependencies: string[], callback: any): void;
define(callback: any): void;
}
interface IModuleConfiguration {
[key: string]: any;
Expand Down
3 changes: 3 additions & 0 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,9 @@ var AMDLoader;
RequireFunc.getStats = function () {
return moduleManager.getLoaderEvents();
};
RequireFunc.define = function () {
return DefineFunc.apply(null, arguments);
};
function init() {
if (typeof AMDLoader.global.require !== 'undefined' || typeof require !== 'undefined') {
var _nodeRequire_1 = (AMDLoader.global.require || require);
Expand Down

0 comments on commit 818b11e

Please sign in to comment.