Skip to content

Commit d872218

Browse files
authored
fix: note the conditions under which the request couldn't be found
1 parent 52b61d0 commit d872218

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/ExportsFieldPlugin.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,18 @@ module.exports = class ExportsFieldPlugin {
114114
}
115115

116116
if (paths.length === 0) {
117+
let conditions;
118+
if (this.conditionNames.length > 1) {
119+
const listFormat = new Intl.ListFormat("en", { type: "disjunction" });
120+
conditions = `the conditions ${listFormat.format(this.conditionNames.map(c => `"${c}"`))}`;
121+
} else if (this.conditionNames.length == 1) {
122+
conditions = `the condition "${this.conditionNames[0]}"`;
123+
} else {
124+
conditions = "the conditions [empty]";
125+
}
117126
return callback(
118127
new Error(
119-
`Package path ${remainingRequest} is not exported from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`,
128+
`"${remainingRequest}" is not exported under ${conditions} from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`,
120129
),
121130
);
122131
}

0 commit comments

Comments
 (0)