paularmstrong/swig — comment on commit 16a0326f1e93c0425094859f1efcf58e025f7eed
File: scripts/browser.sh line 55
By cdata:

Hey there, I've been experimenting with using Swig in my project Bound, a static blog generator, and also on an internal project at my company. I noticed that the file you generate for the browser leaks a bunch of stuff into the global scope. When you sed the requires out with this line, you are actually removing the 'var' from the variable declaration are of some files (at least, this is true for index.js), which results in JavaScript attaching the values as properties on the window.

Are you presently working on a revised script to generate the browser-side library? If not, would you be willing to consider a pull-request with a revised solution to the problem?

Also, would you be willing to consider exposing a hook or other mechanism to allow for adding new filters when using Swig in the browser without pre-compiling them into the library?

Incidentally, the fact that you are leaking certain values into the global scope allows us to add filters while running in the browser. A formalized version of this behavior would be nice to have ;)