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

Problem with header for verb for JavaScript #26

Closed
elifer5000 opened this issue Jun 2, 2016 · 1 comment
Closed

Problem with header for verb for JavaScript #26

elifer5000 opened this issue Jun 2, 2016 · 1 comment

Comments

@elifer5000
Copy link

elifer5000 commented Jun 2, 2016

I think this check in the verb.js header, is not correct

// node.js context, but not WebWorker
if ( typeof window !== 'object' && typeof require === "function"){
    Worker = require('webworker-threads').Worker;
}

Try opening one of your examples, like http://verbnurbs.com/examples/curveClosestPoint.html
and set a breakpoint there. You can see that window is not defined, even though we are in the browser. Furthermore, it is defined one step above in the call stack.

This makes it think that it's in a node context. In this case nothing happens, because require is not defined. But if you use verb inside a library that it's browserified, require will be defined, and it will require webworker-threads, which creates further problems (browserify won't work if it's not installed, and if you do install it, it will fail at runtime since it's not meant to run in the browser)

In conclusion, either the check is not correct, or window should somehow be defined there when running from a browser.

@pboyer
Copy link
Owner

pboyer commented Jan 17, 2017

@elifer5000 Thanks a lot for letting me know. This should be fixed in 2.0.2 - out now. Just give it a npm install.

@pboyer pboyer closed this as completed Jan 17, 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

No branches or pull requests

2 participants