assertNoDuplicates throw with more context#10419
Conversation
When users see errors like
```
Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.
plugins: [
['some-plugin', {}],
['some-plugin', {}, 'some unique name'],
]
```
It can be difficult to determine the source of the conflict, especially
in a larger build system.
This commit outputs what is known about the plugins that actually
conflict, which can be helpful for users to determine the root cause of
the conflict.
Partially addresses babel#9778
|
Note that this commit only outputs the conflicts that triggered a particular assertion. It could in principle output all conflicts, but I'd be concerned about the output getting too large. |
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11526/ |
1 similar comment
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11526/ |
| plugins: [plugin, plugin], | ||
| plugins: [ | ||
| [plugin, undefined, "my-plugin"], | ||
| [plugin, undefined, "my-plugin"], |
There was a problem hiding this comment.
What does it throw if you don't specify the my-plugin name here?
There was a problem hiding this comment.
@nicolo-ribaudo the example output in the pr is a case where no name is specified. Because I'm serializing it with JSON.stringify you don't see the name key in the output at all.
The output for this test is:
Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.
plugins: [
['some-plugin', {}],
['some-plugin', {}, 'some unique name'],
]
Duplicates detected are:
[
{
"name": "my-plugin",
"alias": "base$0",
"dirname": "/Users/dhamilto/src/babel/babel/packages/babel-core/test",
"ownPass": false
},
{
"name": "my-plugin",
"alias": "base$1",
"dirname": "/Users/dhamilto/src/babel/babel/packages/babel-core/test",
"ownPass": false
}
]
With the name omitted, the output becomes:
Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.
plugins: [
['some-plugin', {}],
['some-plugin', {}, 'some unique name'],
]
Duplicates detected are:
[
{
"alias": "base$0",
"dirname": "/Users/dhamilto/src/babel/babel/packages/babel-core/test",
"ownPass": false
},
{
"alias": "base$1",
"dirname": "/Users/dhamilto/src/babel/babel/packages/babel-core/test",
"ownPass": false
}
]
|
Any thoughts on this one? Not sure what the process itself is to move forward here... |
|
@nicolo-ribaudo - 👋 I'd love some progress here, we are often times getting bug reports for the current error that require us to manually throw a console.log into |
When users see errors like
It can be difficult to determine the source of the conflict, especially
in a larger build system.
This commit outputs what is known about the plugins that actually
conflict, which can be helpful for users to determine the root cause of
the conflict.
New example output on conflict:
Partially addresses #9778