Closed delewis13 closed 5 years ago
i ran into this issue also it has to do with you loading up node/server library with storybook. what i had to do was mock them.
let's say you have .storybook dir like this:
.storybook fsMock.js netMock.js tlsMock.js webpack.config.js
fsMock.js:
module.exports = { readFileSync: () => 'mocked file', // other things in fs that you are using }
netMock.js:
module.exports = { netFunc: () => 'mocked file', // other things in net that you are using }
tlsMock.js:
module.exports = { tlsFunc: () => 'mocked file', // other things in tls that you are using }
webpack.config.js:
const path = require('path');
module.exports = (storybookBaseConfig, configType) => { storybookBaseConfig.resolve.alias = { ...storybookBaseConfig.resolve.alias, 'fs': path.resolve(dirname, 'fsMock.js'), 'net': path.resolve(dirname, 'netMock.js'), 'tls': path.resolve(__dirname, 'tlsMock.js') };
return storybookBaseConfig; };
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!
Describe the bug
Attempting to create a story for a component that uses NPM modules that require 'tls', 'fs' and 'net'.
Receive error [note: do not receive this during usual build]:
Subsequently attempt to resolve by extending default webpack config as per https://github.com/request/request/issues/1529. As such add the following webpack.config.js file to my .stories folder which is in root directory:
Receive error:
Looks like the Storybook webpack config is being overwritten rather than extended. Subsequently think that I must be doing the webpack.config extension incorrectly, so consult docs. Copy paste the example found at https://storybook.js.org/docs/configurations/custom-webpack-config/
Hit the same error again.
So, my issues appears twofold: (1) Issue with imports of 'fs', 'tls' and 'net' (2) Inability to properly extend Storybook default webpack.
Additional context My package.json: