bpmn-io / bpmn-auto-layout

Layout BPMN diagrams, generating missing DI information.
https://bpmn-io.github.io/bpmn-auto-layout/
52 stars 41 forks source link

TypeError: BpmnModdle is not a constructor #18

Closed jackzhujie closed 3 years ago

jackzhujie commented 4 years ago

Describe the Bug

In our environment, after I used the bpmnModeler.connect() method to connect a line, I needed to automatically layout it, and I got an error: BpmnModdle is not a constructor

Steps to Reproduce

Example Code snippet

const {xml} = await this.bpmnModeler.saveXML({format: true});
const autoLayout = new AutoLayout();
let layOutXml = await autoLayout(xml);`

Example CodeSandbox

Expected Behavior

Should not crash.

pinussilvestrus commented 4 years ago

For further assistance, please share a CodeSandbox that reproduces your issue in a way that we can inspect it.

jackzhujie commented 4 years ago

code

pinussilvestrus commented 4 years ago

Thanks for sharing! Looks like an incompatibility with the latest bpmn-moddle version. We're open for a contribution which solves this issue 👍

pinussilvestrus commented 4 years ago

Hint: the AutoLayout module should be updated to use the correct import statement for the BpmnModdle module.

var BpmnModdle = require('bpmn-moddle').default;
jackzhujie commented 4 years ago

Hint: the AutoLayout module should be updated to use the correct import statement for the BpmnModdle module.

var BpmnModdle = require('bpmn-moddle').default;

ok,thanks

giero commented 4 years ago

Or switch to ES Modules syntax:

import BpmnModdle from 'bpmn-moddle';
import Tree from './Tree';
import DiFactory from './DiFactory';

import DiUtil from './DiUtil';

and then

export default AutoLayout;

This worked for me :) (got the sma bug btw)

nikku commented 4 years ago

We are open to contributions that fix this.

matiasah commented 3 years ago

Hint: the AutoLayout module should be updated to use the correct import statement for the BpmnModdle module.

var BpmnModdle = require('bpmn-moddle').default;

Would this definetly fix this issue? I'm also having this problem but I haven't tried this solution, I would open a PR with this if you confirm it works.

nikku commented 3 years ago

Would this definetly fix this issue?

You open the PR and find out :smile:

matiasah commented 3 years ago

Or switch to ES Modules syntax:

import BpmnModdle from 'bpmn-moddle';
import Tree from './Tree';
import DiFactory from './DiFactory';

import DiUtil from './DiUtil';

and then

export default AutoLayout;

This worked for me :) (got the sma bug btw)

I guess I'm going to try this instead

nikku commented 3 years ago

Closing this issue as we do not plan to follow up on this one, unless we receive an external contribution (pr-needed).