Compressing a v3 app

21 views
Skip to first unread message

dvmorris

unread,
Jul 7, 2010, 5:51:05 PM7/7/10
to JavaScriptMVC
I'm trying to run:

js appname\scripts\compress.js

And it's just sitting there. Is there any way to debug this process? I
let it go for at least 10 minutes with no output to the console.

Are there any known compatibility issues with the compress script in
v3?

Thanks for your help,

Dave

Justin Meyer

unread,
Jul 7, 2010, 5:52:47 PM7/7/10
to javasc...@googlegroups.com
js -d

turn on debugging, then run

load('appname/scripts/compress.js')

The debugger will catch in a few Envjs feature detection errors, ignore those.


Justin Meyer

Jupiter Consulting
\Development\Training\Support
847-924-6039
justin...@gmail.com



--
You received this message because you are subscribed to the Google Groups "JavaScriptMVC" group.
To post to this group, send email to javasc...@googlegroups.com.
To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javascriptmvc?hl=en.


Brian Moschel

unread,
Jul 7, 2010, 5:54:19 PM7/7/10
to javasc...@googlegroups.com
It should say which scripts its compressing at that time.  If you see nothing try a very simple app (just the cookbook).  If that works, then start adding in pieces again until you see what breaks it.

Are you using latest from git?

- Brian

On Wed, Jul 7, 2010 at 4:51 PM, dvmorris <dvmo...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "JavaScriptMVC" group.
To post to this group, send email to javasc...@googlegroups.com.
To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javascriptmvc?hl=en.




--
Brian Moschel


Jupiter Consulting
\Development\Training\Support

dvmorris

unread,
Jul 7, 2010, 6:05:03 PM7/7/10
to JavaScriptMVC
I pulled from git a while back, and I have been running the js *
\update commands frequently.

dvmorris

unread,
Jul 7, 2010, 6:09:01 PM7/7/10
to JavaScriptMVC
I tried js -d and ran the load command, and it breaks on a file called
date.js. I got it from here: http://www.datejs.com/

It's already compressed, perhaps that's the problem. It says the error
is on line 46, I believe this is the file I grabbed:

http://code.google.com/p/datejs/source/browse/trunk/build/date-en-US.js

Dave

On Jul 7, 4:52 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> js -d
>
> turn on debugging, then run
>
> load('appname/scripts/compress.js')
>
> The debugger will catch in a few Envjs feature detection errors, ignore
> those.
>
> Justin Meyer
>
> Jupiter Consulting
> \Development\Training\Support
> 847-924-6039
> justinbme...@gmail.com
>
>
>
> On Wed, Jul 7, 2010 at 4:51 PM, dvmorris <dvmor...@gmail.com> wrote:
> > I'm trying to run:
>
> > js appname\scripts\compress.js
>
> > And it's just sitting there. Is there any way to debug this process? I
> > let it go for at least 10 minutes with no output to the console.
>
> > Are there any known compatibility issues with the compress script in
> > v3?
>
> > Thanks for your help,
>
> > Dave
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "JavaScriptMVC" group.
> > To post to this group, send email to javasc...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > javascriptmv...@googlegroups.com<javascriptmvc%2Bunsubscribe@goog legroups.com>
> > .

Justin Meyer

unread,
Jul 7, 2010, 6:10:51 PM7/7/10
to javasc...@googlegroups.com
What is the error?  You can steal things with the compress: false flag.


Justin Meyer

Jupiter Consulting
\Development\Training\Support
847-924-6039
To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.

dvmorris

unread,
Jul 7, 2010, 6:24:44 PM7/7/10
to JavaScriptMVC
The error is org.mozilla.javascript.EcmaError: TypeError: Cannot find
function getDate in object [Window]

How do I steal this particular file with compress=false when I'm doing
it in the appname.js file by calling
steal.plugins(...).resources('date')...


Dave

On Jul 7, 5:10 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> What is the error?  You can steal things with the compress: false flag.
>
> Justin Meyer
>
> Jupiter Consulting
> \Development\Training\Support
> 847-924-6039

dvmorris

unread,
Jul 7, 2010, 6:26:27 PM7/7/10
to JavaScriptMVC
Just to clarify, I uncompressed part of this date.js file, and found
the error to be happening in this code:

Date.prototype.getOrdinal=function(){
switch(this.getDate()){
case 1:
case 21:
case 31:
return"st";
case 2:
case 22:
return"nd";
case 3:
case 23:
return"rd";
default:
return"th";
}
};

Justin Meyer

unread,
Jul 7, 2010, 6:26:42 PM7/7/10
to javasc...@googlegroups.com
http://v3.javascriptmvc.com/index.html#&who=steal.prototype.init

steal({
  path: 'path/to/date.js',
  compress: 'false'
})

Justin Meyer

Jupiter Consulting
\Development\Training\Support
847-924-6039
To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.

Justin Meyer

unread,
Jul 7, 2010, 6:28:04 PM7/7/10
to javasc...@googlegroups.com
This might be a problem w/ rhino.  However, why is this code running?  I'm pretty sure we prevent env from running load or ready event handlers.


Jupiter Consulting
\Development\Training\Support
847-924-6039
justin...@gmail.com


To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.

Alexandre Gomes

unread,
Jul 7, 2010, 6:29:53 PM7/7/10
to javasc...@googlegroups.com
steal.plugins(...).resources({path:date, compress:false})...

On Wed, Jul 7, 2010 at 5:24 PM, dvmorris <dvmo...@gmail.com> wrote:

> To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.

dvmorris

unread,
Jul 7, 2010, 6:30:14 PM7/7/10
to JavaScriptMVC
Yeah, I couldn't figure out why it's trying to run that code during
the compress process. I guess I'll live without compression for now.

Dave

On Jul 7, 5:28 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> This might be a problem w/ rhino.  However, why is this code running?  I'm
> pretty sure we prevent env from running load or ready event handlers.
>
> Jupiter Consulting
> \Development\Training\Support
> 847-924-6039

dvmorris

unread,
Jul 7, 2010, 6:55:13 PM7/7/10
to JavaScriptMVC
I uncompressed everything in date.js, and the code that barfs is this
function:

// Tokenizers
//
rtoken: function (r) { // regex token
return function (s) {
var mx = s.match(r);
if (mx) {
return ([ mx[0], s.substring(mx[0].length) ]);
} else {
throw new $P.Exception(s);
}
};
},

On the line with the '} else {'. I have no idea why that's happening.

Dave

Alexandre Gomes

unread,
Jul 7, 2010, 7:27:52 PM7/7/10
to javasc...@googlegroups.com
maybe the compressor doesn't recognize:

 return ([ mx[0], s.substring(mx[0].length) ]);

did you try removing the parenthesis:

 return [ mx[0], s.substring(mx[0].length) ];

> To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.

dvmorris

unread,
Jul 7, 2010, 7:29:48 PM7/7/10
to JavaScriptMVC
Yes, I tried that, and it gave the same error.

Alexandre Gomes

unread,
Jul 7, 2010, 7:31:37 PM7/7/10
to javasc...@googlegroups.com
maybe an end of line issue?

dvmorris

unread,
Jul 7, 2010, 7:47:53 PM7/7/10
to JavaScriptMVC
It seems to occur in both the compressed and the uncompressed version,
so it probably isn't related to end of line characters. I tried
messing with it and it didn't seem to have any effect.

Justin Meyer

unread,
Jul 7, 2010, 8:59:14 PM7/7/10
to javasc...@googlegroups.com
The problem is with the compressor, rhino, or envjs?

Sent from my iPhone

Justin Meyer

unread,
Jul 7, 2010, 9:00:25 PM7/7/10
to javasc...@googlegroups.com
And when you say barf, what is it barfing?

Sent from my iPhone

On Jul 7, 2010, at 6:47 PM, dvmorris <dvmo...@gmail.com> wrote:

dvmorris

unread,
Jul 8, 2010, 12:31:30 AM7/8/10
to JavaScriptMVC
I'm not sure whether the problem is with compressor, rhino, or envjs.
How can I tell?

Here are the steps to reproduce my problem:

1. from command line run: js -d
2. inside Rhino interface, toggle Debug -> Break on Exceptions
3. type load('appname/scripts/compress.js') and hit Enter.
4. Click Go.
5. Watch a bunch of files open up in the Rhino interface
6. Rhino throws this Exception when it opens date.js:
Exception in Script
org.mozilla.javascript.EcmaError: TypeError: Cannot read
property "0" from undefined (file://path/to/appname/../appname/
resources/date.js#142)

Or, if I load the uncompressed version of date.js, which is comprised
of 5 separate files, it throws this exception:
Exception in Script
org.mozilla.javascript.JavaScriptException: [object Object]
(file://path/to/appname/../appname/resources/datejs/src/parser-
debug.js#26)

Is that enough information? I'm not sure beyond that what Rhino
JavaScript Debugger is doing at the point where it gets the error.

Thanks for your help,

Dave


On Jul 7, 8:00 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> And when you say barf, what is it barfing?
>
> Sent from my iPhone
>

Justin Meyer

unread,
Jul 8, 2010, 12:43:20 AM7/8/10
to javasc...@googlegroups.com
Rhino -> JavaScript interpreter
Envjs ->  Simulated Browser
Closure -> The compression engine.

It looks like it's a problem with the JS interpreter.

What happens if you just load the parser file?

load('parser-debug.js')


Justin Meyer

Jupiter Consulting
\Development\Training\Support
847-924-6039

dvmorris

unread,
Jul 8, 2010, 12:45:50 AM7/8/10
to JavaScriptMVC
I commented out the offending line, and found a few other lines of
code that cause similar Exceptions:

line 383 of parser-debug.js:
var r = rule.call(this, s);
return [fn.call(this, r[0]), r[1]];

line 814 of parser-debug.js:
var _get = function (f) {
return _F[f] = (_F[f] || g.format(f)[0]);
};

When I get rid of that code, there are no more Exceptions thrown in
the debugger, but it still seems to hang on a file that contains this
text:

steal.end();

The title of this window in Rhino is eval(steal.end();...):
1278564059804

From there, the only button I have access to is "Break". Once I click
that, it takes me to line 5346 of env.js: for(;;) {

Dave

Alexandre Gomes

unread,
Jul 8, 2010, 10:14:17 AM7/8/10
to javasc...@googlegroups.com
the DateJs extension to Date are in conflict with how Envjs uses Date.

One workaround is to wrap datejs code with this:

if (!navigator.userAgent.match(/Rhino/)) {
...
datejs code
...
}

this should allow you to compress the app.

Justin Meyer

unread,
Jul 8, 2010, 11:26:19 AM7/8/10
to javasc...@googlegroups.com
How can you be sure about that?

How does Env use date? Date is part of ECMAScript, not the DOM.

Sent from my iPhone

David Morris

unread,
Jul 9, 2010, 12:09:36 AM7/9/10
to javasc...@googlegroups.com
When I do that I receive an error on line 412 of env.js:

org.mozilla.javascript.EvaluatorException: Compilation produced one syntax errors.

Then I hit OK, and Go, and I receive this error:

org.mozilla.javascript.EcmaError: TypeError: Cannot find function today in object function Date() { [native code for Date.Date, arity=1] } . (file://path/to/appname/../appname/models/week.js#22)

This line of code that errors out is trying to use code from date.js, which I suppose is excluded because of that if statement I added to date.js.

Dave

Justin Meyer

unread,
Jul 9, 2010, 12:46:48 AM7/9/10
to javasc...@googlegroups.com
You might ask if people use datejs on rhino and if there is a supported version. 



Sent from my iPhone

David Morris

unread,
Jul 22, 2010, 12:20:50 PM7/22/10
to javasc...@googlegroups.com
Just an update on this one, I actually removed date.js and reverted to default JavaScript date functionality throughout my jmvc app, and Rhino worked perfectly. I didn't get any feedback from the date.js team.

Datejs does seem like a great idea, but I think it's just a little half baked. Are there any other similar attempts to make it easier to work with dates in JavaScript? Do most people rely on jQuery UI Datepicker's stuff?

Dave
Reply all
Reply to author
Forward
0 new messages