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

Support nested "resolutions" / "overrides" #6608

Open
Tracked by #159
soneymathew opened this issue Oct 19, 2023 · 11 comments
Open
Tracked by #159

Support nested "resolutions" / "overrides" #6608

soneymathew opened this issue Oct 19, 2023 · 11 comments
Labels
atw bun install Something that relates to the npm-compatible client enhancement New feature or request

Comments

@soneymathew
Copy link
Contributor

What version of Bun is running?

1.0.6+969da088f5db3258a803ec186012e30f992829b4

What platform is your computer?

Darwin 23.0.0 arm64 arm

What steps can reproduce the bug?

in package.json add nested resolutions

example from a package.json that failed bun install

 "resolutions" : {
          "**/@myscope/pkg1/**/@anotherscope/pkg2": "187.8.3",
        "**/@myscope/pkg3/**/@emotion/react": "11.10.6",
        "**/@myscope/pkg4/**/@myscope/pkg5": "3.0.3",
        "**/jest-environment-enzyme/jest-environment-jsdom": "^28.0.0",
        "@myscope/pkg6/**/@anotherscope/pkg7": "^10.6.0",
        "@types/webpack-dev-server/**/webpack": "^4.44.1",
        "apollo/moment": "^2.29.4"
 }

What is the expected behavior?

bun install should succeed without errors

What do you see instead?

I see

warn: Bun currently does not support nested "resolutions"

Additional information

No response

@soneymathew soneymathew added the bug Something isn't working label Oct 19, 2023
@Electroid Electroid added bun install Something that relates to the npm-compatible client atw labels Oct 19, 2023
@Electroid Electroid changed the title Bun currently does not support nested "resolutions" Bun currently does not support nested "resolutions" / "overrides" Oct 20, 2023
@rostero1
Copy link

This would be helpful in mitigating findings from security scans, where the immediate dependency may not have the fix, but I know I can safely bump the nested dependency.

@ivanabrkic
Copy link

+1

@gerardmarquinarubio
Copy link

+1

Currently pdfjs-dist can't be used with bun because it doesn't support node_module_register and therefore canvas. This could be solved if we bun add canvas@npm:@napi-rs/canvas and:

"overrides": {
  "pdfjs-dist": {
      "canvas": "$canvas"
    }
}

I'm sure many other packages would benefit from nested overrides, especially in cases where there is a dependency that's not yet supported by bun but that has other dependencies that mimic the api but don't depend on node-specific functionality.

For others with a similar problem for now I had to:

  1. bun add canvas@npm:@napi-rs/canvas
  2. rsync -a --delete node_modules/canvas/ node_modules/pdfjs-dist/node_modules/canvas

I added the second command to the "postinstall" script to make it something reproducible.

@sainjay
Copy link

sainjay commented Apr 29, 2024

+1

warn: Bun currently does not support nested "overrides"

@jebarpg
Copy link

jebarpg commented May 3, 2024

Is there any work being done on this yet?

@Jarred-Sumner
Copy link
Collaborator

Currently pdfjs-dist can't be used with bun because it doesn't support node_module_register and therefore canvas. This could be solved if we bun add canvas@npm:@napi-rs/canvas

@gerardmarquinarubio as of Bun v1.1.13, you can do this as an alternative to nested overrides for that specific scenario:

"overrides": {
   "canvas": "npm:@napi-rs/canvas@latest"
}

This installs @napi-rs/canvas into node_modules/canvas. This is not nested overrides, as nested overrides supports only applying to a specific dependency - this applies everywhere.

@gerardmarquinarubio
Copy link

Currently pdfjs-dist can't be used with bun because it doesn't support node_module_register and therefore canvas. This could be solved if we bun add canvas@npm:@napi-rs/canvas

@gerardmarquinarubio as of Bun v1.1.13, you can do this as an alternative to nested overrides for that specific scenario:

"overrides": {
   "canvas": "npm:@napi-rs/canvas@latest"
}

This installs @napi-rs/canvas into node_modules/canvas. This is not nested overrides, as nested overrides supports only applying to a specific dependency - this applies everywhere.

I see, totally missed it from the docs:

Add bar to the "overrides" field in package.json. Bun will defer to the specified version range when determining which version of bar to install, whether it's a dependency or a metadependency.

Didn't cross my mind that "metadependency" refers to dependencies of dependencies, but it totally makes sense.

@ljharb
Copy link

ljharb commented Jun 14, 2024

The typical term for that is “transitive dependency”, fwiw.

@Jarred-Sumner Jarred-Sumner added enhancement New feature or request and removed bug Something isn't working labels Aug 27, 2024
@Jarred-Sumner Jarred-Sumner changed the title Bun currently does not support nested "resolutions" / "overrides" Support nested "resolutions" / "overrides" Aug 27, 2024
@Jarred-Sumner Jarred-Sumner mentioned this issue Oct 7, 2024
53 tasks
@Sliov
Copy link

Sliov commented Oct 22, 2024

We're facing difficulties with the latest Next 15 release & bun as a package manager, as most react/next related dependencies still use React 18, there's no current way for us to pin React 19 as a nested resolution.

Is it still planned for Q4?

@diavrank
Copy link

diavrank commented Nov 9, 2024

Same issue on Nestjs app, with docusign-esign/**/cookiejar and @temporalio/interceptors-opentelemetry/**/@opentelemetry/resources resolutions

@DaniGuardiola
Copy link

To add a use case, this is currently a blocker for Ariakit to migrate to Bun as pm and script & dev server runner. It's necessary because Ariakit tests @wordpress/components with depends on Ariakit, and tests against the local repo version (file: protocol). See ariakit/ariakit#4350 (comment)

Would love to see this land!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
atw bun install Something that relates to the npm-compatible client enhancement New feature or request
Projects
None yet
Development

No branches or pull requests