Skip to content
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]: Webpack fsCache does not work with @storybook/nextjs framework #29621

Closed
sentience opened this issue Nov 15, 2024 · 0 comments · Fixed by #29654
Closed

[Bug]: Webpack fsCache does not work with @storybook/nextjs framework #29621

sentience opened this issue Nov 15, 2024 · 0 comments · Fixed by #29654

Comments

@sentience
Copy link
Contributor

sentience commented Nov 15, 2024

Describe the bug

The Storybook Next.js framework uses webpack internally to build Storybooks for Next.js projects.

The Storybook webpack builder supports an fsCache option to enable disk-based caching, which greatly improves incremental build performance in webpack-based Storybook projects.

When the fsCache option is enabled in a Storybook project that uses the Next.js framework, however, the disk-based cache does not work, and the Storybook build outputs a large number of webpack.cache.packFileCacheStrategy warnings. As a result, Next.js projects cannot benefit from the significant speed boost afforded by the webpack disk cache.

Storybook config

import { StorybookConfig } from "@storybook/nextjs"

export default {
  stories: ["../example/**/*.stories.(ts|tsx)"],
  framework: {
    name: "@storybook/nextjs",
    options: {
      builder: {
        fsCache: true,
      },
    },
  },
  addons: [],
} satisfies StorybookConfig

Reproduction link

https://github.com/sentience/storybook-nextjs-webpack-cache-issue-demo

Reproduction steps

  1. git clone https://github.com/sentience/storybook-nextjs-webpack-cache-issue-demo.git
  2. cd storybook-nextjs-webpack-cache-issue-demo
  3. pnpm i
  4. pnpm storybook dev

System

Storybook Environment Info:

  System:
    OS: macOS 15.1
    CPU: (8) arm64 Apple M1
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.1 - ~/Developer/storybook-nextjs-webpack-cache-issue-demo/.devbox/nix/profile/default/bin/node
    Yarn: 1.22.22 - ~/Developer/storybook-nextjs-webpack-cache-issue-demo/.devbox/virtenv/nodejs/corepack-bin/yarn
    npm: 10.2.4 - ~/Developer/storybook-nextjs-webpack-cache-issue-demo/.devbox/nix/profile/default/bin/npm
    pnpm: 9.12.3 - ~/Developer/storybook-nextjs-webpack-cache-issue-demo/.devbox/virtenv/nodejs/corepack-bin/pnpm <----- active
  Browsers:
    Chrome: 130.0.6723.119
    Safari: 18.1
  npmPackages:
    @storybook/global: ^5.0.0 => 5.0.0 
    @storybook/nextjs: ^8.4.3 => 8.4.3 
    @storybook/types: ^8.4.3 => 8.4.3 
    storybook: ^8.4.3 => 8.4.3

Additional context

This problem seems to have existed since the introduction of @storybook/nextjs in Storybook 8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants