webpack-federation-obj-exposes
Version:
Configure Webpack 5 Module Federation exposes through a nested object hierarchy.
20 lines (16 loc) • 339 B
JavaScript
function objectExposes(obj, path = ".") {
return Object.entries(obj).reduce((p, [k, v]) => {
const kPath = `${path}/${k}`;
if (typeof v === "object") {
return {
...p,
...objectExposes(v, kPath),
};
}
return {
...p,
[kPath]: v,
};
}, {});
}
module.exports = objectExposes;