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
Accessing code outside browserified code #210
Comments
So you can add browserify arguments (the README has some examples) however the configuration doesn't have the option to add arguments for one module. If you adding So to answer your question, this gem doesn't allow you to do this. You could do a PR to add such configuration but I would also suggest it's probably a bad idea. It increases complexity for this gem and globals are really one of the biggest issues with JavaScript. You are of course free to do whatever you wish but most of the intent behind this gem is to allow going from old school JavaScript (globals, etc) to modular JavaScript (no need for globals). So such a thing hasn't really been desired I would say and that is why this gem doesn't address such a need. |
That said, pragmatically, if I was in your shoes, I would make a module that was used to both consume and export globals. There isn't a need for the browserify option if you go this route. Global defined outside of browserified code So say I had
Then I could consume it:
Global defined inside of browserified code
Above, I set both The reason I would do this is to make it very clear what is a global and what is not. And I also avoid polluting my modular code with globals. |
Hmm it seems if I just do |
I might have misunderstood what you meant by |
Currently if I want to access code outside of the bundle JS I have to prefix the function or variable so it's attached to the window. e.g.
window.myFunction = function() { }
According to this answer on Stack Overflow:
https://stackoverflow.com/questions/23296094/browserify-how-to-call-function-bundled-in-a-file-generated-through-browserify/28805578#28805578
In addition to using the window attachment you can use a standalone mode... how do you use this with this gem? And once used how would I access these functions using the module?
The text was updated successfully, but these errors were encountered: