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

[Bug?]: Hoisting not working as expected #4122

Closed
1 task
bfanger opened this issue Feb 16, 2022 · 7 comments
Closed
1 task

[Bug?]: Hoisting not working as expected #4122

bfanger opened this issue Feb 16, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@bfanger
Copy link

bfanger commented Feb 16, 2022

Self-service

  • I'd be willing to implement a fix

Describe the bug

@storybook/client-api is installed multiple times leading to multiple disconnected "singletons" and a broken storybook installation.

storybookjs/builder-vite#50

To reproduce

.yarnrc.yml

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.1.1.cjs

package.json

{
  "name": "yarn-dedupe-bug",
  "version": "0.0.0",
  "workspaces": [
    "example-svelte"
  ],
  "dependencies": {
    "@storybook/react": "^6.4.0",
    "react": "17.0.2"
  }
}

example-svelte/package.json

{
  "name": "example-svelte",
  "private": true,
  "version": "0.0.0",
  "devDependencies": {
    "@storybook/svelte": "^6.4.0"
  }
}

Run yarn install and you'll get two installations of @storybook/client-api instead of one.

./node_modules/@storybook/svelte/node_modules/@storybook/client-api
./node_modules/@storybook/client-api

identical version of the package but different paths.

Environment

System:
    OS: macOS 11.6.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  Binaries:
    Node: 17.5.0 - /private/var/folders/b2/sc47jtm97zl1m30n6y4j_4xr0000gn/T/xfs-4b594da6/node
    Yarn: 3.1.1 - /private/var/folders/b2/sc47jtm97zl1m30n6y4j_4xr0000gn/T/xfs-4b594da6/yarn
    npm: 8.4.1 - /usr/local/bin/npm

(Yarn: 3.2.0-rc.15 also has this issue)

Additional context

No response

@bfanger bfanger added the bug Something isn't working label Feb 16, 2022
@merceyz
Copy link
Member

merceyz commented Feb 16, 2022

Please provide a cloneable reproduction as without the lockfile this might not reproduce depending on when we test it.

@merceyz merceyz changed the title [Bug?]: Dedupe not working as expected [Bug?]: Hoisting not working as expected Feb 16, 2022
@merceyz merceyz added waiting for feedback Will autoclose in a while unless more data are provided and removed waiting for feedback Will autoclose in a while unless more data are provided labels Feb 16, 2022
@bfanger
Copy link
Author

bfanger commented Feb 16, 2022

https://github.com/eirslett/storybook-builder-vite has the issue (and a lock file)

@merceyz
Copy link
Member

merceyz commented Feb 16, 2022

I'm assuming that repo will change at some point so adding a permalink to its current state
https://github.com/eirslett/storybook-builder-vite/tree/89e6b7c5fe754bcb5e2e8bdb600140688fa8950e

@larixer
Copy link
Member

larixer commented Feb 22, 2022

Not a bug, hoisting works as expected.

I have checked the repo at:
https://github.com/eirslett/storybook-builder-vite/tree/89e6b7c5fe754bcb5e2e8bdb600140688fa8950e

@storybook/client-api peer depends on react.

@storybook/[email protected] depends on @storybook/client-api and [email protected]. But your workspaces depend on @storybook/client-api and [email protected]. This can be easily discovered via yarn why -R @storybook/client-api and yarn why -R react. Thats why Yarn have to create two copies of @storybook/client-api - the first copy which uses [email protected] and the other copy which uses [email protected]

@larixer larixer closed this as completed Feb 22, 2022
@bfanger
Copy link
Author

bfanger commented Feb 22, 2022

Thanks, is there a way to force only one @storybook/client-api folder?

@arcanis
Copy link
Member

arcanis commented Feb 22, 2022

You can use packageExtensions in your yarnrc to add peerDependencies on react and react-dom to @storybook/svelte

@Enteleform
Copy link

@arcanis

There seems to be a similar issue between astro, @astrojs/renderer-solid, & solid-js.

I'm using the astro/examples/framework-multiple project as a baseline.


By default, it uses yarn@^1, which is where I first encountered the issue:

You appear to have multiple instances of Solid. This can lead to unexpected behavior.

I then tried using yarn@^3, and the same issue occured.

Adding the following to yarn@^3 finally resolved the issue:

packageExtensions:

  "astro@*":
    dependencies:
      solid-js: "1.3.7"
    peerDependencies:
      solid-js: "*"

  "@astrojs/renderer-solid@*":
    dependencies:
      solid-js: "1.3.7"
    peerDependencies:
      solid-js: "*"

Is there a way to resolve this issue for yarn@^1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants