Skip to content
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

Peer dependency error with plugin #5

Closed
brycewray opened this issue Mar 9, 2022 · 5 comments
Closed

Peer dependency error with plugin #5

brycewray opened this issue Mar 9, 2022 · 5 comments

Comments

@brycewray
Copy link

Mentioning to you (and will do so in the affected plugin, too) only because it may be that other plugins will be similarly affected, but 2.0.0-canary.1 crashed on launch with the following (cc @KyleMit):

npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eleventy_site@undefined
npm WARN Found: @11ty/eleventy@1.0.0
npm WARN node_modules/@11ty/eleventy
npm WARN   peer @11ty/eleventy@">=0.10.0-beta.1" from eleventy-plugin-embed-tweet@0.3.1
npm WARN   node_modules/eleventy-plugin-embed-tweet
npm WARN     dev eleventy-plugin-embed-tweet@"^0.3.1" from the root project
npm WARN   1 more (the root project)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @11ty/eleventy@">=0.10.0-beta.1" from eleventy-plugin-embed-tweet@0.3.1
npm WARN node_modules/eleventy-plugin-embed-tweet
npm WARN   dev eleventy-plugin-embed-tweet@"^0.3.1" from the root project
@KyleMit
Copy link

KyleMit commented Mar 9, 2022

The relevants bits from the plugin are the peer dependency in the package.config:

"peerDependencies": {
    "@11ty/eleventy": ">=0.10.0-beta.1"
},

I need to drill into why 2.0.0-canary.1 does not satisfy >=0.10.0-beta.1

Worth noting this is probably only due to the major version bump / canary, not the actual dev server implementation as it errors on package install

@KyleMit
Copy link

KyleMit commented Mar 9, 2022

There's a super helpful semver calculator, but pre-releases seem brittle.

I want to support everything past 0.10.0-beta.1, but the simpelest string I can get to work is this:

>0.10.0-beta  || >1.0.0-canary || >1.0.0-beta || >=1.0.1-canary || >=2.0.0-canary

And it still hits some edge cases

image

Since there are so many pre-releases and none of them really need to break, I might just remove the peer dependency check altogether?

@zachleat
Copy link
Member

zachleat commented Mar 9, 2022

Hey y’all—I’ve solved this in Eleventy core. Check out this pattern to use instead of peerDependencies:

https://github.com/11ty/eleventy-plugin-syntaxhighlight/blob/23761d7fd54de0312040520175959327b1a0ab9b/package.json#L36-L38

https://github.com/11ty/eleventy-plugin-syntaxhighlight/blob/23761d7fd54de0312040520175959327b1a0ab9b/.eleventy.js#L12-L16

versionCheck calls this configuration API method:
https://github.com/11ty/eleventy/blob/827ec845c83371343d7e6ca63bf575dd7ee9192f/src/UserConfig.js#L89-L99

The versionCheck configuration API method has been in place for a long time (I see it in v0.3.2 https://github.com/11ty/eleventy/blob/v0.3.2/src/UserConfig.js) but was only recently modified to include prereleases (as of 1.0).

Read more at 11ty/eleventy#2001

@zachleat
Copy link
Member

zachleat commented Mar 9, 2022

Going to close this one—sorry!

Per my comment above, I’d recommend using the pattern above to warn about dependency mismatches in Eleventy. You may want to open another issue over at eleventy-plugin-embed-tweet for this one.

I created 11ty/eleventy#2269 to add some additional official docs for plugin authoring best practices

@zachleat zachleat closed this as completed Mar 9, 2022
@brycewray
Copy link
Author

Going to close this one—sorry!

Per my comment above, I’d recommend using the pattern above to warn about dependency mismatches in Eleventy. You may want to open another issue over at eleventy-plugin-embed-tweet for this one.

Did, indeed. TY as always, sir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants