Skip to content
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

Imports in compile method #698

Open
Plmeks opened this issue Mar 6, 2025 · 0 comments
Open

Imports in compile method #698

Plmeks opened this issue Mar 6, 2025 · 0 comments

Comments

@Plmeks
Copy link

Plmeks commented Mar 6, 2025

Is it possible to make imports and custom components inside md work with compile method?
At official docs there is an example:

import { compile } from 'mdsvex';

const transformed_code = await compile(`
<script>
  import Chart from './Chart.svelte';
</script>

# Hello friends

<Chart />
`,
	mdsvexOptions
);`

But at Svelte 5 with such code:

// api

import { compile } from 'mdsvex';

export async function GET() {
...
const { code } = await compile(`
    <script>
      import Test from '$lib/Test.svelte'
    </script> 

    # Hi
    <Test />
 `);

console.log({ code })
}

The result is:

{
  code: '<script>\n' +
    "      import Test from '$lib/Test.svelte'\n" +
    '    </script>\n' +
    '\n' +
    '    <h1>Hi</h1>\n' +
    '    <Test />\n'
}

It converted md# to h1 but it doesn't recognize internal imports and custom component.
Thank you

@github-project-automation github-project-automation bot moved this to Triage + Refine in mdsvex Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage + Refine
Development

No branches or pull requests

1 participant