touchifyapp / svelte-codemirror-editor

A svelte component to create a CodeMirror 6+ editor
https://touchifyapp.github.io/svelte-codemirror-editor/
MIT License
175 stars 24 forks source link

The example in README.md cannot compile because `@codemirror/lang-javascript` is missing #22

Closed vincenzoml closed 1 week ago

vincenzoml commented 11 months ago

Trying to run the example provided in README.md I get:

[plugin:vite:import-analysis] Failed to resolve import "@codemirror/lang-javascript" from "src/components/SpecEditor.svelte". Does the file exist?
19 |  import "svelte/internal/disclose-version";
20 |  import CodeMirror from "svelte-codemirror-editor";
21 |  import { javascript } from "@codemirror/lang-javascript";
   |                              ^
22 |  const file = "src/components/SpecEditor.svelte";
SomaticIT commented 11 months ago

Hi, Thank you for your issue. Did you install the package : npm install @codemirror/lang-javascript?

vincenzoml commented 11 months ago

Yes I did! It ought to be better to mention this in the same README where the example is presented, it is confusing for those who have not used codemirror before.

------ Messaggio originale ------ Da "Maxime LUCE" @.> A "touchifyapp/svelte-codemirror-editor" @.> Cc "Vincenzo Ciancia" @.>; "Author" @.> Data 21/09/2023 12:18:19 Oggetto Re: [touchifyapp/svelte-codemirror-editor] The example in README.md cannot compile because @.***/lang-javascript` is missing (Issue #22)

Hi, Thank you for your issue. Did you install the package : npm install @codemirror/lang-javascript?

— Reply to this email directly, view it on GitHub https://github.com/touchifyapp/svelte-codemirror-editor/issues/22#issuecomment-1729280040, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARNM5J3FOFRHJLA7TQQNB3X3QH6XANCNFSM6AAAAAA47OMERQ. You are receiving this because you authored the thread.Message ID: @.***>

firehudson commented 4 months ago

@vincenzoml just follow the documentation and add followign to vite.config.ts https://github.com/touchifyapp/svelte-codemirror-editor?tab=readme-ov-file#usage-with-vite--svelte-kit

// vite.config.js
const config = {
    //...
    optimizeDeps: {
        exclude: ["codemirror", "@codemirror/language-javascript" /* ... */],
    },
    //...
}
SomaticIT commented 1 week ago

Thanks @firehudson