-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
enhanced-img is no longer a Svelte preprocessor, breaking compatibility with mdsvex #13842
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
Comments
Would it work to change it to this?
The other fix might be to make mdsvex a vite plugin. That probably wouldn't happen in the short-term, but if the preprocessor API got removed in favor of bundler plugins it could happen one day. Then we could have the order be mdsvex -> enhanced-img -> svelte. (The image plugin expects to operate on a Svelte file so it must come before the Svelte plugin because the Svelte compiler converts the Svelte file to a JS file) |
Thanks for the quick answer! I oversimplified the reproduction a bit. On real markdown files, it fails on various occasions: It will fail on CSS:
```css
.foo {
display: none
}
```
On JSON too:
```json
{
"foo": "bar"
}
```
On LaTeX:
$$
\text{score} = 5 \cdot \frac{\displaystyle \sum_{\text{article}} \text{weight}}{\cosh\left(\text{\# matches} - 1.5\right)}
$$
It will fail on unclosed tags: `<button>`. |
The issue here is that vite plugin svelte runs preprocess and compile within the same transform so other plugins cannot get the preprocessed output to further change that before compile. This can be inserted in the middle is a bit tricky though, have to think about it. |
Splitting them in two would be really nice and have other benefits for debugging: sveltejs/vite-plugin-svelte#729 |
so regarding ordering, vite-plugin-svelte currently still uses Another way would be with hook level ordering hints, but that would require the plugin authors to deal with it. |
@pngwn has said he will convert mdsvex to be a Vite plugin (it might be nice to use https://unplugin.unjs.io/ in order to keep support for webpack, etc.). Feel free to put together a PR if you'd like to expedite the process |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Hi!
In 0.4,
@sveltejs/enhanced-img
was built as a Svelte preprocessor, allowing it to run after mdsvex transformations.Starting in 0.5, this is no longer the case, it's a generic Vite plugin.
This is an issue as
@sveltejs/enhanced-img
now parses all Svelte code, including .svx files, by itself through svelte-parse-markup, which does not have preprocessing built-in.Reproduction
This
.svx
file is not a valid Svelte file, but as it contains<enhanced:img
, it will be parsed as if(If you want a full blown repository, you can clone https://github.com/GauBen/gautier.dev/tree/repro, run
yarn vite-node src/index.js
to trigger the error)Logs
This will fail with this error:
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: