Pre-resolve electron require path
This commit is contained in:
parent
daea448b61
commit
566b0676bc
1 changed files with 11 additions and 1 deletions
|
@ -17,7 +17,7 @@ Module._nodeModulePaths = function (from) {
|
||||||
// If "from" is outside the app then we do nothing.
|
// If "from" is outside the app then we do nothing.
|
||||||
skipOutsidePaths = from.startsWith(process.resourcesPath)
|
skipOutsidePaths = from.startsWith(process.resourcesPath)
|
||||||
|
|
||||||
// Following logoic is copied from module.js.
|
// Following logic is copied from module.js.
|
||||||
splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//
|
splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//
|
||||||
paths = []
|
paths = []
|
||||||
parts = from.split(splitRe)
|
parts = from.split(splitRe)
|
||||||
|
@ -34,3 +34,13 @@ Module._nodeModulePaths = function (from) {
|
||||||
}
|
}
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const electronPath = path.join(__dirname, '..', process.type, 'api', 'exports', 'electron.js')
|
||||||
|
const originalResolveFilename = Module._resolveFilename
|
||||||
|
Module._resolveFilename = function (request, parent, isMain) {
|
||||||
|
if (request === 'electron') {
|
||||||
|
return electronPath
|
||||||
|
} else {
|
||||||
|
return originalResolveFilename(request, parent, isMain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue