aspect-build / aspect-build/rules_js
[Bug]: issue calculating single versions of a dependency with `public_hoist_packages`
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What happened?
I have a single package in my `pnpm` workspace that depends on `@storybook/addon-docs@6.5.13`. Outside of `rules_js`, if i do a `pnpm why` on that dependency in the package that has it I get
```
❯ pnpm why @storybook/addon-docs
Legend: production dependency, optional only, dev only
@company/package@0.0.82 /Users/davidaghassi/repo/web/package
devDependencies:
@storybook/addon-docs 6.5.13
```
However, if I have the following in my `npm_translate_lock` I get an error
```
public_hoist_packages = {
"@storybook/addon-controls": [""],
"@storybook/addon-docs": [""],
"@storybook/addon-google-analytics": [""],
"@storybook/addon-links": [""],
"@storybook/addons": [""],
"@storybook/api": [""],
"@storybook/builder-webpack5": [""],
"@storybook/client-api": [""],
"@storybook/components": [""],
"@storybook/core-events": [""],
"@storybook/manager-webpack5": [""],
"@storybook/react": [""],
"@storybook/theming": [""],
},
```
The error being
```
ERROR: Error computing the main repository mapping: no such package '@rh_pnpm_workspace_deps//':
Invalid public hoist configuration with multiple packages to hoist to '/node_modules/@storybook/addon-docs': ["@storybook/addon-docs@6.5.13_-380341690", "@storybook/addon-docs@6.5.13_-380252348"]
Trying selecting a specific version of '@storybook/addon-docs' to hoist in public_hoist_packages. For example '@storybook/addon-docs@6.5.13_-380341690':
public_hoist_packages = {
"@storybook/addon-docs@6.5.13_-380341690": [""]
}
```
This is the only dependency that experiences this. If I remove this, it works. I have to pick a version for this to work overall. Without this, I can't build with storybook v6 under rules_js.
This also was hard to track down because I didn't realize this part of the npmrc was not automatically read (silently passes with no warning or error)
### Version
Development (host) and target OS/architectures:
Output of `bazel --version`: 6.3.0
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
rules_js - `8e66e6ac47b1b65af6efdb5766b2dbb137065045`
Language(s) and/or frameworks involved:
### How to reproduce
```shell
I will have to find a repro, this is an internal repo.
```
### Any other information?
_No response_
Contributor guide
Research direction
Start with the npm_translate_lock configuration and its public_hoist_packages handling, using the duplicate @storybook/addon-docs entries in the reported error as the initial case. A reproduction is still needed because the report says the original repository is internal; done should mean the dependency can be hoisted without selecting an opaque version-specific key and the npmrc behavior is understood.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100