2

I have a js with this declaration:

import Modeler from '.../Modeler';

and after this I define a var of type Modeler in the js:

var myModeler = new Modeler(...)

When I try to use this variable (myModeler) in an html (in script-tag), I find an exception "myModeler not found". If I move the declaration above (var myModeler...) outside the js, so in my html, I find an exception about the type "Modeler doesn't exist.

I try to declare the js where is the import, in this manner (with and without the type="model"):

<script type="model" src="./MyCamunda.js"></script>

but again another error.

Where I must put myModeler or change any declaration?

EDIT: This is the html I use

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Camunda Modeler</title>

    <!-- required modeler styles -->
    <link rel="stylesheet" href="../node_modules/bpmn-js/dist/assets/diagram-js.css">
    <link rel="stylesheet" href="../node_modules/bpmn-js/dist/assets/bpmn-font/css/bpmn.css">
    <link rel="stylesheet" href="./MyCamunda.css">

    <script src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
    <script src="./MyCamunda.js"></script>
    <script>
        var diagramUrl = './diagramOriginal.bpmn';
        //load external diagram file via AJAX and open it
        $.get(diagramUrl, openDiagram, 'text');
        // wire save button
        $('#save-button').click(exportDiagram);
    </script>
  </head>
  <body>
    <div id="canvas"></div>
    <button id="save-button">print to console</button>
  </body>
 </html>

And this is a snippet of js I use (MyCamunda.js):

import Modeler from '../node_modules/bpmn-js/lib/Modeler';
var bpmnModeler = new Modeler({ container: '#canvas' });
...
Giant2
  • 461
  • 1
  • 4
  • 15
  • can you add a minimal example of the whole html page with the positionings of the scripts. How do you actually include the bpmn.io source? – Jankapunkt Feb 14 '19 at 08:32
  • I added the html and js I use. The include of bpmn.io I believe is done with the js snippet I added, isn't it? – Giant2 Feb 15 '19 at 08:42
  • What if you import like so: `import Modeler from 'bpmn-js/lib/Modeler';` does this work or are any errors coming up then? Do you use any framework, bundler etc? You can also provide a link to your code on GitHub so we can try to reproduce the error. – Jankapunkt Feb 17 '19 at 19:52
  • import Modeler from ... goes ok (no error). The error is when I try to use it from the page or other js file. It seems doesn't initialize an object of type Modeler or with this name. – Giant2 Feb 19 '19 at 15:30

0 Answers0