You are looking at the problem wrong. Instead of putting these hacks into your code you should use some sort of bundler (component/browserify/script/etc..) to prepare your code for the client. That way you leave it up to the user to determine how they want to package the stuff versus making assumptions about it.