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

Yarn PnP support #731

Closed
nicolo-ribaudo opened this issue Nov 27, 2019 · 7 comments
Closed

Yarn PnP support #731

nicolo-ribaudo opened this issue Nov 27, 2019 · 7 comments

Comments

@nicolo-ribaudo
Copy link

I'm trying to upgrade Babel to use Yarn PnP, but it has a problem with debug because it require()s supports-color without declaring it in package.json.

Would it be possible to declare it as a peerDependency?

Note that this issue isn't urgent (I currently have a workaround), but PnP will be enabled by default in yarn 2.

cc @arcanis

@arcanis
Copy link
Contributor

arcanis commented Nov 27, 2019

Note that in the context of debug the best option is probably an optional peer dependency, since the require is in a try/catch. This way you won't get warnings even if support-colors is missing 🙂

@Qix-
Copy link
Member

Qix- commented Nov 27, 2019

#709 #612

@Qix- Qix- closed this as completed Nov 27, 2019
@nicolo-ribaudo
Copy link
Author

Sorry, I searched for "pnp" in issues and didn't find anything, and I forgot to search in PRs 😅

@MonstraG
Copy link

MonstraG commented Mar 8, 2023

Hi. It's been about 3 years.

Both things linked here:

#709 #612

Are closed without proper resolution, in lieu of #556, which is sitting open for the last 4 years.

Can we pretty please fix this?

@arcanis
Copy link
Contributor

arcanis commented Mar 8, 2023

I believe it's been fixed a while ago, supports-color is listed as an optional peer dependency. #556 has no connection I can see to this former issue.

@MonstraG
Copy link

MonstraG commented Mar 8, 2023

Sadly, this is still happening to me:

vulcan.userweb:dev: warn - ../../.yarn/__virtual__/debug-virtual-252d10c791/0/cache/debug-npm-4.3.4-4513954577-3dbad3f94e.zip/node_modules/debug/src/node.js
vulcan.userweb:dev: Module not found: debug tried to access supports-color (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
vulcan.userweb:dev:
vulcan.userweb:dev: Required package: supports-color
vulcan.userweb:dev: Required by: debug@virtual:4.3.4 (via repo_folder/.yarn/__virtual__/debug-virtual-252d10c791/0/cache/debug-npm-4.3.4-4513954577-3dbad3f94e.zip/node_modules/debug/src/)
vulcan.userweb:dev:
vulcan.userweb:dev: Ancestor breaking the chain: @babel/core@npm:7.21.0
vulcan.userweb:dev: Ancestor breaking the chain: @babel/traverse@npm:7.21.2
vulcan.userweb:dev: Ancestor breaking the chain: @eslint/eslintrc@npm:0.4.3
vulcan.userweb:dev: Ancestor breaking the chain: @eslint/eslintrc@npm:2.0.0
vulcan.userweb:dev: Ancestor breaking the chain: @humanwhocodes/config-array@npm:0.11.8
vulcan.userweb:dev: Ancestor breaking the chain: @humanwhocodes/config-array@npm:0.5.0
vulcan.userweb:dev: Ancestor breaking the chain: @typescript-eslint/parser@virtual:5.54.1
vulcan.userweb:dev: Ancestor breaking the chain: @typescript-eslint/parser@virtual:5.54.1
vulcan.userweb:dev: Ancestor breaking the chain: @typescript-eslint/typescript-estree@virtual:5.54.1
vulcan.userweb:dev: Ancestor breaking the chain: @typescript-eslint/typescript-estree@virtual:5.54.1
vulcan.userweb:dev: Ancestor breaking the chain: agent-base@npm:6.0.2
vulcan.userweb:dev: Ancestor breaking the chain: agentkeepalive@npm:4.3.0
vulcan.userweb:dev: Ancestor breaking the chain: eslint@npm:7.32.0
vulcan.userweb:dev: Ancestor breaking the chain: eslint@npm:8.35.0
vulcan.userweb:dev: Ancestor breaking the chain: eslint-import-resolver-typescript@virtual:2.7.1
vulcan.userweb:dev: Ancestor breaking the chain: eslint-import-resolver-typescript@virtual:3.5.3
vulcan.userweb:dev: Ancestor breaking the chain: http-proxy-agent@npm:5.0.0
vulcan.userweb:dev: Ancestor breaking the chain: https-proxy-agent@npm:5.0.1
vulcan.userweb:dev: Ancestor breaking the chain: ioredis@npm:5.3.1
vulcan.userweb:dev: Ancestor breaking the chain: istanbul-lib-source-maps@npm:4.0.1
vulcan.userweb:dev: Ancestor breaking the chain: socks-proxy-agent@npm:7.0.0

Although it seems that my case is a bit more complicated, but I am really out of options on what to do here.

Using a monorepo, shared package accesses ioredis, which pulls down all of this. Adding packageExtensions doesn't help. Adding debug or supports-color everywhere I can, both in dependencies and resolutions doesn't help either.

Actually, scratch that, it seems that adding "supports-color": "<9.0.0", in devDependencies of root package.json and nowhere else seems to work. I have no idea why.

@arcanis
Copy link
Contributor

arcanis commented Mar 8, 2023

As indicated in the error message, debug lists supports-color correctly, it just can't be found because the debug consumers don't actually fulfil the peer dependency:

debug tried to access supports-color (a peer dependency) but it isn't provided by its ancestors

It's usually not a problem because debug makes the require call within a try/catch statement, so errors are silently ignored. If you get a warning, I'd imagine it's caused by whatever your bundler is, which perhaps isn't smart enough to understand that resolution errors within try/catch statements shouldn't be surfaced.

Actually, scratch that, it seems that adding "supports-color": "<9.0.0", in devDependencies of root package.json and nowhere else seems to work. I have no idea why.

It works because of the fallback. Explicitly listing debug in the top-level manifest allows debug to access supports-color even if its consumers don't provide it themselves. Your bundler's resolution succeeds, so no warnings are emitted.

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

No branches or pull requests

4 participants