chore: remove deprecated modules internally using remote.require in sandboxed renderer context (#15957)
This commit is contained in:
parent
fef262f829
commit
713df08e3e
5 changed files with 1 additions and 27 deletions
|
@ -37,13 +37,6 @@ process.isRemoteModuleEnabled = isRemoteModuleEnabled
|
|||
// The electron module depends on process.atomBinding
|
||||
const electron = require('electron')
|
||||
|
||||
const remoteModules = new Set([
|
||||
'child_process',
|
||||
'fs',
|
||||
'os',
|
||||
'path'
|
||||
])
|
||||
|
||||
const loadedModules = new Map([
|
||||
['electron', electron],
|
||||
['events', events],
|
||||
|
@ -91,17 +84,11 @@ 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)) {
|
||||
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