-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix svelte-stories-loader in Windows #133
Conversation
const parser = fileURLToPath(new URL('./collect-stories.js', import.meta.url)) | ||
.replace(/\\/g, "\\\\"); // For Windows paths; | ||
.replace(/\\/g, '/'); // For Windows paths; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call path.posix
instead
@@ -59,7 +59,7 @@ function transformSvelteStories(code: string) { | |||
|
|||
// throws dedent expression is not callable. | |||
// @ts-ignore | |||
return dedent`${codeWithoutDefaultExport} | |||
return `${codeWithoutDefaultExport} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove dedent? if we remove it I think you'll need to remove the comments on the lines above this as well as the import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a regression with dedent from Storybook v7. It doesn't handle correctly quoted backslash. I have added an example in the referenced issue.
Note that the vite loader doesn't use dedent either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will
source = dedent`${component.substr(start, end - start)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably. However here where are not generating invalid javacsript. at worst the source will have invalid breaking line, but we really need dedent here.
In fact, this issue is not related to windows and is caused by this commit: 02ce02a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would help to upgrade this project from dedent 1.2 to the latest version (1.5.1 if I recall correctly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're ok with this, let's create a new issue to improve the rendering of the source snippet.
I'd like to close this PR, it's the last issue for upgrading my stack to Svelte 4 & Storybook 7.4 ^^
Note: All my instances of Storybook work with this patch, SB7.4, Webpack5 and Svelte 4.2 |
🚀 PR was released in |
Fix #131