WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often have to fix a bug in an external package. The basic approach is to edit my package to reference a local copy of the external package. Then rebuild, refresh and test. At least I’d like it to be that easy.
But as far as I know, it’s not so easy. At least not with one additional constraint to the scenario. Let’s say that my package and the external package both depend on one or more grandchild packages. Duplicating a grandchild package at runtime is unsafe, odd things fail if two copies are resolved.
There are three ways I know of to reference the local copy of the external package. link:../local-copy, workspace:* (adding ../local-copy to pnpm-workspace.yaml, or file:../local-copy. link: and workspace: don’t work, multiple copies of the grandchild packages appear at runtime. pnpm.overrides on the grandchild doesn’t fix the duplication (and it would be error prone.)
file:../local-copy works, but only once. After editing the local copy, and rebuilding it, changes are not picked up in my package's resolution path, even after pnpm update or pnpm install. pnpm install –force works, but that takes a really long time to run when unrelated packages have long install scripts.
So my current approach is something like this:
edit my package.jsonpnpm.overrides to change the external package to a 'file: dependency.
edit external package, pnpm prepublish in external package
re-edit pnpm.overrides to introduce a typo into file: dependency
pnpm i
re-edit pnpm.overrides to fix the typo
pnpm i
test change. If it doesn't work, redo installation to distinguish installation error from development bug...
Is there a better way?
If not, could pnpm i always check whether the file: dependency is outdated on disk? Or could we add an option to do so, e.g. pnpm i –force-file-dependencies?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I often have to fix a bug in an external package. The basic approach is to edit my package to reference a local copy of the external package. Then rebuild, refresh and test. At least I’d like it to be that easy.
But as far as I know, it’s not so easy. At least not with one additional constraint to the scenario. Let’s say that my package and the external package both depend on one or more grandchild packages. Duplicating a grandchild package at runtime is unsafe, odd things fail if two copies are resolved.
There are three ways I know of to reference the local copy of the external package.
link:../local-copy,workspace:*(adding../local-copytopnpm-workspace.yaml, orfile:../local-copy.link:andworkspace:don’t work, multiple copies of the grandchild packages appear at runtime.pnpm.overrideson the grandchild doesn’t fix the duplication (and it would be error prone.)file:../local-copyworks, but only once. After editing the local copy, and rebuilding it, changes are not picked up in my package's resolution path, even afterpnpm updateorpnpm install.pnpm install –forceworks, but that takes a really long time to run when unrelated packages have long install scripts.So my current approach is something like this:
package.jsonpnpm.overridesto change the external package to a'file:dependency.pnpm prepublishin external packagefile:dependencyIs there a better way?
If not, could
pnpm ialways check whether thefile:dependency is outdated on disk? Or could we add an option to do so, e.g.pnpm i –force-file-dependencies?Beta Was this translation helpful? Give feedback.
All reactions