denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.15k stars 619 forks source link

Easy way to augment esbuild configuration #2399

Closed kitsonk closed 2 months ago

kitsonk commented 4 months ago

I am currently trying to integrate monaco-editor into an island from the esm source. The problem is that the source expects to have .ttf files loaded for it and currently esbuild integrated into fresh doesn't know what to do. The repo gives an example of how to configure esbuild to be able to be able to build from the esm source, but there seems to be no straightforward way of augmenting the esbuild configuration.

marvinhagemeister commented 4 months ago

Even if we'd expose the esbuild configuration it wouldn't work because we render islands on the server and we only use esbuild to generate the browser bundles. Deno will still error when it comes across an .ttf import statement. To make non-standard file imports work on the server we would need to transpile the server portion of Fresh too. So exposing esbuild alone in Fresh won't be enough.

I feel like longterm the most viable solution for us is to integrate with vite. I'm kinda waiting once they land their new environments API, because that will make it easy to generate server + browser bundles at the same time.

kitsonk commented 4 months ago

For my purposes, I forked fresh and made the modification. monaco-editor already had challenges being run server side and I had to already use an IS_BROWSER dynamic import when I was using esm.sh versus npm imports.

nickguimond commented 4 months ago

Another option might be to use AMD version of Monaco editor save reference to it on window and communicate with it from your island.

nickguimond commented 4 months ago

https://github.com/nickguimond/monaco_test here is a rudimentary example, the commits are organized by the steps I took.

marvinhagemeister commented 2 months ago

Duplicate of https://github.com/denoland/fresh/issues/858