pablo-abc / svelte-markdown

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

import fails and custom components not rendered #25

Closed lajoiemedia closed 3 years ago

lajoiemedia commented 3 years ago

There are two issues:

  1. import SvelteMarkdown from "svelte-markdown" fails with the following error:

ModuleNotFoundError: Could not find module in path: 'svelte-markdown' relative to '/App.svelte'

Here's a sandbox showing the problem (Note that this is not specific to the codesandbox setup since the same is happening in my code):

sandbox1

The workaround I'm using is to use this import statement instead:

import SvelteMarkdown from "svelte-markdown/src/index.js";

  1. Custom components do not render. Here's a codesandbox that shows the problem:

sandbox2

Here the Phone component is ignored. Instead what gets rendered is:

<p>Call me <strong>anytime</strong> at <phone></phone>1-800-GEE-WHIZ</p></main>

This is a great project and I'd love to get it working for my use case. Thanks.

lajoiemedia commented 3 years ago

OK, the solution for the first part was adding svelte to the the resolve.mainFields list in webpack.config.js.

{
    ...,
    resolve: {
        ...,
        mainFields: ["svelte", "browser", "module", "main"],
    },
}

The second problem remains.

lajoiemedia commented 3 years ago

OK, I understand that html style elements in markdown are not handled by this package. Marking the issue closed/invalid.