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
Allowing acorn ^5 or ^6 as peer dependency breaks any module that relies on acorn 6 if 7 is present #103
Comments
Hmm, you're saying that You need to add |
Actually, I don't see a problem with your example. When I replicate same |
Hmm maybe I'm wrong about the exact cause. I made the demo last night and it did what I expected so I figured I was right. That said I'm not sure what else could be the cause. |
That's the expected behaviour, given that |
cc @mysticatea could this be similar to the issue you had and described earlier in acornjs/acorn#870 and #102? |
Yes, this looks the problem that acornjs/acorn#870 and #102 have solved. If you use acorn 7.1.0 or newer, this kind of broken will disappear. If we want to solve this on acorn 6 as well, we need to backport acornjs/acorn#870. |
Backporting to 6 sounds like the ideal solution if that's feasible. |
encounter similar issue here: having both rollup and buble as dependencies. then acorn-jsx parsing will break. |
Looks like this is resolved by acornjs/acorn#887 🎉 |
Sorry for the confusing title - if anyone can improve it please do.
Problem
This module claims to support both
acorn^6.0.0
andacorn^7.0.0
:acorn-jsx/package.json
Line 22 in e57398c
This may be correct in this particular module, but by allowing either one as a peer dependency, Node automatically pulls in the most recent one that is available. So if this plugin is being used in a project that still doesn't support
acorn^7
butacorn^7
is included somewhere else in the dependency tree, the project will break because the versions conflict.This is probably best explained with an example:
Example
I've uploaded a basic module at https://github.com/iansan5653/simple-acorn-jsx-example/ that is a minimal example of a module that uses this extension and still runs
acorn^6
. If you download this and runnpm i
andnode index
, the module will run just fine. As expected, npm installs the most recent version ofacorn-jsx
andacorn^6.3.0
, and becauseacorn-jsx
does supportacorn^6
, this works great.However, if I require my example module in another project that uses
acorn^7
, this is where problems occur. Here's an example of such a project:package.json:
index.js:
Running
node index
here results in an error. This happens becauseacorn-jsx
findsacorn^7
in its peers and pulls that in instead of using the version of acorn found insidesimple-acorn-jsx-example
.Impact
A real-world impact of this is that any project which relies on Buble breaks if that project (or any of its dependencies) relies on
acorn^7
. By extension, any project that uses styleguideist breaks under the same circumstances, because styleguideist relies on Buble.Reference: styleguidist/react-styleguidist#1321.
Solution
I'm not sure exactly what solution works best here. Ideally acorn-jsx should check to see which version of acorn the requiring package is using and then adjust accordingly, but that may not be feasible.
Maybe there should be two releases of this plugin - one that is compatible with
acorn^4
and one withacorn^5
. Maybe these could be two major versions of the same plugin? I'm not really sure.Maybe there's a much more elegant solution I don't know about.
The text was updated successfully, but these errors were encountered: