Vue3 error with BpmnModeler

Hello everyone! I’m having a problem with a project made in Vue 3, and bpmn-js 16.4.0. When compiling it for production, I get this error:
Captura de pantalla 2024-03-12 a la(s) 12.10.55

The portion of code where it crashes is here:

 eventsListener() {
      const eventBus = this.bpmnModeler.get("eventBus");
      console.log(eventBus)
      eventBus.on(["commandStack.changed"], async (event) => {
        let lastChange;
      
//here is the error
        this.bpmnModeler.invoke(function (commandStack) {
          //console.log(commandStack._stack);
          lastChange = commandStack._stack[commandStack._stack.length - 1]
        });

//more code
});

I believe that it must be due to a minification issue that occurs in the compilation. How can I solve it?

If you create your own bpmn-js extension, ensure that you declare dependencies using the minification -safe array notation:

// invoking a function to inject a service (minification safe)
bpmnModeler.invoke([ 'eventBus', function(eventBus) {
  
  // here we have access to eventBus even though
  // it minifies to <t> or whatever letter
} ]);

// create a service (minification safe)
function MySafeService(eventBus) {
  // eventBus is available
}

MySafeService.$inject = [ 'eventBus' ];

Read more about that here.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.