Skip to content

Add browserslist to peerDependencies #45

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

Merged
merged 1 commit into from
May 14, 2020
Merged

Add browserslist to peerDependencies #45

merged 1 commit into from
May 14, 2020

Conversation

joshwilsonvu
Copy link

Hello,

When installing a dependent of this package with Yarn 2, I got log output pointing out that this package has a missing peer dependency browserslist, because postcss-browser-comments has a peer dependency on it. More info here.

➤ YN0000: ┌ Resolution step
➤ YN0002: │ postcss-normalize@npm:9.0.0 doesn't provide browserslist@^4 requested by postcss-browser-comments@npm:3.0.0
➤ YN0000: └ Completed in 0.32s
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 2.58s
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 2.92s
➤ YN0000: Done with warnings in 6s

Unfortunately, this isn't just a warning; Yarn 2 Plug 'n Play throws an error when postcss-browser-comments attempts to require browserslist, even if the top-level project has browserslist installed.

UnhandledPromiseRejectionWarning: Error: postcss-browser-comments tried to access browserslist (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

Adding browserslist to peerDependencies makes the intended behavior here explicit and resolves the installation warning and runtime exception. It will not be a breaking change as npm and Yarn 1 already surface a peer dependency warning from postcss-browser-comments.

@jonathantneal
Copy link
Collaborator

Thank you for explaining the issue so clearly and even presenting me with a solution.

I’m merging this because it resolve an important issue and it is non-breaking.

However, I’m surprised to discover that browserslist is a peerDependencies since it explicitly uses it. Do you suppose that package should change browserslist to a dependency?

@jonathantneal jonathantneal merged commit fd294fd into csstools:master May 14, 2020
@joshwilsonvu
Copy link
Author

They certainly could, but a peer dependency lets their package work with whatever version the end user or a dependent package decides to install. Just a matter of taste I suppose.

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

Successfully merging this pull request may close these issues.

2 participants