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] public-hoist dependencies are deduped in v8, not only the direct dependencies of workspace-root #6299

Closed
SoonIter opened this issue Mar 28, 2023 · 4 comments · Fixed by #6319
Assignees
Milestone

Comments

@SoonIter
Copy link
Contributor

SoonIter commented Mar 28, 2023

pnpm version:

8.0.0

Code to reproduce the issue:

git clone https://github.com/SoonIter/pnpm8-hoist-dedupe-issue.git
pnpm install
├── package.json
├── node_modules
│   ├── eslint
│   ├── prettier 
│   └── react
├── packages
│   ├── a
│   │   └── package.json
├── pnpm-lock.yaml
└── pnpm-workspace.yaml
// packages/a/package.json
{
  "name": "a"
  "dependencies": {
    "react": "18.2.0",
    "eslint": "8.36.0",
    "prettier": "2.8.7"
  }
}
// package.json
{
  "name": "root",
  "dependencies": {
    "react": "18.2.0"
  },
}

in this demo, public-hoisting dependencies such as eslint and prettier is not symlink to "packages/a/node_modules"

#6286 This behavior is a little unclear. Is this within expectations?

This behavior is a little black box. For user consideration, if the dependencies in node_modules are exactly the same as the dependencies declared in package.json, this is more intuitive.

Expected behavior:

The node_modules directory contains all the dependencies of package.json

Additional information:

  • node -v prints: v16.19.0
  • Windows, macOS, or Linux?: macOS
@SoonIter SoonIter changed the title [bug] public-hoist dependencies are deduped in v8, not only the direct dependencies [bug] public-hoist dependencies are deduped in v8, not only the direct dependencies of workspace-root Mar 28, 2023
@SoonIter
Copy link
Contributor Author

├── apps
│   └── web
│       ├── package.json
│       ├── pnpm-lock.yaml
│       └── pnpm-workspace.yaml
└── packages
    ├── a
    │   └── package.json
    ├── b
    │   └── package.json
    └── c
        └── package.json
# apps/web/pnpm-workspace.yaml
packages:
  - '../packages/a'
  - '../packages/b'
  - '../packages/c'

This behavior also makes this directory structure not available, maybe workspace-root does not have to be at the top level.

@zkochan
Copy link
Member

zkochan commented Mar 28, 2023

Yeah, it is expected. Hoisted dependencies are deduped too.

Regarding your second message. That currently doesn't work? If so, we should definitely fix that one.

@SoonIter
Copy link
Contributor Author

@zkochan

Yeah, it is expected. Hoisted dependencies are deduped too.

Regarding your second message. That currently doesn't work? If so, we should definitely fix that one.

Yep, because of this behavior, the non-top-level directory structure cannot work.
Rushjs and some users prefer non-top-level structures to reduce the phantom dependence problem
And I want to have a configuration to switch it off or reconsider this feature.

file structure

├── apps
│   └── web
│       ├── package.json
│       ├── pnpm-lock.yaml
│       └── pnpm-workspace.yaml
└── packages
    └── a
        └── package.json
// packages/a/package.json
{ 
   "name": "a",
  "dependencies": {
    "react": "18.2.0",
    "eslint": "8.36.0",
    "prettier": "2.8.7"
  }
}
# apps/web/pnpm-workspace.yaml
packages:
  - '../../packages/**'

v7.x install behavior

├── apps
│   └── web
│       ├── node_modules
│       │   ├── eslint -> .pnpm/eslint@8.36.0/node_modules/eslint
│       │   ├── prettier -> .pnpm/prettier@2.8.7/node_modules/prettier
│       │   └── react -> .pnpm/react@18.2.0/node_modules/react
│       ├── package.json
│       ├── pnpm-lock.yaml
│       └── pnpm-workspace.yaml
└── packages
    └── a
        ├── node_modules
        │   ├── eslint -> ../../../apps/web/node_modules/.pnpm/eslint@8.36.0/node_modules/eslint
        │   ├── prettier -> ../../../apps/web/node_modules/.pnpm/prettier@2.8.7/node_modules/prettier
        │   └── react -> ../../../apps/web/node_modules/.pnpm/react@18.2.0/node_modules/react
        └── package.json

v8.0.0 install behavior

├── apps
│   └── web
│       ├── node_modules
│       │   ├── .pnpm
│       │   ├── eslint -> .pnpm/eslint@8.36.0/node_modules/eslint
│       │   ├── prettier -> .pnpm/prettier@2.8.7/node_modules/prettier
│       │   └── react -> .pnpm/react@18.2.0/node_modules/react
│       ├── package.json
│       ├── pnpm-lock.yaml
│       └── pnpm-workspace.yaml
└── packages
    └── a
        ├── node_modules     ------> react not exists, cannot find "react" "eslint" "prettier" T_T
        └── package.json

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

Successfully merging a pull request may close this issue.

3 participants