Skip to content

chore(storybook): minimal upgrade migration #5309

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

Merged
merged 2 commits into from
Apr 24, 2025

Conversation

castastrophe
Copy link
Collaborator

@castastrophe castastrophe commented Mar 31, 2025

Description

This update migrations the SWC Storybook instance off of the @web/storybook-builder and @web/storybook-framework-web-components and onto the latest breaking change (v8) release of @storybook/* and storybook packages.

This update does not:

  • migrate the build off webpack and onto Vite

Had to remove the maintained node versions entry to the browsers list config because it was causing the Storybook build to fail:

Error: For the selected environment is no default script chunk format available:
JSONP Array push can be chosen when 'document' or 'importScripts' is available.
CommonJs exports can be chosen when 'require' or node builtins are available.
Make sure that your 'browserslist' includes only platforms that support these features or select an appropriate 'target' to allow selecting a chunk format by default. Alternatively specify the 'output.chunkFormat' directly.

Related issue(s)

Motivation and context

Blog post

  • Built-in visual testing
  • 2-4x faster test builds
  • Refreshed desktop UI
  • Rebuilt mobile UX
  • Removed React dependency for non-React projects (yay!)

How has this been tested?

  • Open the storybook (either locally or the one built to this PR)
    1. Expect the landing page to now be a docs summary story for the Accordion.
    2. Expect each component and component group to now contain a summary docs page with a view of the default story and a list of the available properties.
    3. Expect no regressions in how theming works via the global knobs at the top
    4. If a story does not contain any defined properties, expect the properties section of the docs page to be missing as in Action bar
  • Expect to see no regressions in visual regression tests
  • Expect to see no regressions in functional tests
  • yarn start: expect no regressions to local Storybook
    • Update a CSS asset and validate the changes refresh live in Storybook
    • Update a TS asset and validate the changes refresh live in Storybook

Screenshots

Screenshot 2025-04-01 at 10 07 59 AM

Types of changes

  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • [n/a] If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • [n/a] I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

changeset-bot bot commented Mar 31, 2025

⚠️ No Changeset found

Latest commit: f51747d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

github-actions bot commented Mar 31, 2025

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

Tachometer results

Currently, no packages are changed by this PR...

@castastrophe castastrophe force-pushed the castastrophe/chore-storybook-migration branch 3 times, most recently from b361a04 to 6004f3f Compare April 1, 2025 12:13
@castastrophe castastrophe self-assigned this Apr 1, 2025
@castastrophe castastrophe marked this pull request as ready for review April 1, 2025 14:38
@castastrophe castastrophe requested a review from a team as a code owner April 1, 2025 14:38
icon: html`
<sp-icon-edit hidden slot="icon"></sp-icon-edit>
`,
icon: `<sp-icon-edit hidden slot="icon"></sp-icon-edit>`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This version is much stricter about safe template rendering. It's considered unsafe to call a template result via function inside another template result. This is the way to accomplish that same result.

},
];

export const tags = ['autodocs'];
Copy link
Contributor

@caseyisonit caseyisonit Apr 1, 2025

Choose a reason for hiding this comment

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

can NOT wait for this to go live <3

@@ -277,32 +278,3 @@ export const configuredVisualRegressionPlugin = () =>
);
},
});

export function watchSWC() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what this was doing or why its safe to remove this now?

Copy link
Collaborator Author

@castastrophe castastrophe Apr 16, 2025

Choose a reason for hiding this comment

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

Yes this was forcing rebuild of the assets when updates were made to the source files. Storybook handles this automatically and doesn't need us to manually kick this off any more. We can validate this by making changes to an existing asset and seeing it live refresh on the page. I'll add a test case for that when I start writing up validation steps.

Copy link
Contributor

Choose a reason for hiding this comment

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

worked for me!

"@storybook/addon-designs": "^8.0.0",
"@storybook/addon-essentials": "^7.5.0",
"@storybook/addon-links": "^7.5.0",
"@storybook/web-components": "^7.5.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this package was removed but this is how we set our custom manifest (the part you commented out in preview.js). Was this intentional or is it not supported in storybook 8?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does look like it comes with v8 support: https://www.npmjs.com/package/@storybook/web-components

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It may say that it's supported but there's some serious issues in that package. When I add the dependency, it adds this to our install logs (yes, it does the same if we bump all packages to 8.6.12 too):

Screenshot 2025-04-14 at 1 38 53 PM

When we add it in anyway despite the logged error, it blocks styles from loading. When I commented out the CEM loading, the arg types still loaded in the stories and the styles rendered. We can debug loading the CEM another way but I'm not sure this package is going to be it.

@castastrophe castastrophe force-pushed the castastrophe/chore-storybook-migration branch 3 times, most recently from d596606 to b4fd473 Compare April 4, 2025 15:13
@castastrophe castastrophe force-pushed the castastrophe/chore-storybook-migration branch 7 times, most recently from d5bc7ea to 1b26c82 Compare April 17, 2025 14:08
@castastrophe castastrophe force-pushed the castastrophe/chore-storybook-migration branch from 1b26c82 to 0ae7e45 Compare April 18, 2025 13:36
@castastrophe castastrophe force-pushed the castastrophe/chore-storybook-migration branch from 0ae7e45 to 73d269b Compare April 18, 2025 16:47
import { merge } from 'webpack-merge';

/** @type { import('@storybook/web-components-webpack5').StorybookConfig } */
export default {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A personal nit: how do you feel about including the disableWhatsNewNotifications: true setting in the core settings (like we do in Spectrum CSS)? Also: what if we set disableTelemetry: true?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm definitely in support of that - would it work if I added this as a "fast follow" once this merges?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, absolutely!

Copy link
Collaborator

@pfulton pfulton left a comment

Choose a reason for hiding this comment

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

I pulled down this branch and ran it successfully on my local environment. Everything looked good, functioned as expected, and was speedy!

I love that this enables the AutoDocs stuff!

I dropped one nit comment here that is just a personal preference, but let me know what you think.

Otherwise, I think this should be good to go.

@castastrophe castastrophe force-pushed the castastrophe/chore-storybook-migration branch 3 times, most recently from 0788b9b to f10e882 Compare April 23, 2025 19:01
Copy link
Contributor

@caseyisonit caseyisonit left a comment

Choose a reason for hiding this comment

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

LGTM - would love a fast follow to investigate the custom element manifest or automating the args table over the current implementation which is completely manual.

@castastrophe castastrophe force-pushed the castastrophe/chore-storybook-migration branch from f10e882 to f51747d Compare April 24, 2025 16:56
Copy link
Contributor

@nikkimk nikkimk left a comment

Choose a reason for hiding this comment

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

As always, thanks for making our developer experience so much better!

@@ -277,32 +278,3 @@ export const configuredVisualRegressionPlugin = () =>
);
},
});

export function watchSWC() {
Copy link
Contributor

Choose a reason for hiding this comment

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

worked for me!

@castastrophe castastrophe merged commit c067f66 into main Apr 24, 2025
24 checks passed
@castastrophe castastrophe deleted the castastrophe/chore-storybook-migration branch April 24, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants