Closed vaadin-bot closed 2 years ago
Originally by @Artur-
A lot of tickets have been left hanging in the issue tracker through the years. Some of them are still relevant, some of them have been fixed a long time ago and some are no longer valid. To get a better look on what is important and still relevant, we are closing old tickets which have not been touched in a long time.
No further work will be done on this ticket unless someone indicates that it's still relevant.
If this ticket is still relevant to you, please reopen it.
Originally by mpilone
There is a good discussion of this issue in the forum: https://vaadin.com/forum#!/thread/3390058
As far as I know it is still a problem. I just ran into it with two different components including moment.js.
I'm beginning to think this isn't Vaadin specific, but Vaadin isn't doing much to help the situation. The basic issue is that multiple add-ons may include the same JS files. While Vaadin does try to prevent this by looking at the file path, it isn't perfect because the relative path may be different or the file name may be slightly different (like including a version number in one file and not the other).
One thing that would help would be to support some kind of callback mechanism so the component JS file is loaded but the component function isn't called until a callback is triggered. The key is to support the asynchronous nature of JS and JS script loading. This would allow the component to use module loading mechanisms like require.js (http://requirejs.org) or any AMD mechanism.
The simplistic JavaScript tag works well for the components base script because that will be different per component. But as soon as a JS component needs external libraries, things break down. For Vaadin to fully support JS only components I think it needs to support module loading in some way which might just be plugging into an existing JS tool or at least an asynchronous initialization workflow.
Originally by dnordhoff
As written in the thread on the forum I created a prototype using webars in the @JavaScript
annotation. It is based on discussions at the Hamburg vaadin-meetup, the forum and Matti Tahvones virtitin-webjars branch. Matti also suggested to create a feature request for this in the Vaadin core and adding a webjars://
protocol to @JavaScript
.
If this is a feature which is wanted from the vaadin team, I will create a pull request, else I would pack it in an addon. I would prefere this to become a part of core vaadin, because I belive it would be more accepted by addon developers and users, since having an extra dependency to your addon and an extra servlet for your application might be a reason for not using it.
The current code has a dependency to webjars-locator-core which ships with a custom license, is that a problem?
Best wishes
Daniel
Any news on that topic?
Hello there!
It looks like this issue hasn't progressed lately. There are so many issues that we just can't deal them all within a reasonable timeframe.
There are a couple of things you could help to get things rolling on this issue (this is an automated message, so expect that some of these are already in use):
Thanks again for your contributions! Even though we haven't been able to get this issue fixed, we hope you to report your findings and enhancement ideas in the future too!
Is there a better way now to load javascript files, than using the JavaScript annotation?
Hello there!
It looks like this issue hasn't progressed lately. There are so many issues that we just can't deal them all within a reasonable timeframe.
There are a couple of things you could help to get things rolling on this issue (this is an automated message, so expect that some of these are already in use):
Thanks again for your contributions! Even though we haven't been able to get this issue fixed, we hope you to report your findings and enhancement ideas in the future too!
The issue was automatically closed due to inactivity. If you found some new details to it or started working on it, comment on the issue so that maintainers can re-open it.
Just pointing out, that with Vaadin Flow framework, the handling of JavaScript libraries is done via tools like npm and webpack (exact tools may change in the future), which pretty much solves the problem mentioned here.
Originally by @Legioth
ResourceLoader
could be quite useful for JavaScript Connectors that might want to dynamically load external scripts. The class is however only accessible using GWT right now.Create a JavaScript API for using
ResourceLoader
.Imported from https://dev.vaadin.com/ issue #12201