qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[🐞] Storybook integration not working

Open ardiansah47 opened this issue 1 year ago • 7 comments

Which component is affected?

Starters / CLI

Describe the bug

I installed the fresh qwik project and I want to add the storybook integration to my project, but when I try it fails to run, and shows this error message: SB_CORE-SERVER_0002 (CriticalPresetLoadError): Storybook failed to load the following preset: storybook-framework-qwik/preset.

can you guys take a look? thank you! @manucorporat @igorbabko

Reproduction

https://github.com/ardiansah47/qwik-storybook

Steps to reproduce

  1. Clone the project
  2. Run pnpm install
  3. Then run pnpm storybook

System Info

System:
    OS: macOS 15.3
    CPU: (8) arm64 Apple M3
    Memory: 249.25 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.5.0 - ~/.nvm/versions/node/v23.5.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v23.5.0/bin/npm
    pnpm: 9.15.3 - /opt/homebrew/bin/pnpm
  Browsers:
    Brave Browser: 132.1.74.51
    Chrome: 133.0.6943.53
    Safari: 18.3
  npmPackages:
    @builder.io/qwik: ^1.12.0 => 1.12.0 
    @builder.io/qwik-city: ^1.12.0 => 1.12.0 
    typescript: 5.4.5 => 5.4.5 
    undici: * => 7.3.0 
    vite: 5.3.5 => 5.3.5

Additional Information

Here the images that show the console when you try to run the storybook Image

ardiansah47 avatar Feb 08 '25 14:02 ardiansah47

Hello @ardiansah47 I have the same issue. Did you find a solution?

marloneth avatar Feb 28 '25 15:02 marloneth

Hi! @marloneth I haven’t found a solution yet, but I’ll update here if I do!

ardiansah47 avatar Feb 28 '25 15:02 ardiansah47

My understanding is the line of code failing is coming from a different repository entirely, a project maintained by a community member

https://github.com/literalpie/storybook-framework-qwik/blob/0d237ce4e849d0f3f4e62bd4c006b7dffe888a76/packages/storybook-framework-qwik/src/preset.ts#L7

I was able to reproduce the same problem with a brand new qwik project.

mkdir reproduce-7325
cd reproduce-7325
npm init -y
npm run create qwik@latest
npm run qwik add storybook
npm run storybook

I was able to get storybook working by editing the node_modules/storybook-framework-qwik/dist/preset.js

--- a/preset.js
+++ b/preset.js
@@ -3,6 +3,8 @@ import { mergeConfig } from "vite";
 import { QWIK_LOADER } from "@builder.io/qwik/loader";
 import { qwikDocgen } from "./docs/qwik-docgen.js";
 import { dirname, join } from "path";
+import { createRequire } from "module";
+const require = createRequire(import.meta.url);
 const wrapForPnP = (input) => dirname(require.resolve(join(input, "package.json")));

This makes me believe the problem comes from trying to use CommonJS inside an ESM module.

GrocerPublishAgent avatar Mar 10 '25 18:03 GrocerPublishAgent

Indeed this is a third-party problem. One solution would be to create a pnpm patch for it in the adder, but it would be best if @literalpie accepts the PR and crafts a new release

wmertens avatar Apr 03 '25 12:04 wmertens

Sorry for being a bottleneck. 0.4.2 has been released with the possible fix

literalpie avatar Apr 03 '25 23:04 literalpie

commented on https://github.com/literalpie/storybook-framework-qwik/pull/80

But also sharing here that it is still not working. It looks like build for storybook-framework-qwik may not have worked, the published version of the js does not have the fix:

package preset.js from:

https://unpkg.com/[email protected]/dist/preset.js

import { mergeConfig } from "vite";
import { QWIK_LOADER } from "@builder.io/qwik/loader";
import { qwikDocgen } from "./docs/qwik-docgen.js";
import { dirname, join } from "path";
const wrapForPnP = (input) => dirname(require.resolve(join(input, "package.json")));

evanzedex avatar May 22 '25 19:05 evanzedex

I'm going to close this here because we can't do anything about this

wmertens avatar Aug 06 '25 07:08 wmertens