[RFC] perf: use an internal module resolver to improve require performance (#14633)
* perf: use an internal module resolver instead of relative requires * perf: memoize the results of getting exported Electron properties * perf: make internal module changes consistent across sandboxed / bundled files
This commit is contained in:
parent
73d1b76b54
commit
54ef906832
32 changed files with 156 additions and 73 deletions
|
@ -1,6 +1,6 @@
|
|||
const common = require('../../../common/api/exports/electron')
|
||||
const common = require('@electron/internal/common/api/exports/electron')
|
||||
// since browser module list is also used in renderer, keep it separate.
|
||||
const moduleList = require('../module-list')
|
||||
const moduleList = require('@electron/internal/browser/api/module-list')
|
||||
|
||||
// Import common modules.
|
||||
common.defineProperties(exports)
|
||||
|
@ -8,6 +8,6 @@ common.defineProperties(exports)
|
|||
for (const module of moduleList) {
|
||||
Object.defineProperty(exports, module.name, {
|
||||
enumerable: !module.private,
|
||||
get: () => require(`../${module.file}`)
|
||||
get: common.memoizedGetter(() => require(`@electron/internal/browser/api/${module.file}.js`))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue