thanpolas/grunt-closure-tools

Building Overlapping Sources to two destination files

Closed this issue · 3 comments

Hi there,

I wasn't sure where to post this question, so I hope I am in the right spot.

I used the closureplease/generator-closuer generator (which uses your closure builder tool) to create a project for my team to work on. For the project, my team is building a game engine that uses web workers to offload data. For the engine, we need to have some code that runs in both the web worker and the main window, while some is exclusive to each, and we need to synchronize the data running in both by serializing it to JSON.

I have a dev environment set up now where it runs the uncompiled code fine, but my question is what is the best way to set up the compilations?

Right now, I have two compilations, one for the main window and one for the web worker, but the issue with is that when i synchronize the data, each compilation has different names for the variables.

Is there someway, with the closure builder, to run a compilation that will take two entry points and produce two separate files? Here is my code, if you need to look at it: https://github.com/jadmz/CrunchJS.

Thanks

Joe

Well, this is an issue that has to do with Closure Compiler mostly. If i understand your situation correctly you need one AO compiled part to be able to interface with another AO compiled part.

Start from here: https://developers.google.com/closure/compiler/docs/api-tutorial3#propnames

Essentially you need to export the symbols of part1 and import them on part2... or you may want to check out the --module flag, here are 2 stackoverflow links to get you started, link 1, link 2

Either case, you are up for a great challenge

Thanks for the fast reply!

So, if I was going to use the --module flag, would I be able to use that through the grunt config file, or have to do something outside of the grunt file?

in the grunt file, check #39, another folk had the same question