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

feat: upgraded to storybook 8 and vite-framework #209

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

Jontii
Copy link
Contributor

@Jontii Jontii commented Apr 7, 2024

This PR upgrades storybook to v8 and switched from webpack compiler to vite for storybook.

  • Docs needed to be changed to not have "stories" in the name.
  • Removed babel packages which was not needed since vite was used instead of webpack. This can be changed if we don't feel that vite is needed. But it was easier and faster than compared to webpack.
  • addon/types had been migrated to manager-api/preview-api
  • Upgraded all the needed packages
  • Added a global decorator for the addon panel in preview.jsx

Copy link

netlify bot commented Apr 7, 2024

Deploy Preview for storybook-addon-mock ready!

Name Link
🔨 Latest commit a156b3e
🔍 Latest deploy log https://app.netlify.com/sites/storybook-addon-mock/deploys/661be220a2c1f400085d43b7
😎 Deploy Preview https://deploy-preview-209--storybook-addon-mock.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Jontii Jontii mentioned this pull request Apr 7, 2024
@pinguet62
Copy link

Hello 🖖
Node 16 is no longer supported: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropping-support-for-nodejs-16
I think you can replace node 16.x by 20.x in matrix

@Jontii Jontii force-pushed the master branch 2 times, most recently from aa8760c to 271191f Compare April 7, 2024 15:27
@Jontii
Copy link
Contributor Author

Jontii commented Apr 7, 2024

Hello 🖖 Node 16 is no longer supported: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropping-support-for-nodejs-16 I think you can replace node 16.x by 20.x in matrix

Hi ! I updated it to 20 :)

stories: [
'../stories/**/*stories.mdx',
'../stories/**/*stories.@(js|jsx|ts|tsx)',
'../stories/**/*.mdx',
Copy link

Choose a reason for hiding this comment

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

I believe this line can be removed as MDX files are no longer supported since Storybook v8.x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure ? I can see that they removed the support for .stories.mdx https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropping-support-for-storiesmdx-csf-in-mdx-format-and-mdx1-support

Checking their docs for V8 they still use mdx and show examples of it
https://storybook.js.org/docs/writing-docs/mdx

@castamir
Copy link

castamir commented Apr 8, 2024

@Jontii thanks for your PR. I left some comments in your PR. Hope you don't mind.

@jdehaan
Copy link

jdehaan commented Apr 8, 2024

Is it only for me or the Mock pane is missing in the storybook panel? Maybe something broke the automatic handling.

Screenshot for the previous version of the add-on
image

The tab is missing if I take the code from this PR (unless I did something wrong...)

Beside my local test, comparing current head:

With the netlify preview for this PR:

You can see for the latter somehow the mock data is missing. (locally however I've the tab completely missing)

@Jontii
Copy link
Contributor Author

Jontii commented Apr 9, 2024

Is it only for me or the Mock pane is missing in the storybook panel? Maybe something broke the automatic handling.

Screenshot for the previous version of the add-on image

The tab is missing if I take the code from this PR (unless I did something wrong...)

Beside my local test, comparing current head:

* https://storybook-addon-mock.netlify.app/?path=/story/examples-fetch--get

With the netlify preview for this PR:

* https://deploy-preview-209--storybook-addon-mock.netlify.app/?path=/story/examples-fetch--get

You can see for the latter somehow the mock data is missing. (locally however I've the tab completely missing)

Hmm yeah you're right. I'll check in the week if I can find something

@jdehaan
Copy link

jdehaan commented Apr 9, 2024

I tried to debug that further by adding logs inside withRoundTrip. It seems to me that the decorator is not being called. Maybe something changed in the way this is added in the context of an addon? I tried to compare and see how other addons performed the upgrade but had to face only failures by trying to apply fixes.... Hopefully you'll make it with a better knowledge of what is going on in the addon internally. It's all new to me.

@jdehaan
Copy link

jdehaan commented Apr 9, 2024

By using the info from here and changing preview.js to

import { withRoundTrip } from '../withRoundTrip';

const preview = {
    decorators: [withRoundTrip],
    globals: {
        mockData: [],
    },
};

export default preview;

and keeping the console logs, I can now see the decorator is being called

image

From withRoundTrip.js:

    const data = [...globalMockData, ...paramData];
    console.warn('withRoundTrip:');
    console.log(data);

The data being shown is the story args parameter data. Yet the state data is empty and thus the tab also remains empty. It almost works but in the end there is still no data shown inside the tab.

Two fixes were required. Use the correct addons import and withRoundTrip as a decorator for all stories.
@Jontii
Copy link
Contributor Author

Jontii commented Apr 12, 2024

By using the info from here and changing preview.js to

import { withRoundTrip } from '../withRoundTrip';

const preview = {
    decorators: [withRoundTrip],
    globals: {
        mockData: [],
    },
};

export default preview;

and keeping the console logs, I can now see the decorator is being called

image

From withRoundTrip.js:

    const data = [...globalMockData, ...paramData];
    console.warn('withRoundTrip:');
    console.log(data);

The data being shown is the story args parameter data. Yet the state data is empty and thus the tab also remains empty. It almost works but in the end there is still no data shown inside the tab.

Hi ! I fixed it in my latest commit so everything should be working now. @jdehaan

packages/mock-addon-docs/package.json Outdated Show resolved Hide resolved
packages/mock-addon/.github/workflows/release.yml Outdated Show resolved Hide resolved
packages/mock-addon-docs/package.json Outdated Show resolved Hide resolved
@@ -16,7 +16,7 @@ import { Footer } from './footer';

<h3 className="subheading">1. Global configuration</h3>

You can set <strong>global configuration</strong> for the addon. Go to the `.storybook/preview.js` file and add `mockAddonConfigs` fields with the following properties.
You can set <strong>global configuration</strong> for the addon. Go to the `.storybook/preview.jsxx` file and add `mockAddonConfigs` fields with the following properties.
Copy link

@jdehaan jdehaan Apr 13, 2024

Choose a reason for hiding this comment

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

A small typo here jsxx -> jsx, other than that LGTM! Thanks for the fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll fix it :)

@@ -12,10 +12,10 @@ jobs:
- name: Prepare repository
run: git fetch --unshallow --tags

- name: Use Node.js 14.x
uses: actions/setup-node@v1
- name: Use Node.js 18.x
Copy link

@janaagaard75 janaagaard75 Apr 14, 2024

Choose a reason for hiding this comment

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

Minor, but since we're updating things, I think we might as well choose the latest LTS version of Node.js, and that's version 20.

Copy link
Collaborator

@nutboltu nutboltu left a comment

Choose a reason for hiding this comment

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

LGTM Huge kudos to @Jontii and other who contributes this PR. I'm going to merge the PR and publish the new version soon.

@nutboltu nutboltu merged commit 88b108a into linearlabs-workspace:master Apr 15, 2024
6 checks passed
"remark-gfm": "^3.0.1",
"superagent": "^8.0.9"
"superagent": "^8.0.9",
"vite": "^5.2.8"
Copy link
Contributor

Choose a reason for hiding this comment

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

is vite really a prod dependency of the addon ?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah sorry. This is the docs package, not the addon

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.

8 participants