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 8 + Vite + Turbosnap => Failed to retrieve dependent story files #28973 #1027

Closed
julianCast opened this issue Aug 26, 2024 · 4 comments
Labels
bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation

Comments

@julianCast
Copy link

julianCast commented Aug 26, 2024

Describe the bug

Having the following:
Storybook: 8.2.5
React-Vite: 8.2.5
Turbosnap enabled (onlyChanged)

If I set onlyChanged: false everything works fine. I don't have any vite.config.ts file.

Structure

image

Main.ts

const config: StorybookConfig = {
  stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: [
    getAbsolutePath("@storybook/addon-a11y"),
    getAbsolutePath("@storybook/addon-links"),
    getAbsolutePath("@storybook/addon-essentials"),
    getAbsolutePath("@storybook/addon-interactions"),
  ],
  framework: {
    name: getAbsolutePath("@storybook/react-vite"),
    options: {},
  },
  async viteFinal(config, { configType }) {
    const { mergeConfig } = await import("vite");

    if (configType === "DEVELOPMENT") {
      // Your development configuration goes here
    }
    if (configType === "PRODUCTION") {
      // Your production configuration goes here.
    }
    return mergeConfig(config, {
      // Your environment configuration here
    });
  },
  typescript: {
    check: true,
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
    },
  },
  docs: {
    autodocs: true,
  },

Action.yml

image

I get the following error:

image

Reproduction link

Not provided

Reproduction steps

No response

System

Storybook Environment Info:

  System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M1 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 3.8.3 - ~/.nvm/versions/node/v20.12.2/bin/yarn <----- active
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
  Browsers:
    Chrome: 127.0.6533.122
    Edge: 128.0.2739.42
    Safari: 17.4.1
  npmPackages:
    @storybook/addon-a11y: ^8.2.5 => 8.2.5
    @storybook/addon-docs: ^8.2.5 => 8.2.5
    @storybook/addon-essentials: ^8.2.5 => 8.2.5
    @storybook/addon-interactions: ^8.2.5 => 8.2.5
    @storybook/addon-links: ^8.2.5 => 8.2.5
    @storybook/react: ^8.2.5 => 8.2.5
    @storybook/react-vite: ^8.2.5 => 8.2.5
    @storybook/test: ^8.2.5 => 8.2.5
    @storybook/test-runner: ^0.19.1 => 0.19.1
    eslint-plugin-storybook: ^0.8.0 => 0.8.0
    storybook: ^8.2.5 => 8.2.5

Additional context

Wasn't happening in Storybook 7

@julianCast julianCast added bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation labels Aug 26, 2024
@cgbl-90
Copy link

cgbl-90 commented Aug 26, 2024

@julianCast

We made an update as of CLI v.11.3.1 to check storybookBaseDir against your repository root as opposed to the cwd when using TurboSnap.

As of CLI v.11.3.2, we are using the cwd relative to the repo root as the default value for storybookBaseDir; if your project is in a subdirectory and you use workingDir to change your cwd, you shouldn't need to include storybookBaseDir unless it deviates from the cwd.

Can you set the storybookBaseDir option?

@julianCast
Copy link
Author

julianCast commented Aug 26, 2024

We made an update as of CLI v.11.3.1 to check storybookBaseDir against your repository root as opposed to the cwd when using TurboSnap.

As of CLI v.11.3.2, we are using the cwd relative to the repo root as the default value for storybookBaseDir; if your project is in a subdirectory and you use workingDir to change your cwd, you shouldn't need to include storybookBaseDir unless it deviates from the cwd.

Can you set the storybookBaseDir option?

Well, that worked THANK YOU! Now my question, just for me to understand. What I have done is to remove the storybookBaseDir option.

But since this the structure of my repo:

packages/pk1/package.json - scripts from where we call storybook.
packages/pk1/src/storybook/.storybook
packages/pk1/storybook-static

Shouldn't I have to set storybookBaseDir: "./src/storybook" since my cwd is set as workingDir: "./packages/pk1", or it will recursively look for the storybook folder?

Oh I think is because my main package.json has this script command:
"build-storybook": "yarn storybook build -c ./src/storybook/.storybook" so it links the proper storybook folder

@julianCast
Copy link
Author

Close as it works now, thank you @cgbl-90 .
Related issue #971 (comment)

@cgbl-90
Copy link

cgbl-90 commented Aug 27, 2024

hey @julianCast regarding your other question, you can send us an email at support@chromatic.com and we will take a closer look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation
Projects
None yet
Development

No branches or pull requests

7 participants
@julianCast @cgbl-90 and others