mattjennings / mdsvexamples

Render your Svelte code blocks in MDSveX
35 stars 3 forks source link

Support passing Wrapper as SvelteComponent #22

Closed janosh closed 1 year ago

janosh commented 1 year ago

Wrapper is currently set through an import path to a Svelte component. Would it be possible to allow passing in the component itself?

Reasoning: I'm using a CodeExample.svelte component from an NPM package across multiple projects. That component is not in the package's export map, meaning it's accessible as a named export but not a deep import:

import { CodeExample } from "svelte-zoo" // works
import CodeExample from "svelte-zoo/CodeExample.svelte" // doesn't work

and so this also doesn't work

Wrapper: `svelte-zoo/CodeExample.svelte`
mattjennings commented 1 year ago

I think the easiest solution here is to create your own svelte component that just forwards $$props onto CodeExample.

I’m happy to take a PR that would add support for this use case, in however form.

janosh commented 1 year ago

I think the easiest solution here is to create your own svelte component that just forwards $$props onto CodeExample.

Agreed but it would add boilerplate.

I’m happy to take a PR that would add support for this use case, in however form.

Good to know! I'll report back if I find time to work on this.

mattjennings commented 1 year ago

A bit late, but I've added support for this 0.4.0. See PR #28 or README for notes on how to use.