okikio/bundlejs

could not build codemirror 6 correctly

emergence75 opened this issue · 10 comments

just tried the tool on https://bundlejs.com/

with option set
"format": "iife",
"minify": false,

using this logic descriped here to build a codemirror 6
https://codemirror.net/examples/bundle/

import {EditorView, basicSetup} from "codemirror"
import {javascript} from "@codemirror/lang-javascript"

let editor = new EditorView({
extensions: [basicSetup, javascript()],
parent: document.body
})

when building the console brings me
Bundling 🚀

Fetch https://unpkg.com/@codemirror/lang-javascript@latest
Fetch https://unpkg.com/codemirror@latest
Fetch https://unpkg.com/@lezer/common@%5E1.0.0
Fetch https://unpkg.com/@lezer/javascript@%5E1.0.0
Fetch https://unpkg.com/@codemirror/language@%5E6.6.0
Fetch https://unpkg.com/@codemirror/state@%5E6.0.0
Fetch https://unpkg.com/@codemirror/view@%5E6.0.0
Fetch https://unpkg.com/@codemirror/autocomplete@%5E6.0.0
Fetch https://unpkg.com/@codemirror/lint@%5E6.0.0
Fetch https://unpkg.com/@codemirror/language@%5E6.0.0
Fetch https://unpkg.com/@codemirror/commands@%5E6.0.0
Fetch https://unpkg.com/@codemirror/search@%5E6.0.0
Fetch https://unpkg.com/@lezer/highlight@%5E1.1.3
Fetch https://unpkg.com/@lezer/lr@%5E1.3.0
Fetch https://unpkg.com/@codemirror/view@%5E6.6.0
Fetch https://unpkg.com/w3c-keyname@%5E2.2.4
Fetch https://unpkg.com/@codemirror/state@%5E6.1.4
Fetch https://unpkg.com/style-mod@%5E4.0.0
Fetch https://unpkg.com/crelt@%5E1.0.5
Fetch https://unpkg.com/@codemirror/state@%5E6.2.0
Fetch https://unpkg.com/@lezer/highlight@%5E1.0.0

Done ✨

the problem with this is, that multiple versions e.g state or view are also included and the generated codemirror js does not work...
testing the generated code brings
Uncaught Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.

by the way, cool project...

I'll look into this, thanks for creating an issue

@emergence75 Please take a look. I've pushed a possible fix out, did this fix the issue you were having?

just testet...

https://bundlejs.com/?q=%28import%29codemirror%2C%28import%29%40codemirror%2Flang-javascript&treeshake=%5B%7BEditorView%2CbasicSetup%7D%5D%2C%5B%7Bjavascript%7D%5D&text=%22let+editor+%3D+new+EditorView%28%7B%5Cnextensions%3A+%5BbasicSetup%2C+javascript%28%29%5D%2C%5Cnparent%3A+document.body%5Cn%7D%29%22&config=%7B%22esbuild%22%3A%7B%22format%22%3A%22iife%22%2C%22minify%22%3Afalse%7D%7D

same problem...

Initialized 🚀✨

Bundling 🚀

Fetch https://unpkg.com/codemirror@latest
Fetch https://unpkg.com/@codemirror/lang-javascript@latest
Fetch https://unpkg.com/@codemirror/language@%5E6.6.0
Fetch https://unpkg.com/@codemirror/state@%5E6.0.0
Fetch https://unpkg.com/@lezer/javascript@%5E1.0.0
Fetch https://unpkg.com/@lezer/common@%5E1.0.0
Fetch https://unpkg.com/@codemirror/autocomplete@%5E6.0.0
Fetch https://unpkg.com/@codemirror/language@%5E6.0.0
Fetch https://unpkg.com/@codemirror/view@%5E6.0.0
Fetch https://unpkg.com/@codemirror/view@%5E6.6.0
Fetch https://unpkg.com/style-mod@%5E4.0.0
Fetch https://unpkg.com/@lezer/lr@%5E1.3.0
Fetch https://unpkg.com/@codemirror/state@%5E6.1.4
Fetch https://unpkg.com/w3c-keyname@%5E2.2.4
Fetch https://unpkg.com/@lezer/highlight@%5E1.0.0
Fetch https://unpkg.com/@lezer/highlight@%5E1.1.3
Fetch https://unpkg.com/@codemirror/lint@%5E6.0.0
Fetch https://unpkg.com/@codemirror/search@%5E6.0.0
Fetch https://unpkg.com/@codemirror/commands@%5E6.0.0
Fetch https://unpkg.com/@codemirror/state@%5E6.2.0

Fetch https://unpkg.com/crelt@%5E1.0.5

Done ✨

Ok, I'll do some more research on this

This should provide context on what I think the error is here #43 (comment)

I now have a fix, I'll try to get it out by tmrw

very cool ;-)

I've not yet added the fix to the bundlejs.com website but as you can see it's now fixed and the fix should be published soon

I forgot to update this issue, I already added support for this on the bundlejs website, so this should be fixed everywhere now