require-bro
Advanced tools
+18
-3
@@ -9,4 +9,12 @@ "use strict"; | ||
| } | ||
| if(window.require && !(window.require.cache||{}).electron){ | ||
| throw new Error("require-bro is incompatible here. 'window.require' found"); | ||
| if(window.require){ | ||
| if(!(window.require.cache||{}).electron){ | ||
| throw new Error("require-bro is incompatible here. 'window.require' found"); | ||
| }else{ | ||
| window.FromElectron = { | ||
| require: window.require, | ||
| module: window.module | ||
| }; | ||
| delete window.module; | ||
| } | ||
| } | ||
@@ -50,2 +58,9 @@ if(!window.define){ | ||
| window.requireBro = function requireBro(name){ | ||
| if(window.fromElectron){ | ||
| try{ | ||
| return window.fromElectron.require.apply(window,arguments); | ||
| }catch(err){ | ||
| // search in require-bro system | ||
| } | ||
| } | ||
| if(window.requireBro.definedModules[name]){ | ||
@@ -84,3 +99,3 @@ return window.requireBro.definedModules[name]; | ||
| window.requireBro.definedModules = {}; | ||
| window.require = window.require || window.requireBro; | ||
| window.require = window.requireBro; | ||
| })(); |
+1
-1
| { | ||
| "name": "require-bro", | ||
| "description": "require for browsers", | ||
| "version": "0.2.0", | ||
| "version": "0.2.1", | ||
| "files": [ | ||
@@ -6,0 +6,0 @@ "lib" |
+1
-1
@@ -22,3 +22,3 @@ # require-bro | ||
| For electron compatibility use AMD modules instead of UMD. | ||
| Compatibility with Electron is experimental from both AMD and UMD modules. | ||
@@ -25,0 +25,0 @@ ## Use |
70368
0.63%1692
0.89%