3

The bpmn-js (and diagram-js) allows to include optional modules, that augment the current functionality.

Example: Modeler.js (from line 174, commit [ae96f37]1)

Modeler.prototype._interactionModules = [
  // non-modeling components
  require('diagram-js/lib/navigation/movecanvas'),
  require('diagram-js/lib/navigation/touch'),
  require('diagram-js/lib/navigation/zoomscroll')
];

Now in order to get an overview about the certain modules, I currently have to look at the folders of the both modules (bpmn-js, diagram-js in node_modules) to see the whole list of possible modules:

Example 1: bpmn-js/lib/features/* (commit: b03014f)

Example 2: diagram-js/lib/* (commit: 7956c81)

However, if I want to have a more modular Modeler design (e.g. add / remove functionality, depending on user roles) I would require to have some functionality, that exposes the available modules to my application. Something like

Modeler.modules() // list all module names

Modeler.addModule(name) // adds this module

Modeler.removeModule(name) // removes this module

I have searched to code of the bpmn-js repo so far but found no properties / methods / API that expose these modules.

I just found a way to search the directory of the node module in order to get the desired folders (/lib/*) but that seems very odd to me, since this structure might change with the next version due to refactoring, redesign etc.

Am I really stuck to write my own implementation or did somebody successfully solve this already? (Any "hidden" properties that implicitly expose the available modules?)

Jankapunkt
  • 8,128
  • 4
  • 30
  • 59
  • Your question is about getting the list of possible modules or adding them at run-time? – Tarun Lalwani Mar 20 '18 at 09:07
  • Actually both. If the folder structure changes (which happened latetly in bpmn-js) it crashes all my depending code and refactoring also makes no sense if not having any property exposure but using import paths :-/ Edit: I just think that digging in the node_modules folder at runtime feels like a no-no. – Jankapunkt Mar 20 '18 at 09:11

0 Answers0