okikio / bundlejs

An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
https://bundlejs.com
MIT License
751 stars 13 forks source link

could not build codemirror 6 correctly #41

Closed emergence75 closed 1 year ago

emergence75 commented 1 year ago

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...

okikio commented 1 year ago

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

okikio commented 1 year ago

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

emergence75 commented 1 year ago

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 ✨

okikio commented 1 year ago

Ok, I'll do some more research on this

okikio commented 1 year ago

This should provide context on what I think the error is here https://github.com/okikio/bundlejs/issues/43#issuecomment-1455547451

okikio commented 1 year ago

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

okikio commented 1 year ago

@emergence75 Take a look https://stackblitz.com/edit/vitejs-vite-iquaht?file=src%2Fmain.ts&terminal=dev

emergence75 commented 1 year ago

very cool ;-)

okikio commented 1 year ago

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

okikio commented 1 year ago

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