-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Unable to use Storybook as expected in a monorepo #5949
Comments
@shilman, if possible, you might consider adding a |
We don't have a lerna tag -- |
Hi @maecapozzi - I'm glad you figured out a workaround, but I'm wondering about the original issue. I wonder why you think it might be lerna related? Because of symlinks within OTOH maybe there is a more general issue with monorepos specifically with typescript? I know plenty of people (myself) included have a similar setup to what you originally described so there must be something different going on here. |
Sorry I should add I guess what I did to work around #3346 is: const babelLoader = storybookBaseConfig.module.rules[0];
babelLoader.exclude.push(
path.resolve('./lib/components/node_modules'),
/* etc */
); Which is perhaps a little simpler and less disruptive that what you posted... |
Related: #5220 |
@tmeasday, I did think that maybe it had to do with the symlinks. Alternatively, as I was digging into the dev tools, it looked like something called |
I am also unable to get SB5 working with our Lerna monorepo. We have a custom Webpack config which I haven't had any success updating to the single signature format. Initially it was blowing up on the .css files (we use PostCSS), and after some trial and error I progressed to it blowing up on the JSX parsing. // webpack.config.js
module.exports = async ({ config, mode }) => {
config.module.rules.push(babelLoader)
config.module.rules.push(cssLoader)
return config;
} Storybook will run with above config if I only include a trivial example, however when I attempt to load a story with some of our monorepo components, I get a bunch of errors like:
and
For comparison, my working SB4 custom Webpack config is module.exports = storybookBaseConfig => {
storybookBaseConfig.module.rules.push(babelLoader);
storybookBaseConfig.module.rules.push(cssLoader);
return storybookBaseConfig;
}; |
@astrotim I'm having the exact same issue right now in our monorepo (not using Lerna though). I temporarily fixed it by prefixing the
I never used Lerna but I don't feel like this is related to it... It might have to do with what I'd call webpack contexts switching : the custom webpack configuration we provide to Storybook somehow conflicts with what Storybook does internally. Don't know if it'll help, but you might have a look to webpack |
I actually now think my issue in unrelated to our monorepo environment, but my rather it is #6083 |
I've got this error as well, any way to fix this or any workaround? I've tried to include config.module.rules[0].include = [path.join(cwd, 'src'), path.join(cwd, 'packages/')]; but it did not worked well this is the error: ReferenceError: exports is not defined
at Module../packages/shared/dist/Valeu.js (MyEmail.story.tsx:41)
at __webpack_require__ |
I am also having the same issue. My monorepo is just running yarn workspaces, no lerna. All of my packages are running typescript. |
Use latest alphas releases |
I'm working with a monorepo as well, but the issue has something to do with css-loader, I am using style-loader/css-loader/postcss-loader with css modules, I'm trying to switch from styleguidst to storybook, and it hasn't been easy at all. I am not sure where the issue is but, I get the unknown word: Using the beta.0 version of 5.1 as I needed the core-js v3 issue resolved. |
Just noticed this import is not working when using in a Lerna monorepository |
Hello, ERROR in my-gatsby/node_modules/gatsby/cache-dir/gatsby-browser-entry.js 17:2
Module parse failed: Unexpected token (17:2)
You may need an appropriate loader to handle this file type.
|
| const StaticQuery = props => (
> <StaticQueryContext.Consumer>
| {staticQueryData => {
| if (
@ ./src/baseComponents/Link/Link.stories.jsx 4:0-30
@ . sync \.stories\.(js|jsx)$
@ ./.storybook/config.js
@ multi my-gatsby/node_modules/@storybook/core/dist/server/common/polyfills.js /my-gatsby/node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js (webpack)-hot-middleware/client.js?reload=true I feel certain this is an issue with monorepos and storybook (perhaps the combination with gatsby as well), because I have a gatsby starter project running just fine with storybook ( I took that working gatsby starter and placed it in my monorepo, but not in a directory that uses yarn workspaces, and it also runs just fine. It only causes the error shown above when placed under a folder that uses yarn workspaces which handles I've tried adding a custom |
@Jimmydalecleveland run storybook with the Look at the loaders defined and you'll see there are exclude & include rules for the loaders responsible for transpiling code. I think if you just remove the include property, it should start to work for you. |
@ndelangen Thank you for the quick response. I solved this problem last night differently, and now that I've tried your suggestion and it also works, I'm not understanding why. I pushed a separate include rule: If you need more context, here is the before and after log of what that config looks like after applying your suggestion: // before deleting include rule
{
test: /\.(mjs|jsx?)$/,
use: [ { loader: 'babel-loader', options: [Object] } ],
include: [ './my-project/themes/gatsby-theme-storybook' ],
exclude: [ './my-project/themes/gatsby-theme-storybook/node_modules' ]
}
// after
{
test: /\.(mjs|jsx?)$/,
use: [ { loader: 'babel-loader', options: [Object] } ],
exclude: [ './my-project/themes/gatsby-theme-storybook/node_modules' ]
} And this is the line I was previously using that worked in Thanks again, I really appreciate it. |
@Jimmydalecleveland removing that include is on my todo list, but I'm afraid of it messing up people's setup, So I want to do it for the next major (6.0) I think. My solution works because it simply removes all include filters. Yours work, because... I have no freaking clue why. 😭 not enough context on the project file structure to really judge. |
@ndelangen Ok, no problem. I'm pretty sure it is a very specific problem to monorepos with Gatsby and storybook not at the root of the project. Take care! |
thanks @Jimmydalecleveland, your fix worked for me! I also have a gatsby app inside a monorepo with yarn workspaces and kept getting an ambiguous error from nodemodules/gatsby when running |
this should not be closed. This issue will only be more important with the rise of Nrwl NX |
PR is open addressing this, will be a 6.0.0 feature |
I also report this issue, when I want to load packages or files outside of node_modules I got the empty "exports" issue, in my case is like this:
I solved patching the |
Whoopee!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.0 containing PR #8822 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
This is important.
@shilman This is closed. Not sure why. What would be the workaround? @claudio-moya Could you please post your patch? |
Describe the bug
I am working in a lerna-managed monorepo with Typescript. Originally, we had a separate storybook configuration in each package, which worked nicely. We decided we wanted a root-level storybook that pulled from the
*.stories.tsx
files inside each package.Here is an example of the desired file structure:
After following the fix in this issue to solve our original
exports not found
error, we had no more error messages, but also no stories appeared.After digging into the devtools for some time, we found that the stories were being read, and the correct paths were being generated. It looked like at some point they were unexpectedly cleared from the
StoryStore
.Is this expected behavior? Is it possible to create a top-level storybook that reads from stories inside of packages in a lerna-managed monorepo?
Expected behavior
I expected to see a working storybook with stories from all of my packages in it.
Code snippets
webpack.config.js
config.ts
System:
Additional context
I ended up just creating a top-level
/stories
folder and moving all of my packages into it. That works nicely. I'd just like to understand why the structure I was originally aiming for doesn't work.The text was updated successfully, but these errors were encountered: