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

Turbosnap and barrel imports #4

Open
ITsvetkoFF opened this issue Feb 14, 2023 · 5 comments
Open

Turbosnap and barrel imports #4

ITsvetkoFF opened this issue Feb 14, 2023 · 5 comments

Comments

@ITsvetkoFF
Copy link

This is an issue intended to open a discussion about how turbosnap works with the codebases that are using barrel imports.

I've noticed that if in the story some imports are from index files - all the files that are in these index files are considered to be changed by turbosnap. This may be similar to webpack problems described here and here

This is especially important for us since we're trying to make the code in stories usable as is, so we have imports from @company/ui-library in story code which is mapped to index file.

Any suggestions for a workaround for that issue?

@IanVS
Copy link
Owner

IanVS commented Feb 14, 2023

@ghengeveld is this something that would need to change on Chromatic's side? @ITsvetkoFF, are all of the imports of the barrel file found in the output from this plugin?

There's also storybookjs/storybook#19228 which needs to also be implemented for vite, but I'm uncertain whether it would have any impact on what you are experiencing here.

@ITsvetkoFF
Copy link
Author

@IanVS if you mean preview-stats.json contents, yeah :) it has a lot of modules, since we're using

    rollupOptions: {
      output: {
        preserveModules: true,
      },
}

in our Vite config, this file is 12K lines of code... :)

@IanVS
Copy link
Owner

IanVS commented Feb 15, 2023

Sorry no, I mean your .storybook/preview.js importing something that might pull in lots of modules. That file is included in every story, which can be a reason that your first story, even if it's simple, could pull in a lot of modules.

@ITsvetkoFF
Copy link
Author

ITsvetkoFF commented Feb 15, 2023

It does import 1 file but its path is aggressively ignored by using --untraced CLI flag

@IanVS
Copy link
Owner

IanVS commented Feb 15, 2023

Sorry, I was getting this issue confused with another. But that's still good info. I'm not sure what can be done, right now, but if you're able to dig in and get some ideas of ways this can be improved, I'd be happy to discuss/review. But like I said, the whole plugin needs to be rebuilt to accommodate storybookjs/storybook#19228, but I don't have the time at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants