pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.36k stars 102 forks source link

Getting Vite error on when importing `compile` #255

Open benaltair opened 3 years ago

benaltair commented 3 years ago

When including import { compile } from 'mdsvex'; in a route I immediately get the following error:

SyntaxError: The requested module '/@id/__vite-browser-external:path' does not provide an export named 'join'

This happens without using compile anywhere and it immediately fixed when removing the import.

Running Svelte Kit 1.0.0-next.103 with standard (for Kit so far) config.

pngwn commented 3 years ago

It is probably using the normal esm module which expects a node environment currently. There is a browser module, I don't know if there is a way to tell vite which to use. I am yet to add the new entrypoints to mdsvex but it does have a browser field.

pixelscript commented 3 years ago

I got around this by using: import * as mdsvex from 'mdsvex/dist/browser-umd';

pngwn commented 3 years ago

Using proper ESM export paths might fix this.

techydad05 commented 2 years ago

When including import { compile } from 'mdsvex'; in a route I immediately get the following error:

SyntaxError: The requested module '/@id/__vite-browser-external:path' does not provide an export named 'join'

This happens without using compile anywhere and it immediately fixed when removing the import.

Running Svelte Kit 1.0.0-next.103 with standard (for Kit so far) config.

did you ever figure this out?

benaltair commented 2 years ago

did you ever figure this out?

@techydad05 Unfortunately not, I just went with a different solution entirely.

git-no commented 2 years ago

Same issue here. Error import path__default, { join } from 'path';. Svelte v 3.46.4. I need compilebecause there are no markdown files in my repo, I fetch markdown via api Unfortunately MDSeveX is a show stopper on my repo. Hope it gets solved soon :-)

tim-ming commented 1 year ago

Following https://gist.github.com/FbN/0e651105937c8000f10fefdf9ec9af3d vite build runs without problems.