Skip to content

Docs: Update tsconfig.json diffs in addons migration guide#32922

Merged
jonniebigodes merged 4 commits into
storybookjs:nextfrom
Dschungelabenteuer:docs/addon-migration-guide-tsconfig
Nov 3, 2025
Merged

Docs: Update tsconfig.json diffs in addons migration guide#32922
jonniebigodes merged 4 commits into
storybookjs:nextfrom
Dschungelabenteuer:docs/addon-migration-guide-tsconfig

Conversation

@Dschungelabenteuer
Copy link
Copy Markdown
Member

@Dschungelabenteuer Dschungelabenteuer commented Nov 2, 2025

What I did

The addon migration guide for 10.x.x was very helpful and straightforward. However, it seems that diffs on the tsconfig.json file are based on changes that only occurred in the recent months (e.g. this commit that changes the module field from commonjs to Preserve ). Those changes do not appear in the diffs despite being quite important.

Some of the kit-based addons (if not most) are older than these few months, and I'd guess such addons still have outdated critical fields (like the module one I just mentioned). While debugging these missing changes was pretty quick and easy, it still felt like a small obstacle to the migration!

I think those small changes could help a bit with that migration. And as for the addons that were created within these few months (which I'm pretty sure are a smaller part of the whole ecosystem), they'd just have to ignore those diffs they already pulled!

Also please note:

  1. I've changed the evil ... with the actual because I'm an obsessed alt+0133 lad
  2. This PR includes a few EOL auto-changes based on the root Storybook prettier config,
  3. Viewing this PR's diffs may be a bit confusing since it includes "diffs" codeblocks that are themselves highlighted 🤯

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Well, I'll skip that part because… well… it's pure documentation :D

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Documentation

    • Updated addon migration guide to reflect ESM-first workflows, revised build/config recommendations, and new preset/loading patterns.
    • Clarified public exports and bundler entry expectations for addons and previews.
  • Refactor

    • Public API surface and loading behavior shifted to ES module outputs; local addon and preset loading now use ESM-oriented paths.

@Dschungelabenteuer Dschungelabenteuer changed the title Addons migration guide: update tsconfig.json diffs Docs: : update tsconfig.json diffs in addons migration guide Nov 2, 2025
@Dschungelabenteuer Dschungelabenteuer changed the title Docs: : update tsconfig.json diffs in addons migration guide Docs: update tsconfig.json diffs in addons migration guide Nov 2, 2025
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Nov 2, 2025

View your CI Pipeline Execution ↗ for commit 5b21b1c

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 45s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-03 17:46:13 UTC

@Dschungelabenteuer Dschungelabenteuer added ci:docs Run the CI jobs for documentation checks only. documentation labels Nov 2, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 2, 2025

📝 Walkthrough

Walkthrough

Documentation updated to reflect ESM-first addon migration: package.json exports reworked to ES module defaults including "./manager-helpers"; bundler config moves from exportEntries to managerEntries/previewEntries; presets and local addon loading converted to ESM (import.meta.resolve); TS/tsup build settings adjusted; CSF Factories/preview wrapping added.

Changes

Cohort / File(s) Change Summary
Addon Migration Guide
docs/addons/addon-migration-guide.mdx
Documented ESM-oriented migration: dynamic package.json import (type: "json"), removal of exportEntries in favor of managerEntries/previewEntries, ES module build output and externals, CSF Factories/definePreviewAddon flow and preview annotation wrapping, tsup/tsconfig changes (ESM targets, dts for preview), public exports updated (default ESM mapping, ./manager-helpers), local preset loading moved to ESM (.storybook/local-preset.ts, import.meta.resolve), and preset.js converted to ESM export.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Main as main.ts
  participant Resolver as import.meta.resolve
  participant LocalPreset as .storybook/local-preset.ts
  participant Build as Bundler (tsup)
  participant Runtime as Storybook (manager/preview)

  rect rgba(50,150,250,0.06)
  Main->>Resolver: resolve local preset path
  Resolver-->>Main: file URL
  Main->>LocalPreset: dynamic import (ESM)
  LocalPreset-->>Main: exports (managerEntries, previewEntries, manager-helpers)
  end

  rect rgba(50,200,100,0.06)
  Main->>Build: provide managerEntries & previewEntries (ESM outputs, externals)
  Build-->>Runtime: emit ES module artifacts (manager, preview, manager-helpers)
  Runtime->>Runtime: load ES module outputs at runtime
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to examples in docs/addons/addon-migration-guide.mdx for accurate code snippets (exports, import.meta.resolve usage, TS/tsup options).
  • Verify terminology and public exports (./manager-helpers, default ESM mappings) align with actual package outputs.

Possibly related PRs


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eae1882 and c3de55c.

📒 Files selected for processing (1)
  • docs/addons/addon-migration-guide.mdx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Update documentation under docs/ for significant changes, including migration guides for breaking changes

Files:

  • docs/addons/addon-migration-guide.mdx
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to docs/** : Update documentation under `docs/` for significant changes, including migration guides for breaking changes
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.
📚 Learning: 2025-09-24T09:39:39.233Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.

Applied to files:

  • docs/addons/addon-migration-guide.mdx
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to **/*.{ts,tsx,js,jsx,mjs} : Export functions from modules when they need to be unit-tested

Applied to files:

  • docs/addons/addon-migration-guide.mdx
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to **/tsconfig*.json : Keep TypeScript strict mode enabled in tsconfig (e.g., `"strict": true`)

Applied to files:

  • docs/addons/addon-migration-guide.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (7)
docs/addons/addon-migration-guide.mdx (7)

225-246: ✓ Excellent addition of missing tsconfig.json migration guidance.

The tsconfig.json diff now comprehensively covers the ESM-first requirements, including the previously omitted critical changes. The additions align with the addon-kit reference and address earlier feedback on "module": "preserve". All settings (bundler moduleResolution, preserve format, esnext target/lib, expanded rootDir, and tsup.config.ts inclusion) are correctly configured for Storybook 10's ESM-only build model.


101-116: ✓ Package.json loading updated correctly.

The shift from readFile-based sync parsing to dynamic import with { with: { type: "json" } } is modern, idiomatic ESM, and properly removes the now-unused BundlerConfig type and exportEntries handling.


69-197: ✓ tsup.config.ts migration guidance is comprehensive.

The diff properly documents the transition from exportEntries to managerEntries/previewEntries, removal of globalPackages externalization, platform/target simplifications, and dts handling. Comments explain the rationale (e.g., esnext targets since Storybook rebundles, browser platform focus). The removal of CJS format and splitting logic is clear.


250-256: ✓ Preset.js ESM conversion is properly documented.

The change from CJS module.exports to ESM export * correctly reflects that Storybook Node app now supports ESM. The comment explaining why the filename must remain preset.js (not .cjs) is helpful context.


265-284: ✓ Local addon loading guidance correctly uses import.meta.resolve.

The new .storybook/local-preset.ts example and updated main.ts addon reference properly demonstrate ESM-based relative path resolution. Using fileURLToPath(import.meta.resolve(...)) is the correct modern approach for addon loading without Node.js require.


295-302: ✓ CSF Factories integration guidance is clear.

The definePreviewAddon pattern is correctly documented with import from storybook/internal/csf. The example shows proper default export for CSF Next compatibility.


304-333: ✓ exportEntries removal and manager-helpers migration path is well-explained.

The rationale (exportEntries caused Node/browser compatibility confusion) is clearly stated. The alternative of moving src/index.ts to previewEntries and creating src/manager-helpers.ts for manager-side exports is a sound architectural improvement with a concrete example.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
docs/addons/addon-migration-guide.mdx (3)

118-131: Explain the splitting behavior change and its implications.

Line 120 changes splitting: false to splitting: true, which is a significant shift in bundler behavior. Splitting typically creates multiple output chunks rather than a single bundle, which can affect:

  • Bundle size per entry point
  • Loading patterns in the Storybook UI
  • Tree-shaking effectiveness

This change appears intentional and beneficial for ESM-only builds, but the documentation should clarify why splitting was enabled and what addon developers should expect. Consider adding a brief note explaining the performance or architectural rationale.


59-67: Clarify the relationship between the bundler config changes and build outputs.

The text on lines 62–67 summarizes key changes but could benefit from a brief note about the practical outcome: addon developers no longer need to maintain separate CJS and ESM bundles, reducing complexity. Additionally, the note on line 67 about switching from exportEntries to previewEntries/managerEntries is important, but the section title and intro (lines 58–60) could explicitly mention that this reconfigures where addon code gets bundled (browser vs. Node context), not just the build system.


304-333: Ensure the manager-helpers export example is consistent with the broader bundler changes.

The optional section on removal of exportEntries (lines 304–333) provides a helpful pattern for exporting manager-specific code via a new src/manager-helpers.ts file. This is well-explained, but consider adding a cross-reference or note that this approach mirrors the pattern shown earlier in the tsup.config.ts diff (lines 152–165), where manager entries are compiled separately with platform: "browser".

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03cae6b and eae1882.

📒 Files selected for processing (1)
  • docs/addons/addon-migration-guide.mdx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Update documentation under docs/ for significant changes, including migration guides for breaking changes

Files:

  • docs/addons/addon-migration-guide.mdx
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to docs/** : Update documentation under `docs/` for significant changes, including migration guides for breaking changes
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to docs/** : Update documentation under `docs/` for significant changes, including migration guides for breaking changes

Applied to files:

  • docs/addons/addon-migration-guide.mdx
📚 Learning: 2025-09-24T09:39:39.233Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.

Applied to files:

  • docs/addons/addon-migration-guide.mdx
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to **/*.{ts,tsx,js,jsx,mjs} : Export functions from modules when they need to be unit-tested

Applied to files:

  • docs/addons/addon-migration-guide.mdx
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to **/tsconfig*.json : Keep TypeScript strict mode enabled in tsconfig (e.g., `"strict": true`)

Applied to files:

  • docs/addons/addon-migration-guide.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Danger JS
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (3)
docs/addons/addon-migration-guide.mdx (3)

225-246: Verify TypeScript configuration values and document implications of rootDir change.

The tsconfig.json diff shows several changes that appear correct for ESM:

  • "moduleResolution": "bundler" and "module": "Preserve" correctly preserve ES module semantics
  • "target": "esnext" and "lib": ["esnext", ...] align with ESM re-bundling by downstream tools

However, a few points warrant verification:

  1. Capitalization: "module": "Preserve" uses capital P. Verify this matches the exact TypeScript compiler option (it should be "Preserve", not "preserve").

  2. rootDir implication: Changing from "./src" to "." affects TypeScript's understanding of the project structure. Since tsup.config.ts is now included in the TypeScript compilation via the include array, ensure this doesn't inadvertently pull in unwanted files (e.g., node_modules, dist output, test files). Consider whether you need to add an explicit "exclude" array to the tsconfig for safety.


362-366: Verify the addon-kit PR reference and ensure it remains valid as the guide evolves.

Line 364 references the addon-kit migration PR (#82) as a complete example. While this is helpful, consider:

  1. Confirming the PR link is stable and accessible.
  2. Adding a note (e.g., in a Callout) indicating that the addon-kit may receive additional updates post-Storybook 10 release, so developers should refer to the latest main branch for the most current reference implementation.

1-366: Documentation structure and migration clarity are strong; minor enhancements suggested above.

Overall, the migration guide is comprehensive and well-organized. The progression from dependency updates → build configuration → local loading covers the essential steps. The diffs are clear and use proper syntax highlighting. The explanatory text between diffs helps orient readers. The recommended optional changes provide a clear path for incremental adoption.

As per coding guidelines, documentation under docs/ for significant changes and migration guides has been properly updated to reflect the shift from CJS to ESM in the Storybook addon build pipeline.

Comment thread docs/addons/addon-migration-guide.mdx Outdated
Copy link
Copy Markdown
Member

@Sidnioulz Sidnioulz left a comment

Choose a reason for hiding this comment

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

Thanks @Dschungelabenteuer :) Good catch

Let's maybe keep "..." as it is, or also adjust tsup diffs in the guide. In any case @jonniebigodes @kylegach feel free to merge this as it is!

@jonniebigodes jonniebigodes changed the title Docs: update tsconfig.json diffs in addons migration guide Docs: Update tsconfig.json diffs in addons migration guide Nov 3, 2025
@jonniebigodes
Copy link
Copy Markdown
Contributor

Merging this. The unit test issues are unrelated to this pull request, as this is a documentation-only change. @Sidnioulz appreciate the review on it and @Dschungelabenteuer for the time you took to help us with the documentation 🙏

@jonniebigodes jonniebigodes merged commit c8fd17d into storybookjs:next Nov 3, 2025
8 of 10 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 4, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:docs Run the CI jobs for documentation checks only. documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants