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
window.tinycolor is not defined if JS loader is used #122
Comments
I thought it was using a pretty standard setup for module registration. Do you have an example where this doesn't happen? |
I was trying to use https://github.com/brianpkelley/md-color-picker which needs tinycolor with typescript. |
I guess I'm not sure of how to distinguish between 'a module loader is present' and 'this script is being loaded with a module loader'. I'm not sure I've seen UMD use both define or module.exports and also setting to 'window' |
Just remove the else and always add tinycolor to window. |
But what about in the node js environment? |
Check if window is defined? 😏 |
I imagine there's a case where someone is using a module loader because they don't want libraries to pollute the global namespace. I think what it's doing now is the 'standard' way to register modules with UMD. Are you able to load tinycolor via SystemJS and then set |
yes require(['tinycolor'], function(tinycolor){
window.tonycolor = tonycolor;
}); this is the right way |
Well - I solved in kinda that way for now, too.
Yes, but not quite. It's more to prevent collisions than just populating the window namespace. TL;DR: Can you find any negative effect of registering tinycolor in the window namespace? |
@olee Imagine you have legacy code which uses a global variable with the name tinycolor... Way with require more flexible. |
Agreed with @jt3k and #122 (comment) is a workable solution to the problem. Closing this out. |
When a loader like SystemJS or RequireJS is found, tinycolor skips registering the
window.tinycolor
variable. This breaks other modules that don't use a loader and depend onwindow.tinycolor
.The text was updated successfully, but these errors were encountered: