Skip to content

Storybook generator produces a non-working example #252

@intellix

Description

@intellix

Current Behavior

When you generate a new project and add storybook, it throws an error. If you patch storybook-framework-qwik to fix the initial module error, then you continue with more of the same.

Expected Behavior

I guess it should work out of the box

GitHub Repo

No response

Steps to Reproduce

Run:

pnpx create-nx-workspace@latest project --preset=qwik-nx
pnpx nx generate qwik-nx:storybook-configuration
pnpm nx run whatever:storybook

Nx Report

Node           : 20.19.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.7.1

nx                 : 21.1.2
@nx/js             : 21.1.2
@nx/eslint         : 21.1.2
@nx/workspace      : 21.1.2
@nx/cypress        : 21.1.2
@nx/devkit         : 21.1.2
@nx/eslint-plugin  : 21.1.2
@nx/storybook      : 21.1.2
@nx/vite           : 21.1.2
@nx/web            : 21.1.2
typescript         : 5.7.3
---------------------------------------
Community plugins:
qwik-nx : 3.2.0

Failure Logs

npx nx run whatever:storybook
npm warn Unknown project config "strict-peer-dependencies". This will stop working in the next major version of npm.
npm warn Unknown project config "auto-install-peers". This will stop working in the next major version of npm.

> nx run whatever:storybook

WARN   Failed to load preset: {"type":"presets","name":"/Projects/project/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@[email protected]_dd729897924663033df5070a944c112d/node_modules/storybook-framework-qwik/preset.js"}
ReferenceError: module is not defined
    at file://./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@[email protected]_dd729897924663033df5070a944c112d/node_modules/storybook-framework-qwik/preset.js:2:1
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:387:35)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:323:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1371:24)
    at Module._compile (node:internal/modules/cjs/loader:1511:5)
    at Module._extensions..js (node:internal/modules/cjs/loader:1572:16)
    at Object.newLoader (./node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-register/dist/node.js:2262:9)
    at extensions..js (./node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-register/dist/node.js:4833:24)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Module._load (node:internal/modules/cjs/loader:1096:12)
info => Starting manager..
WARN No story files found for the specified pattern: apps/whatever/**/*.stories.mdx
WARN No story files found for the specified pattern: apps/whatever/**/*.stories.@(js|jsx|ts|tsx)
info => Starting preview..
using deprecated parameters for the initialization function; pass a single object instead
1:32:01 PM [vite] (client) Re-optimizing dependencies because lockfile has changed
╭───────────────────────────────────────────────────────────╮
│                                                           │
│   Storybook 8.6.14 for storybook-framework-qwik started   │
│   57 ms for manager and 775 ms for preview                │
│                                                           │
│    Local:            http://localhost:4400/               │
│    On your network:  http://192.168.0.96:4400/            │
│                                                           │
╰───────────────────────────────────────────────────────────╯

  🚧 Please note that development mode is slower than production.
1:32:02 PM [vite] (ssr) Error when evaluating SSR module /Projects/project/apps/whatever/src/routes/layout.tsx: window is not defined
      at eval (/Projects/project/apps/whatever/src/components/icons/qwik.tsx:35:12)
      at async ESModulesEvaluator.runInlinedModule (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/module-runner.js:1062:5)
      at async SSRCompatModuleRunner.directRequest (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/module-runner.js:1284:61)
      at async SSRCompatModuleRunner.directRequest (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:25274:23)
      at async SSRCompatModuleRunner.cachedRequest (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/module-runner.js:1180:76)
      at async eval (/Projects/project/apps/whatever/src/components/header/header.tsx:2:1)
      at async ESModulesEvaluator.runInlinedModule (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/module-runner.js:1062:5)
      at async SSRCompatModuleRunner.directRequest (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/module-runner.js:1284:61)
      at async SSRCompatModuleRunner.directRequest (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:25274:23)
      at async SSRCompatModuleRunner.cachedRequest (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/module-runner.js:1180:76)
file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:5026
        throw new Error(LINE_GTR_ZERO);
              ^

Error: `line` must be greater than 0 (lines start at line 1)
    at originalPositionFor$1 (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:5026:15)
    at file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:25085:21
    at String.replace (<anonymous>)
    at file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:25075:17
    at Array.map (<anonymous>)
    at ssrRewriteStacktrace (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:25074:28)
    at ssrFixStacktrace (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:25125:22)
    at Proxy.ssrFixStacktrace (file:///Projects/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:38480:7)
    at /Projects/project/node_modules/.pnpm/@[email protected][email protected][email protected][email protected][email protected]_@ty_20665a7b463f83b68e4068e04c3d8332/node_modules/@builder.io/qwik-city/lib/vite/index.cjs:26391:14

Node.js v20.19.0

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions