-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
CLI: Fix pnp support & add auto-detection #21046
Conversation
All this flipping effort and when I try to generate the sandbox i still get this:
last part of the log above:
(norbert/pnp-experiment-2)⚡ % cd sandbox/internal-pnp ~/Projects/Storybook/core Error: Cannot find module '/Users/me/Projects/Storybook/core/sandbox/internal-pnp/.yarn/cache/storybook-npm-7.0.0-beta.46-3d9afedaf1-8.zip/node_modules/storybook/index.js'
|
I did discover that this error:
...is caused by the newly added templates directory in the renderers. When the cli runs init, it adds the proper renderer package, but it does not itself depend on it. I tried a few things to fix this. I've tried loading the I noticed the I don't know I have a lot of options left. I'm close to just calling yarn pnp "broken" with no way to fix. We could make an adjustment to our CLI code to simply skip the copying of the templates from the renderer package when we can't find it.. make it fault-tolerant. But this will cause other issue higher up the chain.. stories being missing, assets not being found... etc. And even if I via such a method fix the problem ( @storybookjs/core |
I wonder if @arcanis would be willing to lend any insight/assistance in order to get storybook working with yarn pnp. |
So I've worked around the pnp issue for getting the templates from the renderer via a new method that does not involve loading the As a general fallback for when the renderer package could not be found. |
521a718
to
1a98e0e
Compare
👋 Do you have specific questions? The thread is a bit long and I'm not familiar with SB 😅 Generally, the If you get
|
👀 ...yes |
I traced this back to this line: storybook/scripts/tasks/sandbox-parts.ts Line 431 in 734767b
Which fails because:
fails hard, on the code that's in main.js when in pnp mode.
|
Ok, cool the sandbox generates now! Or at least the process exits successfully now. When I try to run the sandbox I get this error though:
Which hints at perhaps the version from the public npm registry is being used, not the one from verdaccio? |
I ssh'ed into the CI runner ran the command again, and it succeeded this time...
I'm stuck on this... argh |
It means something did the equivalent of |
@arcanis it looks like he did indeed add a dependency on It also seems strange that we'd need to deal with tarballs at all, I would have expected yarn to handle such details. |
33f4344
to
cf947aa
Compare
@arcanis There is something weird going on in yarn pnp in this sandbox... This message it's giving me:
... is wrong! If I open
So yarn's warning that this uses this package, but doesn't depend on it, is not correct. I suspect some sort of caching? I have verified that yarn has taken the the package from the verdaccio server, and is using the correct version. I figured that perhaps the cache is in the lockfile. got a different error:
This error means very little to me.. but I can take a look into the package mentioned: But the package
I'm not sure if this is normal, but I notice the Looking into the source of the packages mentioned in the logs, this is where it makes a reference to the sub-package:
Here's the code on github: https://github.com/The-Code-Monkey/TechStack/blob/dev/packages/x-default-browser/src/detect-mac.js#L1 Is the problem that it's using an ESM import statement? 🤔 FYI @The-Code-Monkey just letting you know. |
Here's a zip of the sandbox, after re-generating the lockfile: |
I went ahead and did a little trick to make the I re-created the sandbox, re-generated the lockfile, re-ran yarn install, and re-tried running Seems like it's getting even closer now, here's the error:
@arcanis is there some bandwidth on your side to assist the storybook team (me?) on this? Here's the most important part of the error (I think):
It seems to me that the URL yarn cannot find and the one yarn suggests.. are exactly the same..
|
Here's me trying to add this pnp sandbox to our CI setup: |
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.
Great job @ndelangen 💪
Fixes: #20405
Add auto-detection for pnp mode in
storybook init
CLI.Also fix an critical issue where when pnp is enabled, the storybook CLI cannot find the renderer package; which it needs to copy templates from, into the user's newly created project, to serve as demo stories.
Related: (possibly fixes these)
#20861
#19764
#18626
#18625
#18435
#21004