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

Allow usage in NodeJS with the embedded dagre module #31

Closed
wants to merge 3 commits into from

Conversation

prantlf
Copy link
Contributor

@prantlf prantlf commented Jul 30, 2015

The dagre module detects the module exports in the NodeJS environment and
does not declare the dagre object globally. The code in nomnoml.layouter.js
fails accessing the global dagre variable. Let's declare self = {} to make
dagre put its object to it, when running outside of the browser.

A better solution would be to require the dagre module like lodash and
limiting the supported versions to 0.4.x, which have the needed interface.
Let me know if you preferred that solution.

A part of the suggested fix for the issue #29.

The dagre module detects the module exports in the NodeJS environment and
does not declare the dagre object globally.  The code in nomnoml.layouter.js
fails accessing the global dagre variable.  Let's declate self = {} to make
dagre put its object to it, when running outside of the browser.

A better solution would be to require the dagre module like lodash and
limiting the supported versions to 0.4.x, which have the needed interface.
Perform the workaround to expose the dagre module result in the browser too.
If RequireJS is used, dagre detects it and does not expose the dagre object
globally in the window object.

Another reason to integrate dagre as a module like lodash...
@stefanpenner
Copy link
Contributor

require('nomnoml').renderSvg(code);

Now seems to work correctly, I believe this can be closed

@skanaar skanaar closed this Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants