Skip to content

Use require whenever available to load viz.js #4

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

Merged
merged 1 commit into from
Jun 11, 2019

Conversation

colehaus
Copy link
Contributor

It used to be the case that I'd get an error like
2019-06-10-151420_516x144_scrot when trying to use this library in the browser. The offending code is here:
2019-06-10-151614_547x191_scrot.

The problem is that the existing code expects browsers to always have loaded viz.js as a globally available script and that require is never available in browsers. Using pulp's browserify command makes both assumptions incorrect (as you can see in the second screenshot, browserify makes a require function available).

Now the code tries require first and falls back to a global Viz only if require fails.

I tested the new code on the command line (via pulp test), in the browser (via pulp browserify) with require, and in the browser without require (manually edited the JS bundle to skip the require attempt).

@csicar csicar merged commit ad6b8ff into csicar:master Jun 11, 2019
@colehaus
Copy link
Contributor Author

Thanks!

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.

2 participants