Skip to content

Commit

Permalink
nicer looking search for non-empty export alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
naugtur committed Apr 5, 2022
1 parent 8ebd5cc commit 01a9d04
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/compartment-mapper/src/infer-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ function* interpretBrowserExports(name, exports) {
*/
function* interpretExports(name, exports, tags) {
if (isArray(exports)) {
yield* interpretExports(
name,
// Find one that produces non-empty result, discard result and use again
exports.find(ex => !interpretExports(name, ex, tags).next().done),
tags,
);
for (const section of exports) {
const results = [...interpretExports(name, section, tags)];
if (results.length > 0) {
yield* results;
break;
}
}
}
if (typeof exports === 'string') {
yield [name, relativize(exports)];
Expand Down

0 comments on commit 01a9d04

Please sign in to comment.