dagrejs / graphlib-dot

A DOT language parser and writer for graphlib
MIT License
224 stars 42 forks source link

Difficulties including library in client-side code #24

Open p3k opened 9 years ago

p3k commented 9 years ago

When I include the library together with RequireJS like the following in an HTML page I get the error and stack trace below:

<script src='https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.20/require.js'></script>
<script>
  require(['http://cpettitt.github.io/project/graphlib-dot/latest/graphlib-dot.js'], function(dot) {
    console.log(dot);
  });
</script>
Uncaught TypeError: Cannot read property 'Graph' of undefined
  3../graphlib @ graphlib-dot.js:55
  s @ graphlib-dot.js:1
  (anonymous function) @ graphlib-dot.js:1
  8../build-graph @ graphlib-dot.js:2619
  s @ graphlib-dot.js:1
  (anonymous function) @ graphlib-dot.js:1
  2../lib/graphlib @ graphlib-dot.js:28
  s @ graphlib-dot.js:1
  (anonymous function) @ graphlib-dot.js:1
  (anonymous function) @ graphlib-dot.js:24
  1../index @ graphlib-dot.js:26
  s @ graphlib-dot.js:1e @ graphlib-dot.js:1
  (anonymous function) @ graphlib-dot.js:1

What do I need to do to make graphlib-dot work with RequireJS (which is a requirement)?

cpettitt commented 9 years ago

I don't have any experience with RequireJS, but there seem to be some issues with it and browserify, which is what I used to build the graphlib-dot bundle. See discussion / suggestions here: https://github.com/substack/node-browserify/issues/790.

p3k commented 9 years ago

Thanks for the pointer. I can confirm that it works when I add graphlib-dot with a <script> element before the one for RequireJS. Would be still neat to use graphlib-dot as RequireJS module, though.