diff --git a/tools/local-tests/storybook-blocks/blocks-original.ts b/tools/local-tests/storybook-blocks/blocks-original.ts index 39032a31..74544ec2 100644 --- a/tools/local-tests/storybook-blocks/blocks-original.ts +++ b/tools/local-tests/storybook-blocks/blocks-original.ts @@ -1,2 +1,2 @@ -export const PureArgsTable = () => ({ kind: 'pure' }); -export const Other = 1; +export const PureArgsTable = () => ({ kind: 'pure' }) +export const Other = 1 diff --git a/tools/local-tests/storybook-blocks/blocks-reexport.ts b/tools/local-tests/storybook-blocks/blocks-reexport.ts index a072fc6f..0cf29b41 100644 --- a/tools/local-tests/storybook-blocks/blocks-reexport.ts +++ b/tools/local-tests/storybook-blocks/blocks-reexport.ts @@ -1,3 +1,3 @@ -export * from './blocks-original'; +export * from './blocks-original' // Re-export with a from-clause so the alias is applied to the external export -export { PureArgsTable as ArgsTable } from './blocks-original'; +export { PureArgsTable as ArgsTable } from './blocks-original' diff --git a/tools/local-tests/storybook-blocks/blocks.test.ts b/tools/local-tests/storybook-blocks/blocks.test.ts index 30662443..16ada109 100644 --- a/tools/local-tests/storybook-blocks/blocks.test.ts +++ b/tools/local-tests/storybook-blocks/blocks.test.ts @@ -1,14 +1,14 @@ -import * as blocks from './blocks-reexport'; +import * as blocks from './blocks-reexport' describe('local simulation: blocks re-export', () => { test('exports ArgsTable', () => { // debug dump // eslint-disable-next-line no-console - console.log('DEBUG blocks exports:', Object.keys(blocks)); - expect(blocks.ArgsTable).toBeDefined(); - }); + console.log('DEBUG blocks exports:', Object.keys(blocks)) + expect(blocks.ArgsTable).toBeDefined() + }) test('ArgsTable equals PureArgsTable', () => { - expect(blocks.ArgsTable).toBe(blocks.PureArgsTable); - }); -}); + expect(blocks.ArgsTable).toBe(blocks.PureArgsTable) + }) +}) diff --git a/tools/patches/PR_DESCRIPTION.md b/tools/patches/PR_DESCRIPTION.md index e4eb73e0..fd73a4e6 100644 --- a/tools/patches/PR_DESCRIPTION.md +++ b/tools/patches/PR_DESCRIPTION.md @@ -1,33 +1,33 @@ PR: re-export `ArgsTable` from `@storybook/addon-docs/blocks` -Summary -------- +## Summary + This small change re-exports the existing `PureArgsTable` implementation as a stable named export `ArgsTable` from `code/addons/docs/src/blocks.ts`. -Rationale ---------- +## Rationale + - Some bundlers / pre-bundlers (for example Vite optimizeDeps) can alter the compiled modules and effectively remove/change named exports consumers expect, resulting in runtime errors like: - ``Error: The requested module '.../blocks.js' does not provide an export named 'ArgsTable'`` + `Error: The requested module '.../blocks.js' does not provide an export named 'ArgsTable'` - Storybook currently exports an equivalent implementation under a different name (`PureArgsTable`). Re-exporting it under `ArgsTable` restores compatibility with MDX files and third-party docs that import `ArgsTable` directly. -Change ------- +## Change + - Add a single line: `export { PureArgsTable as ArgsTable }` in `code/addons/docs/src/blocks.ts` (or the corresponding entry point that builds `blocks` bundle). -Notes / Alternatives --------------------- +## Notes / Alternatives + - Alternatively, we could update the package exports map or build step to guarantee `ArgsTable` is exported explicitly from the built artifact. This PR picks the smallest non-breaking change that is easy to review and test. -Testing -------- +## Testing + - Unit tests for docs blocks should continue to pass. - Added unit test: `code/addons/docs/src/__tests__/blocks.test.ts` — asserts `ArgsTable` is exported and is an alias of `PureArgsTable`. - Manual verification: build with Vite and run Storybook + MDX that imports `ArgsTable` to ensure runtime import succeeds. -Changelog ---------- +## Changelog + - Fix: re-export `ArgsTable` from `@storybook/addon-docs/blocks` to restore compatibility with imports that expect the named export. -Request -------- +## Request + If maintainers are okay with this approach, I can open a formal PR against Storybook with the change, tests and a short changelog entry.