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

Cannot find prismjs components at runtime on Vercel #548

Open
Tracked by #588
CobyPear opened this issue Oct 29, 2023 · 2 comments
Open
Tracked by #588

Cannot find prismjs components at runtime on Vercel #548

CobyPear opened this issue Oct 29, 2023 · 2 comments
Labels
assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req environment An issue with the environment
Milestone

Comments

@CobyPear
Copy link

CobyPear commented Oct 29, 2023

My blog is using mdsvex to dynamically compile markdown files in a load fn in SvelteKit, then returns them to the client. I have been using {@html } for this and it works fine. I recently added a codeblock and I recieved an error after publishing the post:

Error: Cannot find module 'prismjs/components/prism-bash'
Require stack:
- /var/task/node_modules/.pnpm/mdsvex@0.10.6_svelte@3.58.0/node_modules/mdsvex/dist/main.cjs.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at e.<computed>._module.Module._load (/var/task/___vc/__launcher/__launcher.js:14:2079)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at load_language (/var/task/node_modules/.pnpm/mdsvex@0.10.6_svelte@3.58.0/node_modules/mdsvex/dist/main.cjs.js:25714:3)
    at code_highlight (/var/task/node_modules/.pnpm/mdsvex@0.10.6_svelte@3.58.0/node_modules/mdsvex/dist/main.cjs.js:25773:4)
    at /var/task/node_modules/.pnpm/mdsvex@0.10.6_svelte@3.58.0/node_modules/mdsvex/dist/main.cjs.js:25745:25
    at Array.map (<anonymous>)
    at /var/task/node_modules/.pnpm/mdsvex@0.10.6_svelte@3.58.0/node_modules/mdsvex/dist/main.cjs.js:25743:11

Do I need to install prismjs, and if so should it be listed as a peer dependency?
edit: I tried installing prismjs as a prod dependency and it still failed. I will try a CDN import in the script tag to workaround for now.
edit2: oh duh that didn't work since the module isn't found in the serverless fn, not the client side.

Thanks!

@steven-aj
Copy link

Have you tried <svelte:component this={content} /> instead of interpolating {@html content} on an element?

@CobyPear
Copy link
Author

Hi, @steven-aj. I have tried that but I get the following error which I'm not really sure where to start with:

Error: <svelte:component this={...}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <svelte:component this={...}>.

@pngwn pngwn modified the milestones: 1.0, 1.0 docs + integrations Feb 23, 2024
@pngwn pngwn added the environment An issue with the environment label Feb 23, 2024
@pngwn pngwn mentioned this issue Feb 23, 2024
13 tasks
@pngwn pngwn added the assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req environment An issue with the environment
Projects
None yet
Development

No branches or pull requests

3 participants