Javascript modules and Polymer 3.0

Hi,
is there any way for me to link a javascript module? I cannot seem to find a way to add a <script type="module" src="myModule.js"> that is loaded with a component.
I was able to insert a tag through the initial Page settings, but that is sub-optimal because it either means the module is loaded for every page that uses the same layout, or I’d have to duplicate the layout for my one component which defeats the purpose.

My goal is to use an ES6 module in one of my js connectors. But if the connector is not imported with type module, the
import ModuleName from ‘./modulepath.js’ fails.

Is there any other way for me to do that?
The import(‘modulepath.js’) directive is not supported by anything else than chrome yet.

This is of course also needed for Polymer 3.0 support which is now entirely based on js modules. Any ETA you can give for this integration? I could not find any info on this yet, although the Vaadin elements are already completely converted to P3.

Hi Jonas, P3 is not in the V10 scope at the moment, but it has been planed for later version.

How about the javascript modules? This would help out alot and would also enable manual integration of the new polymer components that can be expected to drop.

The hard part of Polymer 3 support would still not be solved with only something similar to @HtmlImport for JS modules.

The reason for this is that Polymer 3 modules use “bare imports” which are not supported by any browser, but instead polymer serve is dynamically rewriting the imports to use the path based imports that some browsers already support. Polymer 3 support with Flow would thus either require that requests for js files are routed through polymer serve, or alternatively that Flow would internally implement is own similar translation.

If you want to use your own JS modules that don’t use bare imports today, then it might work if you manually create a new Element("script"), set the module attribute on it and append it as a child of your UI’s element. You can also use ComponentUtil.setData with the UI instance to track which modules have already been imported so that you can avoid duplicate imports.

Ok thanks, I will have a look at that.