Closed swyxio closed 1 year ago
Given that this only happens in prod and not in dev, i have to conclude that this is because the prismjs transitive dep doesnt get bundled for serverless rendering
another bug to file for https://github.com/sveltejs/kit/issues/3535
i think this is the offending line
trying to solve it by installing prism
as a dependency, not transitive devdep https://app.netlify.com/sites/swyxkit/deploys/6399e77da4ac1300087a13c7
update: didnt work
was able to repro on a clean sveltekit install https://github.com/geoffrich/sveltekit-satori-mdsvex-test/pull/1
Yes same issue on codingcat rewrite.
For now I am manually importing to at least get most pages working.
import prism from 'prismjs';
import 'prismjs/components/prism-bash.js';
import 'prismjs/components/prism-dart.js';
import 'prismjs/components/prism-diff.js';
import 'prismjs/components/prism-typescript.js';
import 'prismjs/components/prism-jsx';
import 'prism-svelte';
another related bug:
tried to solve this problem by swapping out the syntax highlighter:
but the dynamic import and error is still happening.
i suspect because even tho the highlighter is swapped out, the metadata isnt https://github.com/pngwn/MDsveX/blob/6c60fe68c335fce559db9690fbf5e69ef539d37d/packages/mdsvex/src/transformers/index.ts#L541
I have the same issue with an Astro project.
Error - Cannot find module './prism-markup-templating' Require stack: - /var/task/.netlify/functions-internal/entry.js - /var/task/entry.js - /var/runtime/index.mjs
Error: Cannot find module './prism-markup-templating'
Require stack:
- /var/task/.netlify/functions-internal/entry.js
- /var/task/entry.js
- /var/runtime/index.mjs
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.resolve (node:internal/modules/cjs/helpers:108:19)
at /var/task/.netlify/functions-internal/entry.js:11692:38
at handleId (/var/task/.netlify/functions-internal/entry.js:11572:21)
at loadComponentsInOrder (/var/task/.netlify/functions-internal/entry.js:11590:11)
at Object.load (/var/task/.netlify/functions-internal/entry.js:11658:20)
at loadLanguages2 (/var/task/.netlify/functions-internal/entry.js:11684:48)
at ensureLoaded (/var/task/.netlify/functions-internal/entry.js:24461:37)
at runHighlighterWithAstro (/var/task/.netlify/functions-internal/entry.js:24470:5)
at AstroComponentInstance2.factory (/var/task/.netlify/functions-internal/entry.js:24488:35)
When I change my app from SSR to Static Rendering, prism works as intended, it seems.
i dont have a repro anymore but for future devs reading this, check out swyxkit. open your own issues with yoru own repro
i moved swyxkit off of esbuild recently (due to netlify issues) and found that all my page renders with code samples were failing (https://swyxkit.netlify.app/welcome now 404's because i did clumsy error handling) due to this new error:
i dont have prismjs as a dep so actually took a bit of digging (
npm ls prism-svelte
) to figure out that it was mdsvex.i dont know the direct cause yet but just filing an issue for others to find