Skip to content

Commit e921206

Browse files
fix(cli): #1704 extra null check
1 parent 0676a73 commit e921206

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

packages/cli/src/lib/walker-package-ranger.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async function walkPackageForExports(dependency, packageJson, resolvedRoot) {
164164
// https://unpkg.com/browse/robust-predicates@3.0.2/package.json
165165
updateImportMap(dependency, exports, resolvedRoot);
166166
} else if (exports && typeof exports === "object") {
167-
// we need to check for conditional exports that are null, since typeof null === "object"
167+
// we need to check for conditional exports that are null first, since typeof null === "object"
168168
// https://github.com/ProjectEvergreen/greenwood/issues/1704
169169
// https://app.unpkg.com/effect@4.0.0-beta.97/files/package.json#L52
170170
/*
@@ -174,8 +174,7 @@ async function walkPackageForExports(dependency, packageJson, resolvedRoot) {
174174
* 3. default
175175
*/
176176
for (const sub in exports) {
177-
// although not widely used and is generally discouraged / deprecated
178-
// some export maps have an array
177+
// although not widely used and is generally discouraged / deprecated, some export maps have an array
179178
// https://app.unpkg.com/@jridgewell/gen-mapping@0.3.13/files/package.json#L18
180179
if (Array.isArray(exports[sub])) {
181180
for (const item of exports[sub]) {
@@ -213,7 +212,7 @@ async function walkPackageForExports(dependency, packageJson, resolvedRoot) {
213212
}
214213
}
215214
} else if (exports[sub] && typeof exports[sub] === "object") {
216-
// we need to check for conditional exports that are null, since typeof null === "object"
215+
// we need to check for conditional exports that are null first, since typeof null === "object"
217216
// https://github.com/ProjectEvergreen/greenwood/issues/1704
218217
// https://app.unpkg.com/effect@4.0.0-beta.97/files/package.json#L52
219218
let matched = false;
@@ -241,7 +240,10 @@ async function walkPackageForExports(dependency, packageJson, resolvedRoot) {
241240
// handle (unconditional) subpath exports
242241
if (sub === ".") {
243242
updateImportMap(dependency, `${exports[sub]}`, resolvedRoot);
244-
} else if (sub.indexOf("*") >= 0) {
243+
} else if (exports[sub] && sub.indexOf("*") >= 0) {
244+
// we need to check for conditional export sub conditions that are null first
245+
// https://github.com/ProjectEvergreen/greenwood/issues/1704
246+
// https://app.unpkg.com/effect@4.0.0-beta.97/files/package.json#L52
245247
await walkExportPatterns(dependency, exports[sub], resolvedRoot);
246248
} else if (SUPPORTED_EXPORT_CONDITIONS.includes(sub)) {
247249
// filter out for just supported top level conditions

0 commit comments

Comments
 (0)