0

Let's say I have a JS application which involves fileA. In addition to fileA, there is fileB which depends on fileA both in folder "js". For example:

fileA:

goog.provide('mainProject');
mainProject.something = function(){return "returned";}
mainproject.something();

My understanding (possibly incorrect) is that I can do:

fileB:

goog.require('mainProject')
mainProject.anotherFunction = function(){return "returned again";}
mainProject.anotherFunction();

and that closurebuilder would detect the dependency.

I've run closurebuilder every way I know how and it's not concatenating what's represented here as "fileB". It does, however, include fileA.

My command is this:

python path-to\closurebuilder.py --root=path-to\closure-library --root=path-to\js --namespace="mainProject" --output_mode=script > path-to-js\concatenated.js

I know I'm probably missing a concept here... Any suggestions would be most appreciated.

Thank you.

  • Are you getting errors? If so; what error are you getting. Advanced compilation will remove any code that isn't called so you could add hundreds of js files; if they contain code that's never called it's not going to show up in your compiled js file. – HMR Jun 05 '13 at 11:28
  • Hi, HMR. I'm just looking for the concatenated, uncompiled script so I can send that to the compiler. I noticed that closurebuilder.py's compiler call doesn't allow the --create_source_map option so I just do the compiler separately. I tried it with the calls to each function in the code but it still doesn't pick up fileB. (I'll update the code in the original question) – user2394200 Jun 05 '13 at 14:21
  • I apologize for not putting this in the original post and code but I should also mention that my outpout mode is script (post is now updated.) – user2394200 Jun 05 '13 at 14:30
  • HMR - I just noticed from your link to the article on Lime that I can add --compiler_flags to the closurebuilder command and take advantage of creating the source map all in one step. You can disregard the comment appearing two entries before this. Thanks for the link! – user2394200 Jun 05 '13 at 14:50

2 Answers2

0

Maybe you can use caccdeps.py to update your deps.js file if you have a complex project. If your code can run uncompiled than it should compile as well.

Here is some info on using cacldeps.py, maybe you can solve the problem by placing the JavaScript files in the right directory: WIKI: How to use Lime (how to use closure-compiler with 3rd party (closure) libraries)

Community
  • 1
  • 1
HMR
  • 37,593
  • 24
  • 91
  • 160
0

I was trying to use the Library backwards. I thought that you went up the tree, goog.required a "class" and then instantiated, augmented, etc... When, in reality, you use goog.require/provide to create a dependency tree that starts at the top and moves down the tree you create. This solved the problem. Thanks so much to all who commented/answered.