Skip to content

Commit 20612e7

Browse files
committedApr 24, 2024··
fix: skip export conditions without a source
1 parent c00b854 commit 20612e7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

‎src/node/core/pkg/parseExports.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export function parseExports(options: {
174174
}
175175
} else if (isRecord(exportEntry) && 'svelte' in exportEntry) {
176176
// @TODO should we report a warning or a debug message here about a detected svelte export that is ignored?
177-
} else if (isRecord(exportEntry)) {
177+
} else if (isPkgExport(exportEntry)) {
178178
const exp = {
179179
_exported: true,
180180
_path: exportPath,
@@ -240,7 +240,7 @@ export function parseExports(options: {
240240
}
241241

242242
_exports.push(exp)
243-
} else {
243+
} else if (!isRecord(exportEntry)) {
244244
errors.push('package.json: exports must be an object')
245245
}
246246
}
@@ -253,3 +253,7 @@ export function parseExports(options: {
253253

254254
return _exports
255255
}
256+
257+
function isPkgExport(value: unknown): value is PkgExport {
258+
return isRecord(value) && 'source' in value && typeof value['source'] === 'string'
259+
}

‎src/node/core/pkg/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface PackageJSON {
1515
string,
1616
| `./${string}.json`
1717
| {
18-
source: string
18+
source?: string
1919
types?: string
2020
browser?: {
2121
source: string

0 commit comments

Comments
 (0)
Please sign in to comment.