Global widget dependencies - Mendix Forum

Global widget dependencies

4

Often, multiple pluggable widgets may have common dependencies whether it be a 3rd party library installed to node_modules or a local library (perhaps managed with lerna etc etc).

Currently each widget package independently bundles these dependencies and loads it all when the widget is loaded. This has a couple of downsides:

- Widget packages are large and take time to load

- Some dependencies may require a single instance in order to function correctly. Two widgets on the same page initialising 2 instances of such a library can cause problems.

 

It would be great if we could have a way to easily manage such dependencies. 

Currently, one way I can think of may be to create a custom webpack file for the custom widget and create a ‘vendors’ bundle which will output marked libraries as a separate JS file. 

The trouble is to then ensure this file is loaded once. Could it be possible to do this by editing the index.html file? I don’t know. 

What I would like is a way to tell mendix to load some global/common dependencies and to tell the pluggable widget system to (optionally) exclude said dependencies from the bundle. 

 

 

asked
1 answers

Great point. Sounds like you’re describing a need for dependency injection. I don’t have a solution at the moment, but I’m curious to see if anyone else weighs in. 

Created