vite-plugin-svelte: Error including `bytemd` dependency

Describe the bug

Someone on Discord reported that they can’t get bytemd to work. It looks to me like vite-plugin-svelte is not detecting that bytemd’s lodash.debounce dependency needs to be prebundled. There are also issues reported in the bytemd repo and on Discord where the error occurs on other dependencies

A couple things I noticed that are off about the packaging:

  • bytemd uses .esm.js and .cjs.js extensions instead of .mjs and .cjs
  • lodash.debounce has no main or any other entry point specified in the package.json

Even when I manually edit those I still get the same error.

Reproduction

https://github.com/benmccann/sveltekit-bytemd-bug-reproduction

Logs

8:07:24 PM [vite] Error when evaluating SSR module /node_modules/lodash.debounce/index.js?v=dc88d06f:
ReferenceError: module is not defined
    at /node_modules/lodash.debounce/index.js?v=dc88d06f:377:1

System Info

reproduction provided

Severity

The top two bugs in the bytemd repo are about how the project doesn’t work with SvelteKit: https://github.com/bytedance/bytemd/issues/96 and https://github.com/bytedance/bytemd/issues/139

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments