IanVS / vite-plugin-turbosnap

Enables the use of Chromatic Turbosnap in vite storybook projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Turbosnap and barrel imports

ITsvetkoFF opened this issue · comments

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?

@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.

@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... :)

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.

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

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.