Skip to content

Monorepo project dedupes dependencies even when not specified #9948

@filipw01

Description

@filipw01

Describe the bug

I am using a monorepo package and an app consuming it. They both use different versions of a dependency

Vite uses the version specified in app, even when importing it from the internal package

I expect Vite to use version of a package that is specified in internal package's package.json for the package and the version in app's package.json for app code (not the package code)

For me personally it happens with yarn 3, but I reproduced it on stackblitz using pnpm
To represent the issue I used:
nanoid@2.0.0 for package that is using default export
nanoid@3.0.0 for app that is using named export

Reproduction

https://stackblitz.com/edit/github-zdg7ym-1hbqbp?file=package%2Findex.jsx

System Info

Note, this is my local system info where it failed with yarn, I wasn't able to run it in stackblitz

  System:
    OS: macOS 13.0
    CPU: (10) x64 Apple M1 Max
    Memory: 469.47 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.18.2 - ~/Library/Caches/fnm_multishells/926_1661596049762/bin/node
    Yarn: 3.2.3 - ~/Library/Caches/fnm_multishells/926_1661596049762/bin/yarn
    npm: 8.5.4 - ~/Library/Caches/fnm_multishells/926_1661596049762/bin/npm
  Browsers:
    Brave Browser: 104.1.42.86
    Chrome: 104.0.5112.101
    Firefox: 103.0.2
    Safari: 16.0
  npmPackages:
    @vitejs/plugin-react: 3.1.0 => 3.1.0
    vite: 4.1.2 => 4.1.2

Used Package Manager

yarn

Logs

Click to expand! Error in browser ```shell Uncaught SyntaxError: import not found: default ```

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: deps optimizerEsbuild Dependencies Optimizationp4-importantViolate documented behavior or significantly improves performance (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions