Skip to content

Conversation

@UberMouse
Copy link
Contributor

Summary

  1. updates the heft-storybook-plugin to be compatible with storybook v9, this only required adapting to the bin change from an object pointing at different files depending on whether doing a watch/package build, to a single binary file for both
  2. updates the storybook build samples to storybook v9, I mostly did this to try and reproduce an issue at our work rush monorepo around storybook and watch mode, which turned out to be related to the heft-rspack-plugin instead
  3. added support for detecting the --serve flag when using the heft-rspack-plugin via the same method as the webpack plugins

Details

3 is not done correctly, when adding a dependency on the heft-rspack-plugin to import the same types as the heft-webpack plugins I started getting the following typescript errors

ncountered 3 errors
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/@[email protected]/node_modules/@rspack/core/dist/builtin-plugin/css-extract/index.d.ts:9:34 - (TS2304) Cannot find name 'HTMLLinkElement'.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack-dev-server/types/lib/Server.d.ts:1810:5 - (TS2717) Subsequent property declarations must have the same type.  Property 'devServer' must be of type 'DevServerConfiguration | undefined', but here has type 'DevServerConfiguration | undefined'.
 [build:typescript] /home/taylorl/code/rushstack/heft-plugins/heft-rspack-plugin/dist/heft-rspack-plugin.d.ts:13:10 - (TS2614) Module '"@rspack/core"' has no exported member 'rspackCore'. Did you mean to use 'import rspackCore from "@rspack/core"' instead?

I'm not really sure what is going on there, so I opted to just drop the dependency and work around the missing types. This was enough to generate a patch for our internal Rush monorepo which is what I am after.

How it was tested

Built the storybook sample project

Impacted documentation

I don't think so?

@github-project-automation github-project-automation bot moved this to Needs triage in Bug Triage Dec 9, 2025
@UberMouse UberMouse force-pushed the storybook-v9-support branch from a451802 to 14cc4e5 Compare December 9, 2025 02:00
@UberMouse UberMouse changed the title [heft] update storybook to be compatible with v9 [heft] update storybook plugin to be compatible with v9 Dec 9, 2025
Also adds support for serve mode detection when using the heft-rspack-plugin
@UberMouse UberMouse force-pushed the storybook-v9-support branch from 14cc4e5 to 5dbc106 Compare December 9, 2025 02:26
stories: ['../lib/**/*.stories.js'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials']
// naively referencing the name of the package causes storybook to fail to resolve it
framework: path.resolve(require.resolve('@storybook/react-webpack5/preset'), '..')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be a cleaner way to get the path of the package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to suggestions. I don't really understand what is going on here that the normal method of framework: "@storybook/react-webpack5" doesn't work. It fails to resolve the /preset import when storybook tries to import it.

"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"]
"target": "es2020",
"lib": ["es2020", "scripthost", "dom"],
"skipLibCheck": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's broken in dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ncountered 17 errors
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]._kkvcbkhogs6kgmxbas2whdvtne/node_modules/@storybook/react/dist/types-7abe74eb.d.ts:2:29 - (TS7016) Could not find a declaration file for module 'react-dom/client'. '/home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/react-dom@1
[email protected]/node_modules/react-dom/client.js' implicitly has an 'any' type.
 If the 'react-dom' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom'
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/common/index.d.ts:4:29 - (TS2307) Cannot find module 'node:fs' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/common/index.d.ts:5:24 - (TS2307) Cannot find module 'node:buffer' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/common/index.d.ts:6:30 - (TS2307) Cannot find module 'node:child_process' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/common/index.d.ts:7:44 - (TS2307) Cannot find module 'node:stream' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/common/index.d.ts:95:16 - (TS2304) Cannot find name 'BufferEncoding'.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/common/index.d.ts:311:24 - (TS2724) 'NodeJS' has no exported member named 'ProcessEnv'. Did you mean 'Process'?
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/router/index.d.ts:1:24 - (TS2307) Cannot find module 'react' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/router/index.d.ts:2:57 - (TS2307) Cannot find module 'react' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/theming/index.d.ts:1:26 - (TS2307) Cannot find module 'react' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/types/index.d.ts:3:64 - (TS2307) Cannot find module 'react' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/types/index.d.ts:9:57 - (TS2307) Cannot find module 'http' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/types/index.d.ts:10:36 - (TS2307) Cannot find module 'net' or its corresponding type declarations.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/types/index.d.ts:2236:43 - (TS2339) Property 'hrtime' does not exist on type 'Process'.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/types/index.d.ts:2317:46 - (TS2339) Property 'hrtime' does not exist on type 'Process'.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/types/index.d.ts:2323:46 - (TS2339) Property 'hrtime' does not exist on type 'Process'.
 [build:typescript] /home/taylorl/code/rushstack/common/temp/default/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/storybook/dist/types/index.d.ts:2328:46 - (TS2339) Property 'hrtime' does not exist on type 'Process'.```
 
 Assuming some node type mismatch, unclear on the react one. Didn't seem that important.

"^4.1.16"
]
],
"@types/react": ["~19.2.7"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just update the whole repo?

@iclanton iclanton moved this from Needs triage to In Progress in Bug Triage Dec 17, 2025
"extends": "./node_modules/local-web-rig/profiles/app/tsconfig-base.json"
"extends": "./node_modules/local-web-rig/profiles/app/tsconfig-base.json",
"compilerOptions": {
"skipLibCheck": true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting errors building in dependencies from some pnpm confusion around the new @types/react package

@UberMouse
Copy link
Contributor Author

hrm storybook v9 requires node v20+ so the node 18 CI matrix fails

@iclanton
Copy link
Member

@UberMouse - Node 18 entered EOL in April, so it may be okay to remove. @octogonz - will dropping Node 18 break your stuff?

@octogonz
Copy link
Collaborator

@UberMouse - Node 18 entered EOL in April, so it may be okay to remove. @octogonz - will dropping Node 18 break your stuff?

Yes, we still have some Rush repos that need to build with Node 18. :'(

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants