From b57afec493d642317f93fdc572491fd4370d3d63 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 13 Oct 2022 20:07:33 +0200 Subject: [PATCH] fix: do not infer `.json` subpath exports to build unjs/h3#186 --- src/utils.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 795dab5..bedb3e8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -133,9 +133,12 @@ export function extractExportFilenames (exports: PackageJson['exports'], conditi if (typeof exports === 'string') { return [{ file: exports, type: 'esm' }] } - return Object.entries(exports).flatMap( - ([condition, exports]) => typeof exports === 'string' - ? { file: exports, type: inferExportType(condition, conditions, exports) } - : extractExportFilenames(exports, [...conditions, condition]) - ) + return Object.entries(exports) + // Filter out .json subpaths such as package.json + .filter(([subpath]) => !subpath.endsWith('.json')) + .flatMap( + ([condition, exports]) => typeof exports === 'string' + ? { file: exports, type: inferExportType(condition, conditions, exports) } + : extractExportFilenames(exports, [...conditions, condition]) + ) }