-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Bug]: handlebars
encodes =
character in patched pnpm dependency, breaks preview annotations in @storybook/builder-webpack5
#22828
Comments
Hi @askoufis this is a pretty specific edge case. Any idea what we could change on the Storybook side to fix it? |
You're right, it is quite specific. However, I think there are a few potential options to fix this:
Luckily this appears to be the only place where |
How is it going? any update?? facing the same issue |
Also facing |
Was facing the same issue, fixed it with another patch. Patch command:
In file
With that:
In file
With that:
|
After upgrading my reproduction to the latest prerelease version (8.4.0-alpha.6 at time of writing) the bug appears to be fixed. I'm guessing #29208 fixed the issue as @shilman Should I close this issue even though the fix hasn't be released in a stable version, or should it be kept open until 8.4.0 is released? |
Thanks for following up on this @askoufis ! Let's close it as fixed. The fix is available in an alpha today and will be stable in a few weeks. |
Describe the bug
PNPM injects a hash containing an
=
to the file path of patched dependencies, this looks something like_patch_hash=xpvpw3nxoacxewbpf6zgrfgd4u_
.handlebars
encodes this=
to=
. AFAIK this is an intentional feature of handlebars.js, you can verify this in the handlebars playground by putting an=
in the input. This encoded character causes webpack to fail to resolvepreviewAnnotations
that are injected viahandlebars
. This becomes an issue if you happen to havepnpm patch
ed a dependency that contains a preview annotation.Relevant code:
storybook/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts
Lines 133 to 144 in fc3b4b7
Maybe you've patched an addon's preview annotation, or in my case we're symlinking the user's
.storybook/preview.js
file to a storybook config folder controlled by our framework (which users install as a dependency in their project). We do this because we have a pretty involved webpack config that we need to inject into storybook's webpack config, so we maintain control overmain.js
, while allowing users to provide their ownpreview.js
.You could argue a few things here:
=
in paths isn't great (IMO), but I'm sure there's a reason for ithandlebars
encoding some characters for you makes it unfit for this specific purpose. You already double escape\
anyway, so what's one more tweak to the handlebars output.To Reproduce
pnpm install
pnpm run storybook
. Webpack can't resolve the file, storybook crashes.@storybook/addon-interactions
):git checkout 1ac0916b180e505d3c281e8b301027d99a9a30c5
pnpm install
pnpm run storybook
. Storybook works fine.System
Additional context
No response
The text was updated successfully, but these errors were encountered: