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_packages does not hoist dependencies in bazel-bin/node_modules #1419

Open
zhihao-gong opened this issue Dec 29, 2023 · 0 comments
Labels
bug Something isn't working untriaged Requires traige

Comments

@zhihao-gong
Copy link

zhihao-gong commented Dec 29, 2023

What happened?

I am migrating my vue project to bazel and rules_js.

I used @vue/cli-service@4.5.19 which transitively uses plugins such as @vue/cli-plugin-babel, but without declaring it in dependencies. So I plan to use public_hoist_packages to make @vue/cli-service aware of @vue/cli-plugin-babel.
But the public_hoist_packages field did not hoist @vue/cli-plugin-babel in bazel-bin/node_modules.

Based on docs, public_hoist_packages will do the same thing as public-hoist-pattern in pnpm. I also tried bazelbuild/examples/frontend and didn't see changes in bazel-bin/node_modules either.

Version

Development (host) and target OS/architectures:
x86_64 GNU/Linux ubuntu focal

Output of bazel --version:
bazel 7.0.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
rules_js version is 1.34.1

How to reproduce

I built all targets in bazelbuild/examples/frontend and didn't see hoisting in bazel-bin/node_modules

tusen@desk-0181:~/examples/frontend$ bazel build ...
INFO: Analyzed 69 targets (1236 packages loaded, 10039 targets configured).
INFO: Found 69 targets...
INFO: Elapsed time: 9.104s, Critical Path: 0.09s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
tusen@desk-0181:~/examples/frontend$ ls bazel-bin/node_modules/
jsdom  vitest

I tried pnpm i with public_hoist_pattern which did the hoisting in node_modules directory.

tusen@desk-0181:~/examples/frontend$ pnpm i
Scope: all 7 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 1.6s
tusen@desk-0181:~/examples/frontend$ ls node_modules/
@next                        eslint-import-resolver-typescript  eslint-plugin-jsx-a11y         eslint-utils
eslint                       eslint-module-utils                eslint-plugin-react            eslint-visitor-keys
eslint-config-next           eslint-plugin-flowtype             eslint-plugin-react-hooks      jsdom
eslint-config-react-app      eslint-plugin-import               eslint-plugin-testing-library  vitest
eslint-import-resolver-node  eslint-plugin-jest                 eslint-scope
tusen@desk-0181:~/examples/frontend$ cat .npmrc 
# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules). See
# https://github.com/aspect-build/rules_js/blob/7377f2d0387cc2a9251137929b1c53ccdb3fbcf0/docs/npm_import.md#npm_translate_lock
# documentation for more information.
hoist=false

public-hoist-pattern[]=@next/eslint-plugin-next*
public-hoist-pattern[]=eslint*
@zhihao-gong zhihao-gong added the bug Something isn't working label Dec 29, 2023
@github-actions github-actions bot added the untriaged Requires traige label Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
Status: No status
Development

No branches or pull requests

1 participant