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

[Bug] Doesn't work on Windows anymore #131

Closed
j3rem1e opened this issue Aug 29, 2023 · 3 comments · Fixed by #133
Closed

[Bug] Doesn't work on Windows anymore #131

j3rem1e opened this issue Aug 29, 2023 · 3 comments · Fixed by #133
Labels
bug Something isn't working released This issue/pull request has been released.

Comments

@j3rem1e
Copy link
Contributor

j3rem1e commented Aug 29, 2023

Describe the bug

The v3 of this plugin doesn't work on Windows anymore.

  • It fails because it can't find "collect-stories.js" with a wrong path
  • It fails with stories containing sources with \n

Steps to reproduce the behavior

  1. Create a storybook with this addon
  2. Compile it under windows

Screenshots and/or logs

ModuleNotFoundError: 
Module not found: 
Error: Can't resolve 
'C:\Users\MyApp\projode_modules\@storybook\addon-svelte-csf\dist\parser\collect-stories.js' 

NB: "projode_modules" should be "proj\node_module" but \n has been removed

Environment

  • OS: Windows
  • Node.js version: v16
  • NPM version: 8.11

Additional context

It caused by this commit : 0f5bf98
"Fixed" by this one : fa5505b#diff-c5f119d3c0fad64afb4a542f1fb2bdf0e475cc6191a63712dbfba50bb5af6c3c

However, it's better to replace backslash with juste slash for windows.

After fixing this issue, the stories containing sources with multilines doesn't compile either. The generated stories contains invalid json.
For example:

   const { default: parser } = require('C:/Users/MyApp/proj/node_modules/@storybook/addon-svelte-csf/dist/parser/collect-stories.js');
   const __storiesMetaData = parser(Spacer_stories, {"meta":{"title":"Component/Core/Spacer"},"stories":{"spacer":{"storyId":"component-core-spacer--spacer","name":"Spacer","template":false,"source":"<Surface row>\r
\t<Button>A</Button>\r
\t<Spacer/>\r
\t<Button>B</Button>\r
</Surface>","hasArgs":false}},"allocatedIds":["default","Meta","Story","Surface","Button","Spacer"]});
   export default __storiesMetaData.meta;
   export const spacer = __storiesMetaData.stories["spacer"];
@j3rem1e j3rem1e added the bug Something isn't working label Aug 29, 2023
@j3rem1e
Copy link
Contributor Author

j3rem1e commented Aug 30, 2023

After analysing a little more this issue, it`s caused by "dedent".

const myObject = { name: "my\nname" };
console.log(dedent`--> ${JSON.stringify(myObject)}`);

print :

--> {"name":"my
name"}

@j3rem1e
Copy link
Contributor Author

j3rem1e commented Aug 31, 2023

In fact, it's caused by this commit 02ce02a by @hobbes7878

@shilman
Copy link
Member

shilman commented Aug 31, 2023

🚀 Issue was released in v4.0.1 🚀

@shilman shilman added the released This issue/pull request has been released. label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants