sverweij / mscgen_js

text => sequence charts
https://mscgen.js.org
GNU General Public License v3.0
206 stars 25 forks source link

How to use mscgen_js package properly in angularjs? #241

Closed hari-kris closed 7 years ago

hari-kris commented 7 years ago

I tried to use the package inside the angularjs application by import, rendering is not happening but when I use

<script src='https://sverweij.github.io/mscgen_js/mscgen-inpage.js' defer>
    </script> 

in the html file, SVG file is generated. Any idea how to overcome this problem. Any help would be very useful. Thank you!

sverweij commented 7 years ago

You probably want to use mscgenjs core - I split that off from mscgen_js to support use cases like yours. Documentation on mscgenjs-core should be sufficient to get you started. Let me know if you bump into anything.

The reporter of issue #240 successfully used mscgenjs-core to integrate mscgenjs in his angular app.

hari-kris commented 7 years ago

Thanks @sverweij it solved the problem. Where can I get minified version of the mscgen_js. You made my day. Thank you!.

sverweij commented 7 years ago

Glad it worked out for you.

The typical use case I envisioned for this is that 'mscgenjs-core' is packaged with the app it happens to be included in. I've tried that with requirejs and webpack - two samples here.

This is why there is no separate bundled + minified version of mscgenjs-core yet.

How would you use a bundled (I assume) + minified version of mscgenjs-core in your app?

hari-kris commented 7 years ago

I am planning to use it inside Kibana Plugin. It throws me warning while compiling, that the size is bigger than 100KB

log   [19:57:23.238] [info][optimize] Lazy optimization started
[BABEL] Note: The code generator has deoptimised the styling of "/home/kibana-4.5/installedPlugins/sip/public/js/mscgenjs/parse/xuparser.js" as it exceeds the max of "100KB".
[BABEL] Note: The code generator has deoptimised the styling of "/home/kibana-4.5/installedPlugins/sip/public/js/mscgenjs/parse/msgennyparser.js" as it exceeds the max of "100KB".
optmzr    log   [19:57:29.485] [info][optimize] Lazy optimization started
[BABEL] Note: The code generator has deoptimised the styling of "/home/kibana-4.5/installedPlugins/sip/public/js/mscgenjs/parse/xuparser.js" as it exceeds the max of "100KB".
[BABEL] Note: The code generator has deoptimised the styling of "/home/kibana-4.5/installedPlugins/sip/public/js/mscgenjs/parse/msgennyparser.js" as it exceeds the max of "100KB"
sverweij commented 7 years ago

🤔 It seems your Kibana Plugin compilation train uses babel under the hood. Some googling learns that that warning is not a problem. Babel tries to keep its output readable. When the source is too big, however, it doesn't bother. As xuparser.js and msgennyparser.js parsers are generated code anyway, I wouldn't worry about readability in whatever babel transforms it into.

http://stackoverflow.com/questions/35192796/babel-note-the-code-generator-has-deoptimised-the-styling-of-app-js-as-it-exc?noredirect=1&lq=1

On another note: mscgenjs doesn't need to be transpiled into browser readable javascript - it only uses features the target browsers support natively in the first place.

hari-kris commented 7 years ago

Okay Thank you @sverweij