Correct import for non-webpack local JavaScript

Hi,

I must have missed something (14 npm without spring):

https://vaadin.com/docs/v14/flow/importing-dependencies/tutorial-ways-of-importing.html#static-resources

So for CSS there is:

  • Bundled with webpack (@CssImport with ./)
  • From npm: (@CssImport relative package/bla.css)
  • Not bundled with webpack (@Stylesheet and context://bla)

But that doesn’t match Javascript:

  • Bundled with webpack (@JsModule OR @JavaScript with ./)
  • From npm: (@JsImport relative package/bla.css)
  • Not bundled with webpack. HOW?

I want to load a js file only if a specific UI is loaded. The file is very big, so I don’t want it to be bundled.

Thank you

I think you are talking about https://github.com/vaadin/flow/issues/6565

The workarounds seem to be:

Artur,

thank you for your fast response!

Since that is open too
https://github.com/vaadin/flow/issues/1897

I don’t think there is a reliable way to do this, because I can’t stop waiting for a pending JS result while constructing the UI. Also I can’t do the JS call on session start because sometimes I need that UI (with the big JS) on session start, too.

Anyway thanks for the help!