Trigger lifecycle scripts for workspaces#6869
Trigger lifecycle scripts for workspaces#6869tomasz-sodzawiczny wants to merge 4 commits intoyarnpkg:masterfrom
Conversation
|
28ccf69 to
7ece7fb
Compare
|
I'm not too sure about this one ... I think there's a conceptual issue with regard to peer dependencies. Let's say you have the following:
What's the correct action? The way I see it, they are:
Both 1 and 2 are quite surprising and probably wrong. 3 is surprising as well, but has an entirely predictable behavior, which I would count as an improvement over the two others. The 4 is similar, but only affects workspaces that can trip on this behavior. While it would seems better at first glance, it makes the behavior confusing: from the end user perspective, I'm not sure they would understand why the install scripts run in a case but not every case. I'd personally tend to pick option 3, but I clearly understand the use case so I'd be happy if we could find an intuitive way to make it work that I haven't think of! |
|
@arcanis I am not sure I understand why I would ever run the scripts more than once - the scripts are run when the What am I missing? Can you clarify that? I realise now I missed something else - the order of running the scripts matters: So when we have packages:
The flow using the registry would be:
So I believe with workspaces we should run:
The only case left is when we have circular dependencies - but maybe in this case throwing a warning and not doing anything is a valid solution. Does that make any sense? |
It's not so simple. Imagine that in my previous example B is actually Of course it's a contrived example, but basically: the peer dependencies might be used in order to build the package. Since different peer dependencies can be provided to the same package, it follows that the package might need to be built against each set of dependencies. |
Can they? We're talking about the scripts that run before the package is installed or even published - aren't the edit: Of course it is possible with workspaces, but this is IMO an invalid setup and workspaces don't protect you from it in any way - the same way you can technically require any of the dependencies of sibling workspaces. |
|
That's true for |
|
Oh wow, thanks for pointing that out - you're right, I did a quick check though, and it seems So - we can do nothing about |
|
Can we restrict this to |
|
@NathanielHill Sorry for not following up on this yet - I think Do you know if there is some easy way to do this? I'm guessing this order is already computed somewhere in |
|
Haven't looked at yarn codebase at all. I'm currently solving this by explicitly calling the |
* add test for not running `install`/`postinstall` * add test for running `prepare` in correct order
|
@arcanis I updated the PR. Now the behaviour of
Do you think this is a valid solution now? |
|
Gentle ping on this, still finding myself needing this every so often. Is there anything else needed for this to be merged? |
|
Hello are there news about merging this PR? |
Fixes #3911
All lifecycle scripts run during install (
preinstall,install,postinstall,prepublish&prepare) are now run on the main directory and all workspaces.