ssssota / svelte-exmarkdown

Svelte component to render markdown.
https://ssssota.github.io/svelte-exmarkdown
MIT License
177 stars 6 forks source link

Package breaks apps deployed to Cloudflare Pages #114

Closed shyakadavis closed 8 months ago

shyakadavis commented 10 months ago

Hi, @ssssota

Great work on svelte-exmarkdown. Thank you.

As I was trying to use it for my use case, I ran into some challenges, some highlighted in #113, but so far, the most pressing is the fact that when using this package in the Cloudflare Pages environment, they break, for reasons, more or less, related to how CF doesn't support a true node runtime - or so I hear.

These are the errors output in the console.

20:14:27.378 | ✘ [ERROR] Could not resolve "node:process"
-- | --
20:14:27.379 |  
20:14:27.379 | .svelte-kit/output/server/entries/pages/_page.svelte.js:3:17:
20:14:27.380 | 3 │ import proc from "node:process";
20:14:27.380 | ╵                  ~~~~~~~~~~~~~~
20:14:27.381 |  
20:14:27.381 | The package "node:process" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
20:14:27.381 |  
20:14:27.381 | ✘ [ERROR] Could not resolve "node:path"
20:14:27.381 |  
20:14:27.382 | .svelte-kit/output/server/entries/pages/_page.svelte.js:4:17:
20:14:27.382 | 4 │ import path from "node:path";
20:14:27.382 | ╵                  ~~~~~~~~~~~
20:14:27.382 |  
20:14:27.382 | The package "node:path" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
20:14:27.382 |  
20:14:27.382 | ✘ [ERROR] Could not resolve "node:url"
20:14:27.383 |  
20:14:27.383 | .svelte-kit/output/server/entries/pages/_page.svelte.js:5:30:
20:14:27.383 | 5 │ import { fileURLToPath } from "node:url";
20:14:27.383 | ╵                               ~~~~~~~~~~
20:14:27.383 |  
20:14:27.383 | The package "node:url" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
20:14:27.383 |  
20:14:27.384 | error during build:
20:14:27.384 | Error: Build failed with 3 errors:
20:14:27.384 | .svelte-kit/output/server/entries/pages/_page.svelte.js:3:17: ERROR: Could not resolve "node:process"
20:14:27.384 | .svelte-kit/output/server/entries/pages/_page.svelte.js:4:17: ERROR: Could not resolve "node:path"
20:14:27.385 | .svelte-kit/output/server/entries/pages/_page.svelte.js:5:30: ERROR: Could not resolve "node:url"

Are you aware of a project that used this package running on Cloudflare?

If not, is there a fix for people who use Cloudflare for hosting/deployments?

Thank you for the consideration.

ssssota commented 10 months ago

This project is not using node:* packages. I think there is a problem unrelated to this library.

If you need further assistance, please provide a repro repository.

shyakadavis commented 10 months ago

Hi, @ssssota

Don't know how I forgot to attach it.

But here is the repro. https://github.com/shyakadavis/svelte-exmarkdown

Please let me know if you require anything else.

ssssota commented 10 months ago

I was able to reproduce! I'll check back later.

ssssota commented 10 months ago

It seems that the VFile package, which is indirectly used internally, uses the node:* module. (ref) That is where the error occurred.

I'm still working on a solution.

sadfun commented 9 months ago

Same issue. Very much looking forward to the solution