Panel: Enable adding javascript modules via pn.config.js_files or some alternative

Created on 1 Mar 2020  路  6Comments  路  Source: holoviz/panel

My Pain

I'm trying to add a pn.pane.WebComponent to Panel here https://github.com/holoviz/panel/issues/1120

I can see that often the user or developer of a component needs to import the js dependencies as modules as below

<script type="module" src="https://unpkg.com/[email protected]/lib/wired-slider.js?module"></script>

Please note that module is in two places. It won't work without it. You will get errors in the browser console.

Solution

Extend pn.config.js_files or add pn.config.js_module_files functionality to support this use case.

enhancement

All 6 comments

I don't understand you request.
If you do

pn.extension(js_files = {"wired_slider": "https://unpkg.com/[email protected]/lib/wired-slider.js?module"}

It should already work
Ok I understand now the type "module" is important

Ok I understand know the type "module" is important

Without it you won't be able to import it from the component and it would be just a global pile of JS and not an isolated module.

@mattpap the modification should be at bokeh level in Ressource class?

the modification should be at bokeh level in Ressource class?

We will definitively add support for modules to bokeh, but that will likely happen on top of PR https://github.com/bokeh/bokeh/pull/9614 and it would be useful to positively resolve issue https://github.com/bokeh/bokeh/issues/9731 by then. Though in the meantime panel could add intermediate support on its own. However, it's still preferred to bundle modules together, because of issues with interoperability between dependencies using different module systems, degradation of performance with many modules (especially without HTTP/2 being used) and support for legacy browsers which don't allow modules at all.

Thanks.

My understanding of this stuff is limited though. I鈥檓 just trying to get it to Work.

the modification should be at bokeh level in Ressource class?

We will definitively add support for modules to bokeh, but that will likely happen on top of PR bokeh/bokeh#9614 and it would be useful to positively resolve issue bokeh/bokeh#9731 by then. Though in the meantime panel could add intermediate support on its own. However, it's still preferred to bundle modules together, because of issues with interoperability between dependencies using different module systems, degradation of performance with many modules (especially without HTTP/2 being used) and support for legacy browsers which don't allow modules at all.

Hi @mattpap . I have also read those things but never experienced them. But I guess its because my use cases are relatively simple.

But I think there are two extreme uses case to support and then all the cases in between.

  1. Adhoc or simple use in a notebook. A user has identified some module that can enable him to do something awesome. In this case he just needs to get the module in. He does not need to think about performance or other issues.
  2. An advanced web application with many modules and other dependencies. Here the issues you mention would apply.

The above is something I believe ... not know for sure.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kcpevey picture kcpevey  路  4Comments

MarcSkovMadsen picture MarcSkovMadsen  路  3Comments

philippjfr picture philippjfr  路  3Comments

pybokeh picture pybokeh  路  3Comments

henriqueribeiro picture henriqueribeiro  路  3Comments