electron/lib/common/define-properties.ts
Milan Burda 2c88626b51
chore: revert deprecate as an internal module (#40146)
Revert "chore: restore deprecate as an internal module (#40124)"

This reverts commit 737e3de3fa.
2023-10-10 11:50:47 -04:00

17 lines
588 B
TypeScript

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] = {
enumerable: true,
get: handleESModule(module.loader)
};
}
return Object.defineProperties(targetExports, descriptors);
}