Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '$$') #11

Open
tzwm opened this issue Oct 28, 2023 · 6 comments · May be fixed by #48
Open

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '$$') #11

tzwm opened this issue Oct 28, 2023 · 6 comments · May be fixed by #48

Comments

@tzwm
Copy link

tzwm commented Oct 28, 2023

I used this package in the Svelte:

image
@afiorillo
Copy link

I have the same issue. I made an example/+page.svelte with almost exactly the example given on the README and it encounters the same error.

<script lang="ts">

    import { Editor, Viewer } from 'bytemd'
    import gfm from '@bytemd/plugin-gfm'
  
    let value: string = "";
    const plugins = [
      gfm(),
      // Add more plugins here
    ]
  
    function handleChange(e) {
      value = e.detail.value
    }
</script>

<style type="text/css">
    @import "bytemd/dist/index.css";
</style>

<template>
    <Editor {value} {plugins} on:change={handleChange} />
</template>

@afiorillo
Copy link

I dug a bit further on this and concluded it's because Bytemd doesn't like Vite / Sveltekit out-of-the-box.

Adding

export default defineConfig({
  // ...
  optimizeDeps: { exclude: ["bytemd"]},
}

To my vite.config.js file seems to have resolved that error.

@0gust1
Copy link

0gust1 commented Dec 26, 2023

I don't know what happened with this repository: there was already an issue on this, but it disappeared: https://github.com/bytedance/bytemd/issues/269 (broken link). I guess the maintainers deleted the repo and recreated it under the same name, thus loosing the previous issues.

Nevertheless, I can confirm that @afiorillo 's solution works (I reported the trick in the issue above)

Additionally, we have a warning (with sveltekit v2 & svelte v4)

[vite-plugin-svelte] WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte.

[email protected]

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition for details.

@MarcGodard
Copy link

This fix didn't work for me.

@ym755680
Copy link

This fix didn't work for me. either, I'm using vue-cli

@IAkumaI
Copy link

IAkumaI commented Aug 7, 2024

Does not work at all.
The whole lib seems to be broken on sveltekit.

@CaptainCodeman CaptainCodeman linked a pull request Sep 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants