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