[7.x] Storybook 6 and config changes (#75357)#78894
Conversation
Upgrade to Storybook 6 and attempt to use the declarative configuration.
The goals of this PR (as part of Kibana's Storybook roadmap, are:
Upgrade to Storybook 6
Still allow running Storybooks with yarn storybook plugin_name
Use the declarative configuration to (hopefully) make the configuration simpler to use an easier to understand, as well as avoiding deprecation warnings and loss of future compatibility
The ways in which what I have so far differs from how we do things today are:
In the alias configuration it takes a path to a storybook configuration directory instead of the storybook.js file from before
Each plugin (it doesn't have to be a plugin; can be any directory) has a .storybook/main.js (the aliases file in @kbn/storybook specifies these locations) where they can define their Storybook configuration. You can require('@kbn/storybook').defaultConfig to get defaults and override them
@kbn/storybook has a preset that can provide Webpack and Babel configuration and Storybook parameters and decorators
Instead of dynamically creating the list of stories to import, we define them in the globs of the stories property in .storybook/main.js.
Do not build a DLL. We are using @kbn/ui-shared-deps as externals. Startup time is not quite as fast but still acceptable.
Other things done in this PR:
Allow default exports in .stories. to allow for Common Story Format CSF stories
Add guard in Webpack configuration needed for overriding CSS rules
Update filename casing check to allow for files with required names in Storybook
Clean up observability stories
Rename *.examples.tsx and *.story.tsx to *.stories.tsx
Upgrade to Storybook 6 and attempt to use the declarative configuration.
The goals of this PR (as part of Kibana's Storybook roadmap, are:
Upgrade to Storybook 6
Still allow running Storybooks with yarn storybook plugin_name
Use the declarative configuration to (hopefully) make the configuration simpler to use an easier to understand, as well as avoiding deprecation warnings and loss of future compatibility
The ways in which what I have so far differs from how we do things today are:
In the alias configuration it takes a path to a storybook configuration directory instead of the storybook.js file from before
Each plugin (it doesn't have to be a plugin; can be any directory) has a .storybook/main.js (the aliases file in @kbn/storybook specifies these locations) where they can define their Storybook configuration. You can require('@kbn/storybook').defaultConfig to get defaults and override them
@kbn/storybook has a preset that can provide Webpack and Babel configuration and Storybook parameters and decorators
Instead of dynamically creating the list of stories to import, we define them in the globs of the stories property in .storybook/main.js.
Do not build a DLL. We are using @kbn/ui-shared-deps as externals. Startup time is not quite as fast but still acceptable.
Other things done in this PR:
Allow default exports in .stories. to allow for Common Story Format CSF stories
Add guard in Webpack configuration needed for overriding CSS rules
Update filename casing check to allow for files with required names in Storybook
Clean up observability stories
Rename *.examples.tsx and *.story.tsx to *.stories.tsx
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
|
Updated the branch 🤞 |
|
Merge conflicts - trying this again. This time will try to merge as soon as it goes green. 🤞 |
|
Getting this: I can update optimizer and storybook to fix. |
| "@types/loader-utils": "^1.1.3", | ||
| "@types/loader-utils": "^2.0.1", | ||
| "@types/watchpack": "^1.1.5", | ||
| "@types/webpack": "^4.41.3" |
There was a problem hiding this comment.
It looks like master has "@types/webpack": "^4.41.3" and "@types/loader-utils": "^1.1.3",. Mind aligning with those to keep the branches consistent?
|
@tylersmalley the e2e is failing because of a dependency that should be fixed with tomorrow's packer image build. The type check is failing because of the updates to the types in the optimizer. Let me know if there's anything you want me to do. I plan on going in and either fixing the types or aligning to a previous version but either push commits or let me know if we should do anything differently. |
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
@kbn/ui-shared-deps asset size
async chunks size
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |
Backports the following commits to 7.x: