storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.69k stars 9.32k forks source link

[Bug]: >= v8.2.0 Storybook versions no longer splits the sb-manager into chunks #29035

Open ashleyyy94 opened 2 months ago

ashleyyy94 commented 2 months ago

Describe the bug

After upgrading from 8.1.11 to 8.2 onwards, I noticed that sb-manager files no longer gets split into chunks by webpackFinal's configurations: config.optimization = { ...config.optimization, splitChunks: { chunks: 'all', maxInitialRequests: Infinity, minSize: 30 * 1024, maxSize: 500 * 1024, }, };

Reproduction link

https://stackblitz.com/edit/github-xmmg5f?file=.storybook%2Fmain.ts

Reproduction steps

  1. Initiate a new project using react-webpack5 as the framework.
  2. run npm run build-storybook
  3. Inside storybook-static/sb-manager, the js files are not split into chunks.
  4. Expected to be split as of 8.1.11

System

Storybook Environment Info:

  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm <----- active
  Browsers:
    Chrome: 128.0.6613.114
    Safari: 17.6
  npmPackages:
    @storybook/addon-essentials: ^8.2.9 => 8.2.9 
    @storybook/addon-interactions: ^8.2.9 => 8.2.9 
    @storybook/addon-links: ^8.2.9 => 8.2.9 
    @storybook/addon-styling-webpack: ^1.0.0 => 1.0.0 
    @storybook/addon-themes: ^8.2.9 => 8.2.9 
    @storybook/addon-webpack5-compiler-swc: ^1.0.5 => 1.0.5 
    @storybook/blocks: ^8.2.9 => 8.2.9 
    @storybook/react: ^8.2.9 => 8.2.9 
    @storybook/react-webpack5: ^8.2.9 => 8.2.9 
    @storybook/test: ^8.2.9 => 8.2.9 
    storybook: ^8.2.9 => 8.2.9

Additional context

No response

ashleyyy94 commented 4 days ago

Hi! Any update on this issue? This is still occurring on 8.4.2 last I checked, thanks!

valentinpalkovic commented 4 days ago

Manager assets are not built via webpack, but with esbuild instead, if I am correct. Therefore, whether the manager produces chunks or not is and was not really configurable in Storybook 7 and 8.

@ndelangen Did we change something in emitting manager files?

@ashleyyy94 Do you have any issues with bigger sb-manager file outputs?

ashleyyy94 commented 4 days ago

Hi @valentinpalkovic, it does appear to be configurable though when we add/remove webpackFinal's configurations. Produces chunks when we add. And does not produce chunks when removed.

The issue we are facing is due to the size of the js files in sb-manager. We're using AWS Lambda to serve out Storybook and the response size limit is 2MB.