-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
feat: add public_hoist_packages attribute to npm_translate_lock to emulate .npmrc public-hoist-pattern[] #222
feat: add public_hoist_packages attribute to npm_translate_lock to emulate .npmrc public-hoist-pattern[] #222
Conversation
bd619f5
to
123f64b
Compare
@@ -1,3 +1,4 @@ | |||
# Set a custom registry for a scope that is picked up by pnpm when resolving packages; | |||
# This affects the lockfile format and is here to cover this case. | |||
@types:registry=https://registry.yarnpkg.com | |||
public-hoist-pattern[]=ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment that bazel / rules_js won't actually see this yet, it only has effect for pnpm i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
examples/npm_deps/BUILD.bazel
Outdated
@@ -210,3 +210,24 @@ uvu_test( | |||
":uvu_spec", | |||
], | |||
) | |||
|
|||
####################################### | |||
# Use case 6: depend on a hoisted npm package that wasn't a direct dependency package.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to say which direct dependency has the ms
dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
public_hoist_packages.extend(attr.public_hoist_packages.get(friendly_name, [])) | ||
if unfriendly_name: | ||
public_hoist_packages.extend(attr.patches.get(unfriendly_name, [])) | ||
for public_hoist_package in public_hoist_packages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice short code change is a good sign that the abstractions will endure more feature sprawl :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌮
176722b
to
6bfc884
Compare
…ulate .npmrc public-hoist-pattern[]
6bfc884
to
852b690
Compare
Turns out pnpm does not encode what it hoists in its lockfile. It is a link time decision in the implementation.
This lays the foundation for supporting https://pnpm.io/npmrc#public-hoist-pattern and https://pnpm.io/npmrc#shamefully-hoist.
Follow-ups to this would be to support globs to get closer to what users can do with
.npmrc
. For example,.npmrc
:could be emulated with
and
.npmrc
:with
Once we can do that then we could just let users use the
.npmrc
file as the source of truth instead:NB:
.npmrc
is an INI file https://en.wikipedia.org/wiki/INI_file