deephaven / web-client-ui

Deephaven Web Client UI
Apache License 2.0
29 stars 31 forks source link

Support for chunked ESM plugins #2199

Open mattrunyon opened 3 months ago

mattrunyon commented 3 months ago

It would be great if we could support ESM plugins with multiple files. Right now our restrictions are CJS and a single file. This results in some potentially large plugin files without the ability to lazy load.

For example, we could lazy load the majority of the plotly-express plugin. Right now it will all be fetched at initial page load, but we could load just the object that says what types it supports and lazy import the component when it's needed.

I don't think the remote-component-loader library we use can handle ESM. We could probably support this natively with import maps (MDN page). The difficulty with import maps would be ensuring everything still works with Vite (I think dev mode would be the trickiest) like the React contexts

I've done some basic testing and our DHC config at least sends back any extra files I put in the plugins directory, so an await import('/js-plugins/my-plugin.js') which imports other files around it should work just fine as far as the server is concerned.