Skip to content

Commit

Permalink
fix: handle exports array containing objects
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 26, 2022
1 parent d95b492 commit da44cb7
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/utils/parse-package-json/get-export-entries.ts
Expand Up @@ -32,13 +32,25 @@ function parseExportsMap(
}

if (Array.isArray(exportMap)) {
const exportPaths = exportMap.filter(isPath);

return exportPaths.map((exportPath, index) => ({
outputPath: exportPath,
type: getFileType(exportPath) || packageType,
from: `${packagePath}[${index}]`,
}));
return exportMap.flatMap(
(exportPath, index) => {
const from = `${packagePath}[${index}]`;

return (
typeof exportPath === 'string'
? (
isPath(exportPath)
? {
outputPath: exportPath,
type: getFileType(exportPath) || packageType,
from,
}
: []
)
: parseExportsMap(exportPath, packageType, from)
);
},
);
}

if (typeof exportMap === 'object') {
Expand Down

0 comments on commit da44cb7

Please sign in to comment.