Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 522351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:20:42+00:00 2026-05-13T08:20:42+00:00

We are trying to switch the packaging for our project from dojo to google

  • 0

We are trying to switch the packaging for our project from dojo to google closure, but we haven’t had any luck so far. Here is a simple example that illustrates what we are trying to accomplish:


<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript" src="runtime/src/core/lib/goog-rev26/base.js"></script>
        <script>
            goog.require("foo.bar");
            function main() {foo.bar.echo("hello world")}
        </script>
    </head>
<body onload="main()">
</body>
</html>

Then in /foo/bar.js I have:


goog.provide("foo.bar");
foo.bar.echo = function(s) {console.debug(s);}

The errors I receive in firebug are as follows:

goog.require could not find: foo.bar
foo is not defined

When I look in the Net tab, there isn’t an http request out to fetch a file – I was expecting the closure library to generate a script tag to fetch bar.js.

help! 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:20:42+00:00Added an answer on May 13, 2026 at 8:20 am

    I figured it out and it’s not very hard, but there are a few gotchas.

    Basically, you can use the dependency generating script calcdeps.py (you should read calcdeps.py docs) in one of several modes:

    1. Generating deps.js file
    2. Concatenating everything into a single file, optionally compiling it using the closure compiler.

    For development you should use (1), since it allows you to not run the calcdeps.py after editing the JS sources, unless you make changes to the dependency tree. The rest of the answer is about this way, I haven’t tried the other one yet.

    Here’s what I did to generate it:

    #!/bin/bash
    cd closure-library/closure/goog
    python ../bin/calcdeps.py -p ../../../js -o deps > ../../../my-deps.js
    

    …assuming the following directory structure:

    project/
      closure-library/ (as checked out from SVN)
      js/ (my JS code)
      app.html
    

    (the -p parameter traverses all js files in the specified directory and the docs say you can specify multiple directories to search if you have to.)

    The above call creates a my-deps.js file next to the main app.html, which I use to run the application. The created file contains information about my JS files in js/ and looks like this:

    goog.addDependency('../../../js/controllers.js', ['proj.controllers'], []);
    goog.addDependency('../../../js/ui.js', ['proj.ui'], ['proj.controllers']);
    

    – where the first string it the path to my JS file relative to closure-library/closure/goog/base.js (this is important!), the second array is the list of goog.provide-d strings, and the last array is the list of goog.require-d strings.

    Now in app.html I have:

    <script src="closure-library/closure/goog/base.js"></script>
    <script src="my-deps.js"></script>
    <script>
      goog.require("proj.ui");
    </script>
    <script>
      // here we can use the required objects
    </script>
    

    Note:

    1. In addition to including closure’s base.js, I include my generated deps.js
    2. As mentioned in the tutorial the goog.require call has to be in a separate script tag, because it appends a script tag to load the required scripts and they are loaded after the current script tag finished processing.

    Gotchas:

    1. The described above issue with paths being relative to base.js. goog.require creates the script URL to load by concatenating the base.js base URL (i.e. without base.js leafname) and the first parameter to goog.addDependency in deps.js.
    2. calcdeps.py doesn’t work well on Windows, in particular using the backslashes in the deps.js string literals
    3. If something doesn’t work well, you may want to look through all issues mentioning calcdeps and make sure you have an up to date checkout.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to switch from Pyramid to Django for a small project. The website
I'm trying to switch back from my UIViewController to my UITableViewController but apperendly it's
I'm trying to switch our build from CruiseControl.NET running a custom .msbuild file to
I'm trying to switch over to Storyboard from IB and code but got the
I'm trying to switch from phpDocumentor to doxygen, but all my classes are documented
I'm trying to switch our mobile site from the jQuery Mobile Alpha to the
I'm really trying to switch to emacs, but learning to setup the environment is
I'm trying to switch from CellTable to DataGrid. The actual change was very easy
I have never code in Python and trying to switch from Javascrpt/SVG. Being confused
So my problem is simple. I am trying to switch my chart from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.