ionide-vscode-fsharp icon indicating copy to clipboard operation
ionide-vscode-fsharp copied to clipboard

Use ESBuild instead of Webpack

Open nojaf opened this issue 2 years ago • 11 comments

Hello, as webpack is no longer what the cool kids use, I'm wondering if you would be open to swapping it for esbuild?

nojaf avatar Mar 23 '22 11:03 nojaf

I'm not opposed in theory, but my experience with js build systems is rooted in much pain and so I wonder how much effort it would be to make the change.

cartermp avatar Mar 23 '22 14:03 cartermp

Yeah, it's just an effort question to me. The current setup has worked for a while and it's the part of the codebase I'm least-comfortable with, so I'm change-averse.

baronfel avatar Mar 23 '22 14:03 baronfel

I might give it a try this weekend, one can know if it'll work under a couple of hours so if I face anything weird I'll report back

AngelMunoz avatar Mar 25 '22 14:03 AngelMunoz

Nice! Would be great if we could get a fable and esbuild watch kind of thing going on.

nojaf avatar Mar 25 '22 15:03 nojaf

hot reload?! https://blog.hediet.de/post/hot_reload_for_vs_code_extension_development

baronfel avatar Mar 25 '22 15:03 baronfel

Interesting! But I think you still want esbuild > webpack, it really is a lot faster to compile to the target JS.

nojaf avatar Mar 25 '22 15:03 nojaf

oh certainly esbuild would be a net benefit - I was just hoping to 🎣 snag someone into doing hot reload while they were at it ;)

baronfel avatar Mar 25 '22 15:03 baronfel

I went out and checked (with vite as opposed to raw esbuild) and after some inspection and looking after the code I have a few questions:

  • What is the main reason webpack is/was being used?
  • Do we even want webpack/esbuild/vite at all?

I can only think webpack was there to transpile back early fable code where electron didn't support esm, and perhaps even some ES201X features, this is no longer the case the recent node/electron versions support all of the features that fable transpile as far as I'm aware, we could ditch it entirely to be honest.

The only reason I can think to have an extra build/bundling tool would be if extensions need to have bundled javascript files rather than transpiled and minified source code.

I think we should be able to just run fable in watch mode in the back and then just launch the extension with the direct output of fable there would be some work to be done in regards imported members without extensions but I think over all it could be worth exploring

thoughts?

AngelMunoz avatar Mar 25 '22 18:03 AngelMunoz

That's an interesting idea for sure. I don't think we do anything special - as long as we can emit source maps that should be all we need. The VSCode docs highly suggest bundling for a perf benefit, but realistically our extension isn't really that large at all. Perhaps shipping an unbundled version would be better for debugging?

baronfel avatar Mar 25 '22 18:03 baronfel

I would still bundle for production as the docs say, you don't know upfront what target (desktop/browser) you are dealing with so you want maximum coverage. It would be super cool if while developing you would only need Fable (in watch mode) and can have that extension reload working. That would really be the sweet spot I think.

nojaf avatar Mar 26 '22 08:03 nojaf

Hey Sorry I forgot to report back here I just committed my attempt on my fork I know it worked but I didn't test it too much (hence why no PR) in case anyone wants to check it out

https://github.com/ionide/ionide-vscode-fsharp/compare/main...AngelMunoz:main

AngelMunoz avatar Apr 16 '22 04:04 AngelMunoz