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

Bun currently does not support nested "resolutions" / "overrides" #6608

Open
soneymathew opened this issue Oct 19, 2023 · 8 comments
Open

Bun currently does not support nested "resolutions" / "overrides" #6608

soneymathew opened this issue Oct 19, 2023 · 8 comments
Labels
atw bug Something isn't working npm Something that relates to the npm-compatible client

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 npm 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
atw bug Something isn't working npm Something that relates to the npm-compatible client
Projects
None yet
Development

No branches or pull requests

9 participants