Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextjs-Vite: Add TS docgen support #29824

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Dec 5, 2024

Closes storybookjs/vite-plugin-storybook-nextjs#22

What I did

This PR modifies the experimental-nextjs-vite framework to support react-docgen-typescript. It does so by adding react-vite as a dependency, similarly to how it was done in react-native-web-vite.

before:
image

after:
image

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

Make a sandbox and add this to its main.js:

  typescript: {
    reactDocgen: 'react-docgen-typescript'
  },

Then look at stories which should contain richer docgen metadata

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 pull request has been released as version 0.0.0-pr-29824-sha-bac7061d. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-29824-sha-bac7061d
Triggered by @yannbf
Repository storybookjs/storybook
Branch yann/add-ts-docgen-support-next-vite
Commit bac7061d
Datetime Thu Dec 5 15:08:51 UTC 2024 (1733411331)
Workflow run 12182518539

To request a new release of this pull request, mention the @storybookjs/core team.

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

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 292 B 1.75 0%
initSize 130 MB 130 MB 449 B 1.02 0%
diffSize 52.4 MB 52.4 MB 157 B 0.12 0%
buildSize 6.75 MB 6.75 MB 0 B -0.73 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B - 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 0 B 1.11 0%
buildSbPreviewSize 0 B 0 B 0 B -0.73 -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.57 MB 3.57 MB 0 B -0.73 0%
buildPreviewSize 3.19 MB 3.19 MB 0 B 0.73 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 6.9s 11.9s 5s -0.41 42.2%
generateTime 21.6s 22.4s 869ms 1.53 3.9%
initTime 14.8s 15.1s 255ms 0.75 1.7%
buildTime 8.5s 11.2s 2.7s 2.01 🔺24.3%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5s 6s 970ms 1.46 🔺16.1%
devManagerResponsive 3.8s 4.1s 319ms 0.92 7.7%
devManagerHeaderVisible 539ms 927ms 388ms 3.95 🔺41.9%
devManagerIndexVisible 610ms 938ms 328ms 3.04 🔺35%
devStoryVisibleUncached 1.6s 1.7s 46ms -0.29 2.7%
devStoryVisible 607ms 1s 422ms 3.66 🔺41%
devAutodocsVisible 484ms 716ms 232ms 2.45 🔺32.4%
devMDXVisible 509ms 706ms 197ms 1.85 🔺27.9%
buildManagerHeaderVisible 618ms 744ms 126ms 1.22 16.9%
buildManagerIndexVisible 693ms 833ms 140ms 1.3 🔺16.8%
buildStoryVisible 556ms 675ms 119ms 0.99 17.6%
buildAutodocsVisible 418ms 1s 593ms 6.61 🔺58.7%
buildMDXVisible 436ms 590ms 154ms 1.81 🔺26.1%

Greptile Summary

Based on the provided files and context, I'll create a concise summary of the key changes in this pull request:

Adds TypeScript documentation generation (docgen) support to the experimental Next.js Vite framework by leveraging existing react-vite functionality.

  • Modified experimental-nextjs-vite/preset.ts to use reactViteFinal from @storybook/react-vite/preset for TypeScript docgen support
  • Added @storybook/react-vite as a dependency in experimental-nextjs-vite/package.json to enable docgen functionality
  • Updated plugin handling in react-vite/preset.ts to properly integrate react-docgen-typescript via @joshwooding/vite-plugin-react-docgen-typescript
  • Configured docgen plugin to save prop values as strings for compatibility with react-docgen format

@yannbf yannbf added feature request nextjs ci:merged Run the CI jobs that normally run when merged. docgen labels Dec 5, 2024
@yannbf yannbf self-assigned this Dec 5, 2024
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

LGTM

5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

nx-cloud bot commented Dec 5, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit bac7061. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@shilman shilman changed the title Nextjs: Add TS docgen support for Vite implementation Nextjs-Vite: Add TS docgen support Dec 5, 2024
@yannbf yannbf added ci:merged Run the CI jobs that normally run when merged. and removed ci:merged Run the CI jobs that normally run when merged. labels Dec 5, 2024
@storybook-pr-benchmarking
Copy link

Package Benchmarks

Commit: bac7061, ran on 5 December 2024 at 17:24:21 UTC

The following packages have significant changes to their size or dependencies:

@storybook/experimental-nextjs-vite

Before After Difference
Dependency count 87 153 🚨 +66 🚨
Self size 231 KB 231 KB 🚨 +152 B 🚨
Dependency size 31.28 MB 44.37 MB 🚨 +13.09 MB 🚨
Bundle Size Analyzer Link Link

@RicardoAvans
Copy link

Would love to see this merged because I can't get it to work with the main experimental-nextjs-vite plugin and react-docgen-typescript plugin.

@yannbf yannbf merged commit c2ab01c into next Dec 12, 2024
78 of 81 checks passed
@yannbf yannbf deleted the yann/add-ts-docgen-support-next-vite branch December 12, 2024 11:23
@yannbf yannbf added needs qa Indicates that this needs manual QA during the upcoming minor/major release and removed needs qa Indicates that this needs manual QA during the upcoming minor/major release labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:merged Run the CI jobs that normally run when merged. docgen feature request nextjs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do you plan on supporting docgen / react-typescript-docgen
3 participants