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

Vue: Properly resolve Vite plugin #29795

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Conversation

tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Dec 4, 2024

What I did

Currently, the vue preset adds storybook:vue-template-compilation as unresolved Promise<Plugin>. This leads to memory issues downstream as analyzed in nuxt-modules/storybook#740 (comment). This is fixed by awating the promise. Also changed the types of the plugin array to the stronger Plugin type, which doesn't admit promises to prevent this from reaccouring the future.

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

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

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/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 canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 2.48 kB 2.7 0%
initSize 130 MB 130 MB 1.27 kB 0.87 0%
diffSize 52.4 MB 52.4 MB -1.21 kB -0.12 0%
buildSize 6.75 MB 6.75 MB -108 B -1 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 -108 B -0.56 0%
buildSbPreviewSize 0 B 0 B 0 B -1 -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.57 MB 3.56 MB -108 B -1 0%
buildPreviewSize 3.19 MB 3.19 MB 0 B 1 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 13.1s 24.8s 11.7s 1.05 47.1%
generateTime 19.2s 20.7s 1.5s 0.18 7.3%
initTime 13s 13.5s 545ms -0.04 4%
buildTime 9.3s 9.1s -223ms -0.12 -2.4%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.6s 4.7s -863ms -0.85 -18.2%
devManagerResponsive 3.8s 3.6s -194ms -0.3 -5.3%
devManagerHeaderVisible 562ms 555ms -7ms -0.44 -1.3%
devManagerIndexVisible 593ms 591ms -2ms -0.82 -0.3%
devStoryVisibleUncached 1.8s 1.4s -384ms -1.52 🔰-26.2%
devStoryVisible 595ms 585ms -10ms -0.78 -1.7%
devAutodocsVisible 555ms 482ms -73ms -0.86 -15.1%
devMDXVisible 555ms 541ms -14ms -0.07 -2.6%
buildManagerHeaderVisible 559ms 537ms -22ms -0.53 -4.1%
buildManagerIndexVisible 636ms 628ms -8ms -0.22 -1.3%
buildStoryVisible 500ms 495ms -5ms -0.68 -1%
buildAutodocsVisible 448ms 400ms -48ms -0.82 -12%
buildMDXVisible 424ms 464ms 40ms -0.05 8.6%

Greptile Summary

Fixes memory issues in Vue's Vite plugin system by properly resolving plugin promises and enforcing stricter typing for plugin arrays.

  • Changed storybookVuePlugin in code/frameworks/vue3-vite/src/vite-plugin.ts to properly await plugin promises
  • Updated plugin array type from PluginOption[] to stricter Plugin[] type in code/frameworks/vue3-vite/src/preset.ts
  • Added proper type annotations for templateCompilation function in code/frameworks/vue3-vite/src/plugins/vue-template.ts
  • Strengthened plugin type definitions across vue-docgen and vue-component-meta plugins

💡 (4/5) You can add custom instructions or style guidelines for the bot here!

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

@tobiasdiez tobiasdiez mentioned this pull request Dec 4, 2024
8 tasks
Copy link

nx-cloud bot commented Dec 4, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 517dba5. 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 1 target

Sent with 💌 from NxCloud.

Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1,6 +1,6 @@
import type { Plugin } from 'vite';

export async function templateCompilation() {
export async function templateCompilation(): Promise<Plugin> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually don't see a reason for this to be a promise in the first place cc @yannbf ?

Copy link
Member

Choose a reason for hiding this comment

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

There is no reason. The others were needed because they do dynamic imports, but this one seems simple enough

@storybook-pr-benchmarking
Copy link

Package Benchmarks

Commit: 517dba5, ran on 4 December 2024 at 23:05:58 UTC

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

@storybook/experimental-addon-test

Before After Difference
Dependency count 61 61 0
Self size 916 KB 695 KB 🎉 -221 KB 🎉
Dependency size 13.86 MB 13.86 MB 0 B
Bundle Size Analyzer Link Link

@yannbf yannbf changed the title Vue: properly resolve vite plugin Vue: Properly resolve Vite plugin Dec 5, 2024
@yannbf yannbf merged commit f25b824 into storybookjs:next Dec 5, 2024
63 of 71 checks passed
@github-actions github-actions bot mentioned this pull request Dec 5, 2024
11 tasks
@yannbf yannbf added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Dec 5, 2024
@github-actions github-actions bot mentioned this pull request Dec 5, 2024
8 tasks
@tobiasdiez tobiasdiez deleted the plugin-promise branch December 5, 2024 15:32
yannbf added a commit that referenced this pull request Dec 5, 2024
Vue: Properly resolve Vite plugin
(cherry picked from commit f25b824)
@tobiasdiez
Copy link
Contributor Author

Thanks for the quick merge!

@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ci:normal patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants