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

CLI: Make PackageJson optional for starting a dev server #28594

Merged
merged 12 commits into from
Aug 21, 2024

Conversation

tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Jul 14, 2024

What I did

Currently, starting the storybook dev sever operates with the following assumptions:

  • The storybook packages are direct dependencies (specified in the package.json file of the project)
  • The package.json file contains storybook scripts to run storybook

For the nuxt integration both assumptions may not be fullfilled: the storybook packages are dependencies of the nuxt module but not of the project where they are installed. And the dev server may be started as part of the nuxt dev server.

Hence the interface for the buildDevStandalone is changed to make packageJson optional. This would also help fixing the downstream issue nuxt-modules/storybook#704

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

I couldn't test this manually due to #28593

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 76.3 MB 76.3 MB 275 B -0.3 0%
initSize 169 MB 169 MB 202 B 1.38 0%
diffSize 92.8 MB 92.8 MB -73 B 1.04 0%
buildSize 7.46 MB 7.46 MB 0 B 0.98 0%
buildSbAddonsSize 1.62 MB 1.62 MB 0 B 1.08 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.3 MB 2.3 MB 0 B - 0%
buildSbPreviewSize 351 kB 351 kB 0 B 0.9 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.46 MB 4.46 MB 0 B 1.01 0%
buildPreviewSize 3 MB 3 MB 0 B 0.83 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 17.3s 7.2s -10s -117ms -1.45 🔰-140.1%
generateTime 19.3s 20.5s 1.2s 0.23 6%
initTime 16.4s 17.4s 970ms -0.1 5.6%
buildTime 12.1s 11.1s -974ms -1.4 🔰-8.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6.2s 7.9s 1.6s 0.55 20.7%
devManagerResponsive 4.2s 5.2s 1s 0.86 19.4%
devManagerHeaderVisible 711ms 1.1s 432ms 2.83 🔺37.8%
devManagerIndexVisible 743ms 1.2s 462ms 2.96 🔺38.3%
devStoryVisibleUncached 1s 1.6s 590ms 1.39 🔺35.6%
devStoryVisible 744ms 1.2s 462ms 2.98 🔺38.3%
devAutodocsVisible 655ms 1s 386ms 2.58 🔺37.1%
devMDXVisible 639ms 1s 432ms 2.48 🔺40.3%
buildManagerHeaderVisible 676ms 1s 350ms 2.79 🔺34.1%
buildManagerIndexVisible 684ms 1s 385ms 3.21 🔺36%
buildStoryVisible 716ms 1s 351ms 2.19 🔺32.9%
buildAutodocsVisible 635ms 961ms 326ms 2.86 🔺33.9%
buildMDXVisible 581ms 827ms 246ms 2.52 🔺29.7%

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.

PR Summary

  • code/core/src/core-server/utils/warnWhenUsingArgTypesRegex.ts: Made packageJson parameter optional, added previewConfigPath.
  • code/core/src/types/modules/core-common.ts: Updated LoadOptions interface to make packageJson optional.

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

nx-cloud bot commented Jul 14, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f83fe19. 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.

@shilman shilman added maintenance User-facing maintenance tasks cli nuxt ci:normal labels Jul 15, 2024
@shilman shilman changed the title feat: make PackageJson optional for starting a dev server CLI: Make PackageJson optional for starting a dev server Jul 15, 2024
tobiasdiez added a commit to nuxt-modules/storybook that referenced this pull request Jul 16, 2024
… version check) (#722)

<!---
☝️ PR title should follow conventional commits
(https://conventionalcommits.org)
-->

### 🔗 Linked issue

Fixes #704

<!-- If it resolves an open issue, please link the issue here. For
example "Resolves #123" -->

### ❓ Type of change

<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply. -->

- [ ] 📖 Documentation (updates to the documentation or readme)
- [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
- [ ] 👌 Enhancement (improving an existing functionality)
- [ ] ✨ New feature (a non-breaking change that adds functionality)
- [ ] 🧹 Chore (updates to the build process or auxiliary tools and
libraries)
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to change)

### 📚 Description

Instead of actually loading the package json, we just pass a javascript
object with a `version` field. That is the only thing used by storybook.
It's a temporary workaround until
storybookjs/storybook#28594 is merged.

<!-- Describe your changes in detail -->
<!-- Why is this change required? What problem does it solve? -->
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

@tobiasdiez, it appears that one of the changed values has string|null type instead of expected string|undefined, and this makes the build fail in CircleCI:

src/core-server/build-dev.ts(50,5): error TS2322: Type 'string | null' is not assignable to type 'string | undefined'.
  Type 'null' is not assignable to type 'string | undefined'.
``

@ndelangen ndelangen merged commit 51f64f6 into storybookjs:next Aug 21, 2024
52 checks passed
@tobiasdiez tobiasdiez deleted the packageJson branch August 21, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal cli maintenance User-facing maintenance tasks nuxt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants