Skip to content
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

change rootDir to ./src cause trouble for storybook custom /.storybook/config.ts with require.context (Storybook <5.3) #641

Closed
zhaoyao91 opened this issue Mar 24, 2020 · 6 comments
Labels
solution: outdated This is not up-to-date with the current version solution: workaround available There is a workaround available for this issue

Comments

@zhaoyao91
Copy link

Current Behavior

after receiving the warning to tell me changge the rootDir to ./src, the stroybook does not work no longer.

ERROR in /Users/bytedance/workspace/use-pick-files/tsconfig.json
[tsl] ERROR
      TS6059: File '/Users/bytedance/workspace/use-pick-files/.storybook/config.ts' is not under 'rootDir' '/Users/bytedance/workspace/use-pick-files/src'. 'rootDir' is expected to contain all source files.

ERROR in /Users/bytedance/workspace/use-pick-files/tsconfig.json
[tsl] ERROR
      TS6059: File '/Users/bytedance/workspace/use-pick-files/stories/use-pick-files.stories.tsx' is not under 'rootDir' '/Users/bytedance/workspace/use-pick-files/src'. 'rootDir' is expected to contain all source files.

Expected behavior

storybook works after changing the rootDir

Suggested solution(s)

Additional context

Your environment

Software Version(s)
TSDX 0.13.0
TypeScript 3.8.3
Browser chrome
npm/Yarn yarn 1.21.1
Node 12.14.1
Operating System mac os
@agilgur5
Copy link
Collaborator

agilgur5 commented Mar 24, 2020

Poop, thought this might be an issue after working on #638 which is very similar, but this is on the Storybook side, not the TSDX side. Was mentioned in #440 (comment) .

Currently working on it but I think there's a workaround that seems to be safe, which is to use:

{
  "rootDirs": ["./src", "./stories", "./.storybook"]
}

Storybook seems to recommend a similar set-up

@zhaoyao91
Copy link
Author

@agilgur5 confirmed, workaround works well!
this may be integrated into the template of react with storybook, to avoid having to search the issue for new projects.

@agilgur5
Copy link
Collaborator

That's great, thanks for confirming!

I did a lot of research and there's some discussion in #638, which is closely related to this -- there will be some changes to the templates, but I'm not sure if we'll use this specific one yet; we might be able to work it out a different way.
I still need to test what's possible with Storybook, as that's not something I looked into yet (#638 is about tests) and I also don't use it in any of my libraries at all yet, so I'm not really familiar with it.

@agilgur5
Copy link
Collaborator

agilgur5 commented Mar 29, 2020

So I tried reproducing this and was unable to do this with react-with-storybook template.

The Storybook config you're using in use-pick-files is quite different than the template. I was able to reproduce it with your config.

@agilgur5 agilgur5 changed the title change rootDir to ./src cause trouble for storybook change rootDir to ./src cause trouble for storybook (custom /.storybook/config.ts) Mar 29, 2020
@agilgur5 agilgur5 changed the title change rootDir to ./src cause trouble for storybook (custom /.storybook/config.ts) change rootDir to ./src cause trouble for storybook custom /.storybook/config.ts Mar 29, 2020
@agilgur5 agilgur5 changed the title change rootDir to ./src cause trouble for storybook custom /.storybook/config.ts change rootDir to ./src cause trouble for storybook custom /.storybook/config.ts with require.context Mar 29, 2020
@agilgur5
Copy link
Collaborator

Ah, I figured it out -- your configuration is for Storybook 5.2 -- the templates use 5.3 (as of TSDX v0.13), which is a big change. In 5.3 you don't need require.context at all, you should use the stories: config with a glob in main.js.

See the Storybook 5.3 migration guide or TSDX's newer templates

@agilgur5 agilgur5 changed the title change rootDir to ./src cause trouble for storybook custom /.storybook/config.ts with require.context change rootDir to ./src cause trouble for storybook custom /.storybook/config.ts with require.context (Storybook <5.3) Mar 29, 2020
@agilgur5 agilgur5 added solution: outdated This is not up-to-date with the current version and removed priority: in progress labels Mar 29, 2020
@zhaoyao91
Copy link
Author

@agilgur5 thanks for help
this is the original repo

Repository owner locked as resolved and limited conversation to collaborators Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
solution: outdated This is not up-to-date with the current version solution: workaround available There is a workaround available for this issue
Projects
None yet
Development

No branches or pull requests

2 participants