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

The requested module does not provide an export named 'createMarkdownRenderer' #1752

Closed
3 tasks done
TotomInc opened this issue Jan 2, 2023 · 3 comments
Closed
3 tasks done
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@TotomInc
Copy link

TotomInc commented Jan 2, 2023

Describe the bug

Hi, I am trying to import and use a custom Markdown renderer inside a component but it looks like the createMarkdownRenderer function is not exported.

Uncaught SyntaxError: The requested module '/@fs/Users/xyz/.github/xyz/node_modules/vitepress/dist/client/index.js?v=61ac765b' does not provide an export named 'createMarkdownRenderer' (at EndpointExample.vue:2:10)

However, according to TypeScript types exported from VitePress, createMarkdownRenderer should be available for use.

Reproduction

<script setup lang="ts">
import { createMarkdownRenderer } from "vitepress";

const props = defineProps<{
  requests: { type: string; content: string; }[];
  response: string;
}>();

// `createMarkdownRenderer` is not exported from vitepress.
const md = await createMarkdownRenderer(".");
const response = md.render(props.response);
</script>

Expected behavior

The function createMarkdownRenderer should be exported as it is available from TypeScript types. If it should not, then remove the createMarkdownRenderer type export.

System Info

System:
    OS: macOS 12.6
    CPU: (8) arm64 Apple M1 Pro
    Memory: 116.75 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Brave Browser: 108.1.46.144
    Chrome: 108.0.5359.124
    Firefox: 103.0.2
    Safari: 16.0

Additional context

Please note that I am trying to create a custom markdownRenderer so that I can create a code render from my component props.

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@TotomInc TotomInc added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 2, 2023
@brc-dd
Copy link
Member

brc-dd commented Jan 2, 2023

It is a server side function. It won't be accessible inside a Vue component.

@brc-dd brc-dd closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2023
@TotomInc
Copy link
Author

TotomInc commented Jan 2, 2023

Thanks for your answer.

Any ideas on how can I use this server-side API on an SSR component with VitePress?

@brc-dd
Copy link
Member

brc-dd commented Jan 2, 2023

You can use static data imports. Basically, create a file ending with .data.ts, then inside it you can have content like this: https://github.com/vuejs/vitepress/blob/main/__tests__/e2e/static-data/static.data.ts Then if you import data from it, it will be embedded as JSON during build. (#794 (comment), #1291 (reply in thread))

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants