2019-08-23 09:18:58 +00:00
|
|
|
const handleESModule = (loader: ElectronInternal.ModuleLoader) => () => {
|
|
|
|
const value = loader();
|
|
|
|
if (value.__esModule && value.default) return value.default;
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Attaches properties to |targetExports|.
|
|
|
|
export function defineProperties (targetExports: Object, moduleList: ElectronInternal.ModuleEntry[]) {
|
|
|
|
const descriptors: PropertyDescriptorMap = {};
|
|
|
|
for (const module of moduleList) {
|
|
|
|
descriptors[module.name] = {
|
2023-10-08 23:55:16 +00:00
|
|
|
enumerable: !module.private,
|
2019-08-23 09:18:58 +00:00
|
|
|
get: handleESModule(module.loader)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return Object.defineProperties(targetExports, descriptors);
|
|
|
|
}
|