Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in webpack prevents use of amdefine and hence mscgenjs #45

Closed
parikshitgawali opened this issue Jan 3, 2018 · 6 comments · Fixed by #46
Closed

Issue in webpack prevents use of amdefine and hence mscgenjs #45

parikshitgawali opened this issue Jan 3, 2018 · 6 comments · Fixed by #46

Comments

@parikshitgawali
Copy link

mscgenjs is not compatible with webpack v3.6.0 .Getting error Uncaught Error: define cannot be used indirect . This is due to bug with webpack that 'define' is not support. Is it possible to make it compatible current version of webpack ?
{
"name": "mscgenjs",
"version": "1.9.0",
"description": "Implementation of MscGen in JavaScript",
"main": "index.js",
"dependencies": {
"amdefine": "1.0.1",
"requirejs": "2.3.2"
},

Working fine older"version": "1.12.15".

@sverweij sverweij changed the title Not Compatible with latest version of webpack Bug in webpack prevents use of amd amdefine and hence mscgenjs Jan 3, 2018
@sverweij sverweij changed the title Bug in webpack prevents use of amd amdefine and hence mscgenjs Bug in webpack prevents use of amdefine and hence mscgenjs Jan 3, 2018
@sverweij
Copy link
Member

sverweij commented Jan 3, 2018

This is caused by webpack/webpack#5316 - which most likely affects all libraries that - just like mscgenjs - use amdefine to expose AMD modules for use in commonJS. Hence the ideal and correct solution for this would be for webpack to fix issue 5316. I see the issue is open since July 2017, though, so there's probably issues that have higher priority in the webpack project.

Alternatives:

  • Consumers using mscgenjs i.c.w. webpack keep using webpack 1.x.x or migrate to another bundler
    At least until webpack issue 5316 is solved. Not ideal, but in the short term (= the coming days) the only realistic 'solution' I can offer.
  • Change mscgenjs' module system to either commonjs or es6 modules.
    This is not a small change. I'd have to change some apps that depend on mscgenjs-core to keep them working, and I'd have to change my development workflow (I've done this migration with sverweij/state-machine-cat a few weeks ago - and learned enough to know the issues mscgenjs would bump into). I might walk this path at some point in the future, but not now.
  • Hack around the webpack's module loader problems with almond.
    This looks promising, but I don't have experience with the solution outlined there (yet).

@sverweij sverweij changed the title Bug in webpack prevents use of amdefine and hence mscgenjs Issue in webpack prevents use of amdefine and hence mscgenjs Jan 3, 2018
@sverweij
Copy link
Member

sverweij commented Jan 3, 2018

@pgawali-broadsoft the workaround with almond seems to work ☝️. To use it you'll need to require the almond generated file in dist/mscgen instead of mscgen.js' root module - see the samples/README.md and the sample root module for the setup I used to test this.

I'll need to test/ document and polish this before releasing (maybe this weekend, maybe later), but if you want to try it already checkout above branch and use the thing in dist or copy the workaround-with-almond thing in the dist folder of that feature branch directly from GitHub (dist/mscgen.js)

@parikshitgawali
Copy link
Author

parikshitgawali commented Jan 4, 2018

Thanks a lot . Issue mostly resolved but tool-tip functionality seems to be not working for me .I can see 'title'tag with populate text in DOM even though tool-tip is not visible on hover. Is it expected in this workaround?

@sverweij
Copy link
Member

sverweij commented Jan 4, 2018

Tool-tip functionality should work as before. I've tested it in firefox 57, chrome 63 and safari 11 and there it works as expected.

(Note that browsers implement the tooltip on text hover only, so if the label is super small or absent (e.g. msc {a,b; a => b[title="Title won't show up on hover"];}) getting the tool-tip to show will probably not be fruitful; but if there is a label it willmsc {a,b; a => b[label="message in a bottle", title="Title will show up on hover"];}.)

@sverweij
Copy link
Member

sverweij commented Jan 5, 2018

I'll merge & publish this weekend - just a heads up: I've renamed the thing from dist/mscgen.js to dist/webpack-issue-5316-workaround.js because it's more clear & self documenting. So you'll use it like this:

// commonjs, only for use with webpack > 2,
var msgenjs = require('mscgenjs/dist/webpack-issue-5316-workaround');

sverweij added a commit that referenced this issue Jan 5, 2018
@parikshitgawali
Copy link
Author

ok. Thanks for workaround. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants