diff --git a/packages/babel-core/src/config/config-descriptors.js b/packages/babel-core/src/config/config-descriptors.js index e17cca93c6..d9218a87c0 100644 --- a/packages/babel-core/src/config/config-descriptors.js +++ b/packages/babel-core/src/config/config-descriptors.js @@ -345,6 +345,7 @@ function assertNoDuplicates(items: Array): void { } if (nameMap.has(item.name)) { + const conflicts = items.filter(i => i.value === item.value); throw new Error( [ `Duplicate plugin/preset detected.`, @@ -355,6 +356,9 @@ function assertNoDuplicates(items: Array): void { ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`, + ``, + `Duplicates detected are:`, + `${JSON.stringify(conflicts, null, 2)}`, ].join("\n"), ); } diff --git a/packages/babel-core/test/option-manager.js b/packages/babel-core/test/option-manager.js index 4a6301ab47..8839f1178c 100644 --- a/packages/babel-core/test/option-manager.js +++ b/packages/babel-core/test/option-manager.js @@ -27,14 +27,19 @@ describe("option-manager", () => { return { plugin, calls }; } - it("should throw if a plugin is repeated", () => { - const { calls, plugin } = makePlugin(); + it("should throw if a plugin is repeated, with information about the repeated plugin", () => { + const { calls, plugin } = makePlugin("my-plugin"); expect(() => { loadOptions({ - plugins: [plugin, plugin], + plugins: [ + [plugin, undefined, "my-plugin"], + [plugin, undefined, "my-plugin"], + ], }); - }).toThrow(/Duplicate plugin\/preset detected/); + }).toThrow( + /Duplicate plugin\/preset detected.*Duplicates detected are.*my-plugin.*my-plugin/ms, + ); expect(calls).toEqual([]); });