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

Storybook does not resolve paths from TS config #528

Closed
dhruvkb opened this issue Aug 8, 2021 · 1 comment · Fixed by #589
Closed

Storybook does not resolve paths from TS config #528

dhruvkb opened this issue Aug 8, 2021 · 1 comment · Fixed by #589
Assignees
Labels
ready Ready for implementation restricted: maintainers Only maintainers can resolve this issue work: frontend Related to frontend code in the mathesar_ui directory

Comments

@dhruvkb
Copy link
Member

dhruvkb commented Aug 8, 2021

Description

The TypeScript config file tsconfig.json defines paths as follows:

"paths": {
  "@mathesar/*": ["src/*"],
  "@mathesar-components-dir/*": ["src/components/*"],
  "@mathesar-components/types": ["src/components/types.d.ts"],
  "@mathesar-components": ["src/components/index.ts"]
}

which allows us to import using a much cleaner syntax:

import { portal } from '@mathesar-components';

These paths are not resolved by Storybook and thus stories written for components that use such imports do not compile.

Expected behavior

Storybook should use the same TS config and resolve paths.

To Reproduce

  1. Add the .svelte extension to src/components/modal/__meta__/Modal.stories.
  2. Run Storybook.

Additional context

Aliases set at the bundler level can be configured for Storybook using the webpackFinal field or viteFinal field in main.js but since these paths are set at the TypeScript level instead, I'm not sure what needs to be done.

@dhruvkb dhruvkb mentioned this issue Aug 8, 2021
7 tasks
@pavish pavish added this to the 2021-08 improvements milestone Aug 9, 2021
@pavish pavish added ready Ready for implementation work: frontend Related to frontend code in the mathesar_ui directory labels Aug 9, 2021
@kgodey kgodey added the help wanted Community contributors can implement this label Aug 9, 2021
@pavish pavish added the good first issue Everything in "Help wanted", PLUS being relatively easy and straightforward to implement. label Aug 9, 2021
@pavish
Copy link
Member

pavish commented Aug 9, 2021

We do have paths at each level (at TS, vite and jest levels). Currently we read it only from TS config, convert to respective formats while using them at the various levels. This ensures that we have a single source of truth.

We have to follow the same approach for Storybook. I would recommend going with the webpackFinal field, as it is the native bundler used by storybook.

@pavish pavish self-assigned this Aug 18, 2021
@pavish pavish added restricted: maintainers Only maintainers can resolve this issue and removed good first issue Everything in "Help wanted", PLUS being relatively easy and straightforward to implement. help wanted Community contributors can implement this labels Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Ready for implementation restricted: maintainers Only maintainers can resolve this issue work: frontend Related to frontend code in the mathesar_ui directory
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants