Routing error on deps.js #2

Closed
joshjhall opened this Issue Sep 28, 2011 · 6 comments

Comments

Projects
None yet
3 participants
@joshjhall

Just trying to set this up on a fairly new project to play with closure.

I'm getting the following routing error...
ActionController::RoutingError (No route matches [GET] "/deps.js")

Looking at the source, the following line is being put into the head after my first call to goog.require()...

<script type="text/javascript" src="deps.js"></script>

I assume this should be routed to something like src="assets/deps.js"; however, I'm not sure what the "right" approach is for this with the asset pipeline and vendor dir.

@igrigorik

This comment has been minimized.

Show comment Hide comment
@igrigorik

igrigorik Sep 28, 2011

Owner

Hmm, actually we shouldn't even need that. I'm still learning closure myself, but from my understanding deps.js is used for dynamic loading use cases - it basically specifies the dependency tree. This is something the asset pipeline should handle on the server side for us, hence the file is not needed.

Now to figure out how to disable it.. :-)

Owner

igrigorik commented Sep 28, 2011

Hmm, actually we shouldn't even need that. I'm still learning closure myself, but from my understanding deps.js is used for dynamic loading use cases - it basically specifies the dependency tree. This is something the asset pipeline should handle on the server side for us, hence the file is not needed.

Now to figure out how to disable it.. :-)

@joshjhall

This comment has been minimized.

Show comment Hide comment
@joshjhall

joshjhall Sep 28, 2011

After a bit of experimentation I found that turning on debug mode for sprockets will cause things to hang. So...
config.assets.debug = true

Leads to things hanging at...
Started GET "/assets/goog/deps.js" for 127.0.0.1 at 2011-09-28 02:18:29 -0500
Served asset /goog/deps.js - 304 Not Modified (2ms)

Not sure if that'll help, but it's the only thing I found that might be useful.

After a bit of experimentation I found that turning on debug mode for sprockets will cause things to hang. So...
config.assets.debug = true

Leads to things hanging at...
Started GET "/assets/goog/deps.js" for 127.0.0.1 at 2011-09-28 02:18:29 -0500
Served asset /goog/deps.js - 304 Not Modified (2ms)

Not sure if that'll help, but it's the only thing I found that might be useful.

@igrigorik

This comment has been minimized.

Show comment Hide comment
@igrigorik

igrigorik Sep 28, 2011

Owner

Reading through the docs, looks like there are several ways to disable this, one of which is by adding this prior to loading closure files:

<script type="text/javascript">
  var CLOSURE_NO_DEPS = true;
</script>

Should also be able to bake this directly into the pipeline to avoid the extra hassle.

Owner

igrigorik commented Sep 28, 2011

Reading through the docs, looks like there are several ways to disable this, one of which is by adding this prior to loading closure files:

<script type="text/javascript">
  var CLOSURE_NO_DEPS = true;
</script>

Should also be able to bake this directly into the pipeline to avoid the extra hassle.

@joshjhall

This comment has been minimized.

Show comment Hide comment
@joshjhall

joshjhall Sep 28, 2011

Hmm... well, I no longer get a 404 error, but it's not actually loading the closure files at all.

I have this in the head of my template (using HAML here)

%script{ :type => "text/javascript" }
  var CLOSURE_NO_DEPS = true;
= javascript_include_tag :application

And this in my application.js

goog.require('goog.dom');
newHeader = goog.dom.createDom('h1', {}, 'Hello world!');
goog.dom.appendChild(document.body, newHeader);

I'm getting a "Uncaught TypeError: Cannot call method 'appendChild' of null" error, because goog.dom isn't being included correctly.

Hmm... well, I no longer get a 404 error, but it's not actually loading the closure files at all.

I have this in the head of my template (using HAML here)

%script{ :type => "text/javascript" }
  var CLOSURE_NO_DEPS = true;
= javascript_include_tag :application

And this in my application.js

goog.require('goog.dom');
newHeader = goog.dom.createDom('h1', {}, 'Hello world!');
goog.dom.appendChild(document.body, newHeader);

I'm getting a "Uncaught TypeError: Cannot call method 'appendChild' of null" error, because goog.dom isn't being included correctly.

@igrigorik

This comment has been minimized.

Show comment Hide comment
@igrigorik

igrigorik Oct 1, 2011

Owner

Hi Josh, please take a look at this thread: #1

Closing this thread, since it's the same issue.

Owner

igrigorik commented Oct 1, 2011

Hi Josh, please take a look at this thread: #1

Closing this thread, since it's the same issue.

@igrigorik igrigorik closed this Oct 1, 2011

@dogenpunk

This comment has been minimized.

Show comment Hide comment
@dogenpunk

dogenpunk Jan 3, 2012

Contributor

I was just having this very same issue and, like @joshjhall I thought it was an issue with the loading of 'goog.dom'. After adding the var CLOSURE_NO_DEPS = true; I was getting the "Uncaught TypeError" he mentioned. I resolved it by changing the code from the README

goog.require('goog.dom');

function sayHi() {
    newHeader = goog.dom.createDom('h1', {}, 'Hello, world!');
    goog.dom.appendChild(document.body, newHeader);
}

window.onload = sayHi;

In the closure library goog.dom.appendChild is defined

goog.dom.appendChild = function(parent, child) {
  parent.appendChild(child);
};

The issue is actually trying to call document.body before the DOM is loaded.

Contributor

dogenpunk commented Jan 3, 2012

I was just having this very same issue and, like @joshjhall I thought it was an issue with the loading of 'goog.dom'. After adding the var CLOSURE_NO_DEPS = true; I was getting the "Uncaught TypeError" he mentioned. I resolved it by changing the code from the README

goog.require('goog.dom');

function sayHi() {
    newHeader = goog.dom.createDom('h1', {}, 'Hello, world!');
    goog.dom.appendChild(document.body, newHeader);
}

window.onload = sayHi;

In the closure library goog.dom.appendChild is defined

goog.dom.appendChild = function(parent, child) {
  parent.appendChild(child);
};

The issue is actually trying to call document.body before the DOM is loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment