pablo-abc / svelte-markdown

Markdown parser to svelte components
MIT License
359 stars 50 forks source link

Error when using svelte-markdown in sveltekit #7

Closed asv7c2 closed 3 years ago

asv7c2 commented 3 years ago

Such error i got:

Cannot read property 'Lexer' of undefined

It installed as usual dependency. If i instal it as devdependency it cannot be found.

asv7c2 commented 3 years ago

Looks like something with sveltekit.

emme1444 commented 3 years ago

Hey @asv1! Did you ever get around this? I'm getting the same error.

asv7c2 commented 3 years ago

@emme1444 You need replace in file markdown-parser.js from import marked from 'marked' to import marked from 'marked/lib/marked.esm.js'. It because sveltekit wants esm module to import.

pablo-abc commented 3 years ago

@asv1 I had been scratching my head on how to solve it while not breaking other environments. Have you tested if changing the import would not break it for plain Svelte with Rollup or Sapper? If so I can make the change as a patch here.

asv7c2 commented 3 years ago

@pablo-abc Rollup can import esm? So is sapper to, i am right?

emme1444 commented 3 years ago

@asv1 Thanks for the quick response! I went a different route by using MDsveX instead. But good luck!

tomekrozalski commented 3 years ago

@pablo-abc it was closed, but issue still occurs when I try it with SvelteKit :(

pablo-abc commented 3 years ago

@tomekrozalski which version of this package are you using? I'm currently using this with SvelteKit here without any issues. Are you getting the same error as the original issue?