hashmd: Cant get this working in Svelte Kit

Hi I can’t seem to get this working in Svelte Kit.

Like all my other modules:

[vite] Error when evaluating SSR module /node_modules/remark-parse/index.js?v=94403ef9:
ReferenceError: module is not defined
    at /node_modules/remark-parse/index.js?v=94403ef9:3:1
    at instantiateModule (/Users/marcgodard/Documents/Github/swp-crm/node_modules/vite/dist/node/chunks/dep-0ed4fbc0.js:69982:166)

And If I turn SSR off I get:

[vite] Internal server error: Cannot find module './transformers/module'

Has anyone gotten this working yet?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 10
  • Comments: 34 (7 by maintainers)

Most upvoted comments

After upgrading to bytemd@^1.12.4 Sveltekit is working w/o needing to use VanillaJS config or optimizeDeps. Thanks.

Yep I have the same problem 😭

Yep, same here

module is not defined

ReferenceError: module is not defined
    at /node_modules/lodash.debounce/index.js?v=5d239c0d:373:1
    at instantiateModule (/home/virgiled/Projects/lookout-radar/wl-vision-1/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73464:166)

Hi all, thanks for providing so much context for this issue!

I have provided an example here, which is built with the latest version of SvelteKit (with tag next). Hope this can help

Hi @MarcGodard, sorry for make pollution to your thread. I think you have 2 issue here. First

[vite] Error when evaluating SSR module /node_modules/remark-parse/index.js?v=94403ef9:
ReferenceError: module is not defined
    at /node_modules/remark-parse/index.js?v=94403ef9:3:1
    at instantiateModule (/Users/marcgodard/Documents/Github/swp-crm/node_modules/vite/dist/node/chunks/dep-0ed4fbc0.js:69982:166)

This caused by ESM problem like we discuss above. Remark parse is cjs module. It cannot work on vite (svelte-kit). So to make this package work we must change how the way cjs module imported or use the esm module version of the module (if exists). Not only remark-parse, the following module is also cjs module: lodash.debounce, lodash.throttle, remark-rehype, etc. So we just wait for maintainer update their dependency from cjs to esm version or change how the module imported For now, I try to copy this bytemd from node_modules to src/vendor and change the code and update the dependency manually.

Second

[vite] Internal server error: Cannot find module './transformers/module'

May be this is different Issue. I cannot reproduce this in my project even I turn off ssr mode.

Ok, thanks for the advice @benwoodward 😊

Would also love to see this issue resolved, just upgraded my project to SvelteKit and now it seems like my editor doesn’t work.