New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertNoDuplicates throw with more context #10419
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @hjdivad! Debugging these errors is quite hard (since it contains no context on which plugins/presets were causing the issue), with these changes we can have a bit more of a fighting chance....
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it throw if you don't specify the my-plugin
name here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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