-
Notifications
You must be signed in to change notification settings - Fork 492
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
Loading node-semver via browserify throws errors in closure compiler verbose mode #45
Comments
Why is clojure compiler complaining about these things? Using the This is a bug in clojure. |
Also, if you're using browserify, then it's wrong -- exports and module WILL be defined when this script is run. |
Thanks for your quick reply @isaacs. I'm sorry I took a shortcut and the output above was inaccurate:
You're right - those two will be defined - but The error thrown during closure compiling the browserified script was actually just The previous output was got using Google Closure Compiler on the whole browser bundle (which in retrospect was not a fair test). Apologies for the confusion. |
Well... look at the code. It's only going to assign to the semver global if module and exports are undefined. And if they are undefined, then it's not "leaking" a global, it's intentionally setting a very specific global. So, this is still a case of clojure being either overly zealous or misconfigured. |
Sorry, I misspoke, it'll set |
Ok I think this is just a case of different opinions of coding style. Thanks for your time in going through this with me and explaining it in detail. I have a workaround - and I will discuss with my colleagues about whether we should reduce the enthusiasm of our current Google Closure Compiler settings. Thank you again. |
Oh, I just realized, if it's getting tripped up by the code style of putting |
I will investigate this and get back to you. Thanks for your advice. |
@matthew-andrews Did you ever find a work-around please? |
Firstly I recognise this is a slightly obscure use case and probably doesn't affect many (any?) other people at all. Also I have a 'good enough' workaround (instead of
require('semver')
simply userequire('semver/semver')
).What we're doing:
warning_level VERBOSE
.The errors we see:
I'm not sure what the best fix for this would be but since it's possible to workaround it by just pointing browserify at the raw semver file (rather the
semver.browser.js
, which has thehead.js
andfoot.js
files sandwiching it) I was wondering why thebrowser
property (which - and I may be wrong here - is only used by browserify?) wasn't just pointing to the semver.js file.Alternatively the code to compile the library 'for browsers' could be switched for browserify with the standalone option, which I know to be 'closure compiler safe' - but that will increase the size of the library unnecessarily...
What do you think?
Thanks!
Matt
The text was updated successfully, but these errors were encountered: