From d872218a63db9f7b9f35c67a20eae8e615a9ed03 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Sun, 17 Aug 2025 15:10:07 -0700 Subject: [PATCH 1/7] fix: note the conditions under which the request couldn't be found --- lib/ExportsFieldPlugin.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ExportsFieldPlugin.js b/lib/ExportsFieldPlugin.js index b6730f0..c6bbfea 100644 --- a/lib/ExportsFieldPlugin.js +++ b/lib/ExportsFieldPlugin.js @@ -114,9 +114,18 @@ module.exports = class ExportsFieldPlugin { } if (paths.length === 0) { + let conditions; + if (this.conditionNames.length > 1) { + const listFormat = new Intl.ListFormat("en", { type: "disjunction" }); + conditions = `the conditions ${listFormat.format(this.conditionNames.map(c => `"${c}"`))}`; + } else if (this.conditionNames.length == 1) { + conditions = `the condition "${this.conditionNames[0]}"`; + } else { + conditions = "the conditions [empty]"; + } return callback( new Error( - `Package path ${remainingRequest} is not exported from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`, + `"${remainingRequest}" is not exported under ${conditions} from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`, ), ); } From 6b36e6419293025ab57f92f8b32211bb0389b26a Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 18 Aug 2025 05:37:11 -0700 Subject: [PATCH 2/7] drop the listFormat --- lib/ExportsFieldPlugin.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/ExportsFieldPlugin.js b/lib/ExportsFieldPlugin.js index c6bbfea..646b124 100644 --- a/lib/ExportsFieldPlugin.js +++ b/lib/ExportsFieldPlugin.js @@ -115,13 +115,10 @@ module.exports = class ExportsFieldPlugin { if (paths.length === 0) { let conditions; - if (this.conditionNames.length > 1) { - const listFormat = new Intl.ListFormat("en", { type: "disjunction" }); - conditions = `the conditions ${listFormat.format(this.conditionNames.map(c => `"${c}"`))}`; - } else if (this.conditionNames.length == 1) { + if (this.conditionNames.length == 1) { conditions = `the condition "${this.conditionNames[0]}"`; } else { - conditions = "the conditions [empty]"; + conditions = `the conditions ${JSON.stringify(this.conditionNames)}`; } return callback( new Error( From a9df92de0108181b3e970853b6ffb33385deef46 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 18 Aug 2025 05:46:22 -0700 Subject: [PATCH 3/7] what i get for using github.dev instead of a real editor --- lib/ExportsFieldPlugin.js | 10 ++++------ test/exportsField.test.js | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/ExportsFieldPlugin.js b/lib/ExportsFieldPlugin.js index 646b124..d283615 100644 --- a/lib/ExportsFieldPlugin.js +++ b/lib/ExportsFieldPlugin.js @@ -114,12 +114,10 @@ module.exports = class ExportsFieldPlugin { } if (paths.length === 0) { - let conditions; - if (this.conditionNames.length == 1) { - conditions = `the condition "${this.conditionNames[0]}"`; - } else { - conditions = `the conditions ${JSON.stringify(this.conditionNames)}`; - } + const conditions = + this.conditionNames.length === 1 + ? `the condition "${this.conditionNames[0]}"` + : `the conditions ${JSON.stringify(this.conditionNames)}`; return callback( new Error( `"${remainingRequest}" is not exported under ${conditions} from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`, diff --git a/test/exportsField.test.js b/test/exportsField.test.js index e93b1e5..66c3c69 100644 --- a/test/exportsField.test.js +++ b/test/exportsField.test.js @@ -2352,7 +2352,7 @@ describe("exportsFieldPlugin", () => { resolver.resolve({}, fixture2, "exports-field?foo", {}, (err, result) => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); - expect(err.message).toMatch(/Package path \.\/\?foo is not exported/); + expect(err.message).toMatch(/"\.\/\?foo" is not exported/); done(); }); }); @@ -2381,7 +2381,7 @@ describe("exportsFieldPlugin", () => { resolver.resolve({}, fixture2, "exports-field#foo", {}, (err, result) => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); - expect(err.message).toMatch(/Package path \.\/#foo is not exported/); + expect(err.message).toMatch(/"\.\/#foo" is not exported/); done(); }); }); @@ -2837,7 +2837,7 @@ describe("exportsFieldPlugin", () => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); expect(err.message).toMatch( - /Package path \.\/features\/internal\/file\.js is not exported/, + /"\.\/features\/internal\/file\.js" is not exported/, ); done(); }, @@ -2938,7 +2938,7 @@ describe("exportsFieldPlugin", () => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); expect(err.message).toMatch( - /Package path \.\/string\.ts is not exported/, + /"\.\/string\.ts" is not exported/, ); done(); }); @@ -2963,7 +2963,7 @@ describe("exportsFieldPlugin", () => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); expect(err.message).toMatch( - /Package path \.\/string\.ts is not exported/, + /"\.\/string\.ts" is not exported/, ); done(); }); From 8d21cfbb5be590fa36bc3ebdc357ca7702842218 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 18 Aug 2025 05:47:47 -0700 Subject: [PATCH 4/7] oh, also it's actually a set --- lib/ExportsFieldPlugin.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ExportsFieldPlugin.js b/lib/ExportsFieldPlugin.js index d283615..35732b3 100644 --- a/lib/ExportsFieldPlugin.js +++ b/lib/ExportsFieldPlugin.js @@ -114,13 +114,14 @@ module.exports = class ExportsFieldPlugin { } if (paths.length === 0) { - const conditions = - this.conditionNames.length === 1 - ? `the condition "${this.conditionNames[0]}"` - : `the conditions ${JSON.stringify(this.conditionNames)}`; + const conditions = [...this.conditionNames]; + const conditionsStr = + conditions.length === 1 + ? `the condition "${conditions[0]}"` + : `the conditions ${JSON.stringify(conditions)}`; return callback( new Error( - `"${remainingRequest}" is not exported under ${conditions} from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`, + `"${remainingRequest}" is not exported under ${conditionsStr} from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`, ), ); } From a78df356c02cef645ae84a53b4c90289d368b1f5 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 18 Aug 2025 06:39:51 -0700 Subject: [PATCH 5/7] i should REALLY stop using github.dev --- lib/ExportsFieldPlugin.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ExportsFieldPlugin.js b/lib/ExportsFieldPlugin.js index 35732b3..cba3cc7 100644 --- a/lib/ExportsFieldPlugin.js +++ b/lib/ExportsFieldPlugin.js @@ -115,10 +115,10 @@ module.exports = class ExportsFieldPlugin { if (paths.length === 0) { const conditions = [...this.conditionNames]; - const conditionsStr = - conditions.length === 1 - ? `the condition "${conditions[0]}"` - : `the conditions ${JSON.stringify(conditions)}`; + const conditionsStr = + conditions.length === 1 + ? `the condition "${conditions[0]}"` + : `the conditions ${JSON.stringify(conditions)}`; return callback( new Error( `"${remainingRequest}" is not exported under ${conditionsStr} from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`, From dc0831d3c02892f6f5ef73f91d07acfc0d07f3d2 Mon Sep 17 00:00:00 2001 From: KTibow Date: Mon, 18 Aug 2025 07:53:47 -0700 Subject: [PATCH 6/7] okay, running locally, sorry about all that, SURELY it'll work this time --- test/exportsField.test.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/exportsField.test.js b/test/exportsField.test.js index 66c3c69..adb5561 100644 --- a/test/exportsField.test.js +++ b/test/exportsField.test.js @@ -2937,9 +2937,7 @@ describe("exportsFieldPlugin", () => { resolver.resolve({}, fixture, "pkg/string.js", {}, (err, result) => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); - expect(err.message).toMatch( - /"\.\/string\.ts" is not exported/, - ); + expect(err.message).toMatch(/"\.\/string\.ts" is not exported/); done(); }); }); @@ -2962,9 +2960,7 @@ describe("exportsFieldPlugin", () => { resolver.resolve({}, fixture, "pkg/string.js", {}, (err, result) => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); - expect(err.message).toMatch( - /"\.\/string\.ts" is not exported/, - ); + expect(err.message).toMatch(/"\.\/string\.ts" is not exported/); done(); }); }); From f1e1301a36e72b905146c2a27dad7c3c5ab0dbfa Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 18 Aug 2025 15:16:13 +0000 Subject: [PATCH 7/7] no shortcuts this time. actually using yarn. if this doesn't work... --- test/exportsField.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/exportsField.test.js b/test/exportsField.test.js index adb5561..337eb07 100644 --- a/test/exportsField.test.js +++ b/test/exportsField.test.js @@ -2470,7 +2470,9 @@ describe("exportsFieldPlugin", () => { (err, result) => { if (!err) return done(new Error(`expect error, got ${result}`)); expect(err).toBeInstanceOf(Error); - expect(err.message).toMatch(/not exported from package/); + expect(err.message).toMatch( + /not exported under the condition "webpack" from package/, + ); done(); }, );