Unclear configuration of storysource with Typescript causes TypeErrors
See original GitHub issueDescribe the bug
The README for the storysource addon is confusing if you are not quite familiar with Webpack. You are supposed to change the main.js
file like this:
module.exports = {
addons: ['@storybook/addon-storysource'],
};
But also, if you want to use Typescript-based stories, you need to change main.js
like this:
module.exports = function({ config }) { /* ... */ };
I have problems with merging these two exports. My current not working solution looks like this:
module.exports = function ({ config }) {
config.stories = ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'];
config.addons = [
'@storybook/addon-links',
'@storybook/addon-actions',
'@storybook/addon-essentials',
'@storybook/addon-storysource',
'@storybook/addon-docs',
];
config.module.rules.push({
test: /\.stories\.tsx?$/,
loaders: [
{
loader: require.resolve('@storybook/source-loader'),
options: { parser: 'typescript' },
},
],
enforce: 'pre',
});
return config;
};
But this does not work since the passed argument does not have a config
field.
To Reproduce
Install the current storybook version (6.0.0.-rc.x) and try to apply the instructions of the storysource README. Use one of the function-based exports and you will see an error message which indicates that config
is undefined.
Expected behavior Ideally, the README would better explain how the function-based exports are to be merged with the default record based export.
Screenshots
System:
Environment Info:
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Binaries:
Node: 13.12.0 - ~/.nvm/versions/node/v13.12.0/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v13.12.0/bin/npm
Browsers:
Chrome: 84.0.4147.105
Firefox: 76.0.1
Safari: 13.1
npmPackages:
@storybook/addon-actions: 6.0.0-rc.13 => 6.0.0-rc.13
@storybook/addon-docs: ^6.0.0-rc.16 => 6.0.0-rc.16
@storybook/addon-essentials: 6.0.0-rc.13 => 6.0.0-rc.13
@storybook/addon-links: 6.0.0-rc.13 => 6.0.0-rc.13
@storybook/addon-storysource: 6.0.0-rc.16 => 6.0.0-rc.16
@storybook/angular: 6.0.0-rc.13 => 6.0.0-rc.13
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top GitHub Comments
Well this addon is poo, dealing with the same thing?
bump