chore: simplify code for modules internally using remote.require in sandbox (#16104)
This commit is contained in:
parent
c64b4a3926
commit
7a6fe00f49
7 changed files with 8 additions and 49 deletions
|
@ -91,13 +91,16 @@ Object.defineProperty(preloadProcess, 'noDeprecation', {
|
|||
|
||||
process.on('exit', () => preloadProcess.emit('exit'))
|
||||
|
||||
const { remoteRequire } = require('@electron/internal/renderer/remote')
|
||||
|
||||
// This is the `require` function that will be visible to the preload script
|
||||
function preloadRequire (module) {
|
||||
if (loadedModules.has(module)) {
|
||||
return loadedModules.get(module)
|
||||
}
|
||||
if (remoteModules.has(module)) {
|
||||
return require(module)
|
||||
electron.deprecate.warn(`require('${module}')`, `remote.require('${module}')`)
|
||||
return remoteRequire(module)
|
||||
}
|
||||
throw new Error('module not found')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue