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

update shim files to use window instead of global #286

Merged
merged 1 commit into from
Oct 29, 2018
Merged

update shim files to use window instead of global #286

merged 1 commit into from
Oct 29, 2018

Conversation

jorgenfb
Copy link
Contributor

The files in /shim is only used in browsers (remapped in the browser
field of package.json) when using build tools. Browsers do not have the
global propery which is a node thing. Browsers instead have the global
namespace window.

This commit solve my problem of importing roslib in my application and
building with webpack 4 without having webpack shim global = window.

Note: updated Gruntfile.js to have jshint read the config file from the
closes directory/parent directory and added a new .jshintrc to /shim to
lint the files there with a browser environment in mind.

Copy link
Contributor

@Rayman Rayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, your changes look good, but can you remove the changes to the build/ directory?

The files in /shim is only used in browsers (remapped in the browser
field of package.json) when using build tools. Browsers do not have the
global propery which is a node thing. Browsers instead have the global
namespace window.

This commit solve my problem of importing roslib in my application and
building with webpack 4 without having webpack shim global = window.

Note: updated Gruntfile.js to have jshint read the config file from the
closes directory/parent directory and added a new .jshintrc to /shim to
lint the files there with a browser environment in mind.
@jorgenfb
Copy link
Contributor Author

Sure! Build artifacts removed.

@jihoonl jihoonl merged commit 35e7474 into RobotWebTools:develop Oct 29, 2018
@yokyj
Copy link

yokyj commented Mar 13, 2019

hi guys
to improve performance,I want roslib to suscribe topics in web worker
but there is not objetc window in worker field so it crashed

@jorgenfb
Copy link
Contributor Author

Hi! I do not think this library can be used in a worker out of the box. Mainly because it references several global objects not available in a worker. For instance DOMParser, DOMImplementation, XMLParser, Canvas and Image. I suggest that you open a new issue regarding support for usage in web workers.

@mvollrath
Copy link
Contributor

@yokyj there is now a feature to run the WebSocket in a Worker, though decoding still happens in the main thread. See #317

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.

5 participants