$inject BpmnJS instance (Viewer) into component


I am currenty using the bpmn io framework for a research project at work, which I am currently in the process of creating an additional module for. This additional module needs access to a function that exists currently in the viewer module, ImportXML.

What I would like is as follows:


var bpmnModeler = new BpmnModeler({
    container: canvas,
    additionalModules: [


function MyModule(eventBus, modeling, commandStack, canvas, viewer) {
	this._eventBus = eventBus;
	this._modeling = modeling;
	this._commandStack = commandStack;
	this._canvas = canvas;
	this._viewer = viewer;

module.exports = MyModule;

MyModule.$inject = [
	'viewer', // This is ideally what I thought I would need to do...

MyModule.prototype._importXML = function(xml) {

Any help in where I am going wrong is much appreciated.


The BpmnJS instance (viewer, modeler or whatever) is available via the bpmnjs name to other modules.

So you could do something like this:

function MyService(bpmnjs) {
  this.export = function() {

Reimport diagrams from within a service via Viewer#importXML is something we do not support right now though.

Ah OK it was the name I was getting wrong.

My service module is loading a BPMN diagram from a database so I wanted to use the bpmnjs.importXML function.

Anyway it seems to be working fine now I am injecting bpmnjs.

Thanks very much