Replies: 2 comments
|
The "memo is not defined" error in production with Storybook v10 and Next.js 16 is often caused by differences in how dependencies or modules are bundled for production vs. local dev. Here’s a focused checklist to help you resolve it:
If the error persists, please share your To reply, just mention @dosu. Docs are dead. Just use Dosu. |
|
Ran into this as well when attempting to upgrade to Next 16 and Storybook 10.5.8 with the You may try simply switching to the @storybook/nextjs-vite config, and see if that works. In our case, Claude managed to figure out a fix by adding this in our config webpackFinal: async storybookConfig => {
/**
* Disable webpack's inner-module tree shaking for the production build.
*
* `storybook/dist/components/index.js` is one large esbuild bundle. webpack's
* `innerGraph` analysis wrongly decides some of its React imports are unused and
* strips them, leaving declarations that still reference them:
*
* var TabErrorBoundary = class extends (\/* unused pure expression or super *\/ null && (Component2)) {
* ... Tabs = memo(...) // `memo` binding removed
*
* At runtime every Storybook docs page then dies with
* `ReferenceError: memo is not defined`, while stories render fine. It only
* affects `build-storybook`, because `innerGraph` is a production-only
* optimization — which is why `npm run storybook` looks healthy.
*
* Storybook's shipped source is correct (it does import `memo` and `Component`),
* so this is a bundling bug, not a Storybook packaging bug. Re-check on future
* Storybook/webpack upgrades and drop this when it is no longer needed.
*/
storybookConfig.optimization = storybookConfig.optimization || {}
storybookConfig.optimization.innerGraph = false
} |
Uh oh!
There was an error while loading. Please reload this page.
Summary
I'm migrating to Storybook v10 on Next.js v16, and it works locally, but on production all stories give the following error:
I can't find any previous references of this.
Additional information
No response
Create a reproduction
No response
All reactions