Last active
December 30, 2024 14:39
-
-
Save ArtemAvramenko/aafa156df5a2f8956245 to your computer and use it in GitHub Desktop.
Revisions
-
ArtemAvramenko revised this gist
Dec 30, 2024 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,20 @@ // https://stackoverflow.com/a/31930918/5171110 var module: { exports: any }; var exports = { sham: (() => { var sham = ((moduleName: string) => { exports = { sham }; module = sham.modules[moduleName] = { exports }; }) as { (moduleName: string): void; modules: { [moduleName: string]: { exports: any } }; }; sham.modules = {}; return sham; })() }; var require = function (oldRequire: (moduleName: string) => any) { return (moduleName: string) => exports.sham.modules[moduleName].exports || oldRequire(moduleName); } (require!); -
ArtemAvramenko revised this gist
Aug 10, 2015 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,6 @@ var exports = { })() }; var require = function (oldRequire: (moduleName: string) => any) { return (moduleName: string) => exports.sham.modules[moduleName].exports || oldRequire(moduleName); } (require); -
ArtemAvramenko revised this gist
Aug 10, 2015 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,8 @@ var exports = { return sham; })() }; var require = function (oldRequire: (moduleName: string) => any) { return (moduleName: string) => { return exports.sham.modules[moduleName].exports || oldRequire(moduleName); } } (require); -
ArtemAvramenko revised this gist
Aug 2, 2015 . No changes.There are no files selected for viewing
-
ArtemAvramenko revised this gist
Jul 29, 2015 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,12 @@ var module: { exports }; var exports = { sham: (() => { var sham = <{ (moduleName: string): void; modules: { [moduleName: string]: { exports } }; }>(moduleName => { exports = { sham }; module = sham.modules[moduleName] = { exports }; }); sham.modules = {}; return sham; -
ArtemAvramenko created this gist
Jul 28, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ var module: (...any) => any; var exports = { sham: (() => { var sham = <{ (moduleName: string): void; modules: { [mouduleName: string]: { exports: any } }; }>(moduleName => { exports = { sham }; var m = sham.modules[moduleName] = { exports }; module = <any>m; }); sham.modules = {}; return sham; })() }; function require(moduleName: string) { return exports.sham.modules[moduleName].exports; }