Open peterpeterparker opened 1 year ago
Well, this was certainly an annoying and confusing bug. Especially since everything seemed to work fine with the dev server, but breaks badly in production build.
Given this source code:
There is this output in dev mode:
<style>
body {background: red !important;}
</style>
But there is this output in production build mode:
<style>body{background:red!important}</style>
If I add a language to the beginning of the code fence like this:
```html
Then the output is colored with syntax highlighting in both modes, but the spaces are still removed in production build mode as shown above.
Given this source code:
There is this output in dev mode:
<style>
// A comment
.something {color: red;}
</style>
But during production build, there is a crash with this error:
So it seems like this source code is being "picked up" in an undesired way by the postcss and/or lightningcss compilers/tools.
I also tried disabling lightningcss, but it's clear that the code is still processed in an undesirable way by postcss alone. The output is still somewhat mangled, some spaces are removed.
It seems like the solution here should be to have MDsveX somehow say that this piece of source code is "marked as verbatim" so that it doesn't get picked up by any part of the compiler toolchain. In order to that, one would also have to guarantee that MDsveX runs before those other compilers/tools.
I've seen solutions like that in other frameworks before. For example the verbatim
tag in Django. But I have no idea how to do that in Svelte(Kit).
But I managed to workaround the problem by escaping the tags in the source code, like this:
\<style> // A comment .something {color: red;}
I have no idea how safe this is, or if it will work for any inner code, but it seems to work fine so far.
Hi,
In one of our pages or our UI library we display following block of code that contains a Scss import.
When building with Svelte v3 we do not get any error and block is generated as expected. However, when we try to build with Svelte v4, it seems that the block of code becomes an effective code that Svelte tries to build because we get following error:
Not sure if it's a bug per sé or anything that can be done on our side to prevent Svelte v4 to intepret the documented code as effective code?