mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Pre-resolve electron require path
This commit is contained in:
@@ -17,7 +17,7 @@ Module._nodeModulePaths = function (from) {
|
||||
// If "from" is outside the app then we do nothing.
|
||||
skipOutsidePaths = from.startsWith(process.resourcesPath)
|
||||
|
||||
// Following logoic is copied from module.js.
|
||||
// Following logic is copied from module.js.
|
||||
splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//
|
||||
paths = []
|
||||
parts = from.split(splitRe)
|
||||
@@ -34,3 +34,13 @@ Module._nodeModulePaths = function (from) {
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user