refactor: unify module-list format and exports/electron (#19697)

This commit is contained in:
Milan Burda 2019-08-23 11:18:58 +02:00 committed by Alexey Kuzmin
parent c6a8b7f959
commit 7825d043f2
18 changed files with 108 additions and 162 deletions

View file

@ -1,25 +0,0 @@
'use strict'
const moduleList = require('@electron/internal/sandboxed_renderer/api/module-list')
const handleESModule = (m) => {
// Handle Typescript modules with an "export default X" statement
if (m.__esModule && m.default) return m.default
return m
}
for (const {
name,
load,
enabled = true,
private: isPrivate = false
} of moduleList) {
if (!enabled) {
continue
}
Object.defineProperty(exports, name, {
enumerable: !isPrivate,
get: () => handleESModule(load())
})
}

View file

@ -0,0 +1,4 @@
import { defineProperties } from '@electron/internal/common/define-properties'
import { moduleList } from '@electron/internal/sandboxed_renderer/api/module-list'
defineProperties(exports, moduleList)