CommonJS - Integration with more JS platforms

28 views
Skip to first unread message

kvz

unread,
Nov 23, 2009, 5:34:37 AM11/23/09
to php.js
I asked Felix (he does a lot of nodejs stuff nowadays) how we could
close the gap between php.js and serverside js platforms like nodejs,
and it seems this is the answer: http://wiki.commonjs.org/wiki/Modules/1.1
Felix: "that just means that you need to put all php.js functions in 1
file and have each of them declared on the 'exports' object in that
file your file would be called php.js and I could include it via:
require('php');"

I imagine the compiler could create a 3rd version next to our normal
and namespaced: 'commonjs'.
Additionally we could provide a preset with just functions that make
sense to have on the server: sha1, md5, that kind of thing.
In that preset we'd have to drop the 'require' function in any case to
avoid confusion between commonjs' require & ours.

Changing the compiler is probably a day work. There may be more
problems in getting our functions compatible, I don't know. We could
have to investigate that if you guys like the idea.

Brett

unread,
Nov 30, 2009, 4:15:14 AM11/30/09
to php.js
I was told that we might be able to get php.js added as a module with
Cuddlefish--a modular system for Jetpack (which I think I remember
reading used CommonJS too, albeit on the client-side), thus allowing
people to build Firefox extensions with only a knowledge of HTML, CSS,
and php.js!

There's also something called FUEL for those building full-blown
Firefox extensions to which we could possibly get php.js added, but I
think Jetpack would be a higher priority if this module system
develops.

Kevin van Zonneveld

unread,
Dec 9, 2009, 6:14:57 AM12/9/09
to ph...@googlegroups.com
Ok that sounds pretty cool. Let me see how easy it is for me to
implement CommonJS in the compiler
--
Met vriendelijke groet / Kind regards,

Kevin van Zonneveld
http://kevin.vanzonneveld.net

http://twitter.com/kvz

Philip Peterson

unread,
Nov 19, 2010, 5:35:27 AM11/19/10
to ph...@googlegroups.com
I know this project's rather dead these days, but the code should at least be accessible without going through and copy-pasting all the functions into a giant text file. Is there something I can do to help fix the compiler?

Philip Peterson

Kevin van Zonneveld

unread,
Nov 20, 2010, 5:59:22 AM11/20/10
to ph...@googlegroups.com
Hey Philip,

You are right. In between work, bootstrapping transloadit.com, and
bugfixing system_daemon, php.js is not getting the time it deservers
anymore.
I'm willing to give the leadership to someone else if that's what it takes.
But that won't fix the compiler.

I have plans of migrating the website to a github pages site, so that
it everyone with commit access to php.js can generate & push a new
site live without my intervention.
In the meantime I will try to squeeze in some time to fix the
compiler. Cause obviously we the aforementioned plan will take a bit
longer.

PS
The actual compiling code is also part of the phpjs repo itself..

--

Kevin van Zonneveld

unread,
Nov 21, 2010, 5:18:22 AM11/21/10
to ph...@googlegroups.com
Think I fixed the issue, btw.

Philip Peterson

unread,
Nov 21, 2010, 5:54:13 AM11/21/10
to ph...@googlegroups.com
I'm taking a look at the source to see if I can start to understand how it works. The issue doesn't seem to be fixed; clicking the Compile button just takes me back to the compile page.

Philip Peterson

Kevin van Zonneveld

unread,
Nov 21, 2010, 6:03:14 AM11/21/10
to ph...@googlegroups.com
Getting "Successfully compiled" or "Found an existing package with the
same configuration" every time I try it.
What configuration do you use that results in a reproducible failure
on your end?

Philip Peterson

unread,
Nov 21, 2010, 7:10:16 AM11/21/10
to ph...@googlegroups.com
Functions: none, except for echo.
Compression: none
Namespaced: yes


Philip Peterson

Kevin van Zonneveld

unread,
Nov 27, 2010, 8:18:51 AM11/27/10
to ph...@googlegroups.com
Also getting succesfully compiled on OSX/Chrome 7.0
What platform does it not work on? What if you clear your caches?

Philip Peterson

unread,
Nov 27, 2010, 9:03:05 AM11/27/10
to ph...@googlegroups.com
Odd, I can't get it to work on Firefox, Chrome, or Safari on OS X.6. Tried clearing caches as well. I don't think I'm "just missing it" (the notification that the package has successfully compiled, etc.) but can you post a screenshot just so we're sure that I'm not just blind?

Philip Peterson

Philip Peterson

unread,
Nov 27, 2010, 9:03:28 AM11/27/10
to ph...@googlegroups.com
Also, even the default configuration fails to build.

Philip Peterson

Kevin van Zonneveld

unread,
Nov 27, 2010, 10:34:10 AM11/27/10
to ph...@googlegroups.com

Philip Peterson

unread,
Nov 27, 2010, 10:35:44 AM11/27/10
to ph...@googlegroups.com
Nope, I don't get that at all. It just takes me back to /packages/compile.
Philip Peterson

Kevin van Zonneveld

unread,
Nov 27, 2010, 10:36:41 AM11/27/10
to ph...@googlegroups.com
No errors or nothing?

carnio...@gmail.com

unread,
Nov 27, 2010, 10:37:18 AM11/27/10
to ph...@googlegroups.com
No.
Sent on the Sprint® Now Network from my BlackBerry®

Philip Peterson

unread,
Nov 27, 2010, 12:52:02 PM11/27/10
to ph...@googlegroups.com
It may be of use to know that accessing the URL from the screenshot works fine; I see the summary and download link, and everything works fine.

Philip Peterson

Kevin van Zonneveld

unread,
Nov 28, 2010, 3:43:21 PM11/28/10
to ph...@googlegroups.com
That's the page you get forwarded to after a successful compile, but
the page remains available for a while as well.

I haven't found any errors in the logs since I pushed the fix either.

Would it be possible for you to figure out what's happening in terms
of HTTP requests, JavaScript error console, etc?
Does it appear to do a page reload? Or is nothing happening at all?
Does the POST get through?

Any more info on these matters would be helpful in finding the cause.

Philip Peterson

unread,
Nov 29, 2010, 3:05:03 PM11/29/10
to ph...@googlegroups.com
No JavaScript errors; seems there's one "failure" I found by logging the HTTP headers:

http://cl.ly/362C2D1a1r0V2c2o172C

"Client closed connection before receiving entire response"



Philip Peterson

Kevin van Zonneveld

unread,
Dec 5, 2010, 9:46:12 AM12/5/10
to ph...@googlegroups.com
Could it be a proxy times out or something? Have you tried another environment?

Philip Peterson

unread,
Dec 6, 2010, 8:24:40 AM12/6/10
to ph...@googlegroups.com
I've tried several public computers, all which result in the same failure. The only proxy being used was the Charles proxy (to capture the HTTP headers). I still get the error when not using the proxy, so it doesn't seem like that would be the issue.

Philip Peterson

Kevin van Zonneveld

unread,
Dec 12, 2010, 11:56:04 AM12/12/10
to ph...@googlegroups.com
I'm still looking for a machine where I can reproduce this on, Philip.
It's impossible to fix otherwise.

Philip Peterson

unread,
Dec 12, 2010, 12:46:41 PM12/12/10
to ph...@googlegroups.com
@KvZ:

It's really odd that I can't find a computer that doesn't reproduce it, and you can't find one that can :P. Perhaps (weird/unlikely as it sounds) it's a geographical thing... maybe you could check that your client's HTTP request headers (if they aren't already) include the following?

Accept-Language: en-us,en;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7


Philip Peterson
Reply all
Reply to author
Forward
0 new messages