-
-
Notifications
You must be signed in to change notification settings - Fork 936
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
Make depedenciesMeta inject by default for workspace packages? #4965
Comments
The main reason is that when you use inject and you rebuild the injected dependency, you somehow need to resync that dependency. |
I would agree with this decision, if a workspace package specifies a peerDependency, it is simply ignored when you install it from another workspace package, without any error or warning. |
can the resync somehow happen automatically? I'm using dependenciesMeta.injected right now to help out with a deep peer dependency, and my library that forwards that peer needs to be built, and those built assets aren't present in the injected version until I run install again. Since this will be a common scenario for me (in a monorepo), I'd like this to somehow be more ergonomic |
Currently the packages will be automatically synced if they are built via a prepare script. But they are not resynced when someone rebuilds them. Probably this should be fixed. |
anyone have ideas for how to re-sync dependencies when using turborepo? I could prefix all my scripts with I opened an issue here on turbo's repo: vercel/turbo#2306 |
@zkochan I had an idea for how we can reasonably do this / implement this feature.
|
This will not work with symlinks. This will only work with hard links (that we use now) or copies. Symlinks are ignored when node.js resolves dependencies. So even though the symlink to project-b will be inside project-a's node_modules, the dependencies of project-b will be resolved from the node_modules of project-b because that is where the symlink points. |
would the same idea work with hard links? instead of file-based hard-links, hard-link folders, based on Do hardlinks still work if say, the whole |
No, hard links are only possible upon files. |
Has node rejected the idea of resolving symlinks? Edit: found this: symlink alternative and the rationale for node not resolving symlinks But wait, this is all unrelated, we need the symlink in the repo-root .pnpm directory, not node_modules. |
Node.js should resolve symlinks to their real locations. Otherwise, node.js would not work with pnpm. |
How do you mean?, you said:
|
For example, let's consider these two projects:
If |
does this behavior apply to all files or just the package root? I think I need to test this out in a monorepo. I'll report back with that |
I got distracted, but in the mean time, @simonihmig made a util that would make re-syncing easier -- I commented about maybe adding it to pnpm here: #6088 (comment) |
Added a README to this project: https://github.com/NullVoxPopuli/pnpm-sync-dependencies-meta-injected it at least allows folks to regain some productivity 😅 |
@zkochan would it make sense to internalize this library as a daemon, or... how should we proceed? |
What do you mean by initializing it as a daemon? You mean adding it to pnpm as a new command? Unfortunately, I cannot really dogfood this as I only used injected deps with Bit, which automatically writes to the "injected" dists when compiling. For now, if your package works, you can transfer it to the pnpm org and we can reference it from the docs. |
without build time integration, something needs to be running to watch output directories (
sounds good, I'll make a demo |
@zkochan -- how is transferring supposed to work? should I transfer it to your user account first? |
Describe the user story
We maintain many packages with monorepo, but we often make mistake "missing peers"
expect: mssing peers 'something' in 'b'
result: nothing
dependenciesMeta.*.inject
option helps, but it is quite annoying writeinject
when every deps. It also cause another human error.Describe the solution you'd like
npm options like "use-inject-workspace = true"
Describe the drawbacks of your solution
I don't fully understand why inject should be in
package.json
instead a pnpm option,use-inject-workspace
makesinject
not explicit.Describe alternatives you've considered
use-inject-workspace = dependencies
use-inject-workspace = dependencies,devDependencies
or
add inject when add workspace as dependency?
Question:
Sorry for question. I wonder why pnpm don't use inject for all dependencies. Does it have performance drawback?
The text was updated successfully, but these errors were encountered: