modernweb-dev / storybook-prebuilt

Storybook prebuilt to work with native es modules
MIT License
37 stars 9 forks source link

Update the storybook version base #133

Open emexal-company opened 2 years ago

emexal-company commented 2 years ago

Are there any plans to upgrade to storybook 6.5.9 ? I'm facing a bug, that is fixed on the 6.5.9. The bug is the following 👍

export default {
  title: 'Example/Button',
  argTypes: {
    label: {type: 'string'},
    value: {type: 'number'},
  }
}

const Template: Story<Partial<ButtonProps>> = (args) => {
  const [args, updateArgs] = useArgs();
  const newargs = Object.assign({}, args, {
    onClick: () => {
      updateArgs({label: 'gooooooooooooogle', value: 10});
    },
  });

After clicking the button, the "title" is updated in the ArgsTable, but the "value" is not. The issue seems to be related to the argtype 'number'.

emexal-company commented 2 years ago

The issue was fixed in this PR.

emexal-company commented 2 years ago

I tried to upgrade myself. What I did so far is:

  1. In package.json
    {
    "scripts": {
       // Added this script
        "postinstall": "patch-package"
    },
    "devDependencies": {
         // Upgraded storybook to 6.5.9
         "@storybook/addon-docs": "6.5.9",
         "@storybook/addon-essentials": "6.5.9",
         "@storybook/addons": "6.5.9",
         "@storybook/api": "6.5.9",
         "@storybook/preact": "6.5.9",
         "@storybook/theming": "6.5.9",
         "@storybook/web-components": "6.5.9",
         // Added this package
         "patch-package": "^6.4.7"
     },
     "overrides": {
        /* Override Acorn, the new storybook is compiled in Ecma 2020, 
        and the plugin rollup-plugin-node-globals is using a too old version of acorn */
         "acorn": "8.7.1"
      }
    }
  2. Added a patch file for rollup-plugin-node-globals in order to upgrade the ECMA version that acorn will parse

    diff --git a/node_modules/rollup-plugin-node-globals/dist/rollup-plugin-node-globals.cjs.js b/node_modules/rollup-plugin-node-globals/dist/rollup-plugin-node-globals.cjs.js
    index 2a94535..2390f1a 100644
    --- a/node_modules/rollup-plugin-node-globals/dist/rollup-plugin-node-globals.cjs.js
    +++ b/node_modules/rollup-plugin-node-globals/dist/rollup-plugin-node-globals.cjs.js
    @@ -72,7 +72,7 @@ function inject (code, id, mod1, mod2, sourceMap) {
    
    try {
     ast = acorn.parse(code, {
    -      ecmaVersion: 9,
    +      ecmaVersion: 'latest',
       sourceType: 'module'
     });
    } catch (err) {

    The result is that the build now is succeeding, but the prebuilt version fails to start. Can anyone help to analyse the situation ? If we understand what is happening, then I might take some time to find a solution