Skip to content Skip to sidebar Skip to footer

How To Make Summary Module That Re-exports All The Exports Of Sub-modules For Esm Modules?

How do you re-export the exports from multiple files in an ESM module without listing each individual export separately? I have a CommonJS module directory that consists of a numbe

Solution 1:

You can use a star export for each of them:

export * from'./mapConcurrent.js';
export * from'./deferred.js';
export * from'./utils.js';
export * from'./rateMap.js';
export * from'./concurrency.js';
export * from'./retry.js';

It will re-export all the named exports from the respective module, but not the default export (those you'd need to rename or they would collide).

So no, you don't have to explicitly name each export, but you must explicitly declare all of the sub-files.

Post a Comment for "How To Make Summary Module That Re-exports All The Exports Of Sub-modules For Esm Modules?"