Closed happycollision closed 4 years ago
Do you get any errors specifically or does it just silently fail? I'm actually changing to a different parser in a current rewrite but I'd like to understand what is happening here.
The only message in the terminal is the giant blob of json which seems to come from about line 6098 of node_modules/markdown-it/dist/markdown-it.js
✗ client
Unexpected token (Note that you need rollup-plugin-json to import JSON files)
1: {"Aacute":"\u00C1","aacute":"\u00E1","Abreve":"\u0102","abreve":"\u0103","ac":"\u223E","acd":"\u223F","acE":"\u223E\u0333","Acirc":"\u00C2","acirc":"\u00E2","acute":"\u00B4","Acy":"\u0410","acy":"\u0430","AElig":"\u00C6","aelig":"\u00E6","af":"\u2061", ETC, ETC, ETC}
(ETC is a placeholder for a lot more)
You would get this error if you were just using markdown-it
on its own. markdown-it
uses some JSON files as well as javascript and rollup doesn't handle them by default.
The solution is in the message: Note that you need rollup-plugin-json to import JSON files
if you install and apply rollup-plugin-json
(which is now @rollup/plugin-json
) then this error would go away.
You would, however, get another error regarding punycode
and you'd have to provide an alternative for that in the browser.
The short version of all of this is that markdown-it
is a pain to use in the browser and has a few quirks which are just some of the reasons I'm moving away from it.
Actually, @pngwn, I was using markdown-it just fine when NOT using MDsveX. I could literally transcribe the MDsveX template to Svelte and the error disappeared and my markdown rendered. So, I don’t think it is a Rollup issue.
Or if it is, it is being surfaced by the combination of MDsveX and markdown-it together.
If I install markdown-it
and try to use it in a Svelte component without mdsvex i get the same errors and those errors are expected given the nature of markdown-it
's dependencies, so I'm not sure why mdsvex would be causing these issues.
That's pretty much it. Even if you try and import via a Svelte component that uses it, you are toast. So I just switched to using
marked
for my runtime Markdown renders.