ActiveState Community

[extension] JavaScript #Include Pre-compiler/exporter.

Posted by stellar on 2009-10-24 03:10
OS: All / Any

/*****Rant*****/

Hi, I recently(3 day's) started using Komodo and was pleasantly surprised that it didn't only do highlighting but also REALLY did auto completion(on JavaScript).

So here I am with an app that actually works (And doesn't kill my laptop on loading *koff**Eclipse**koff*).... and I want more..

The big problem with JavaScript is that it has no native #Include option. And virtually no IDE has export options of any kind for js/html. This leads to big files in witch u have to keep scrolling up and down, have to set placement markers and all kinds of other "patch" work to keep it workable. Or you turn to a library witch does the include for you using eval methods and other "hacks" witch run up the client side load time and possibly run time. Or you have to include all the files in your HTML by hand in the right order.

My own answer to this problem was the simple thought of an exporter that crammed all your code into one comfy file witch you could then include in your HTML, or even directly include it in the HTML if preferred. Later maybe even add some obfuscation and compacting options if wanted.

Sooooo... I went off to find the wizzard.... Ehem.. extension API..

Did all that, did it again.. again... again........ Now I'm here.

/**** The Idea ****/

The trouble I had was getting information from ko, yes there is an Komodo API (not in the toc) and yes there is also a mozilla IDE but that didn't give me the information I was looking for.

The steps in my process would be the following.

1. Ask witch JS file to export.
2. Ask the name for the export.
3. Load the "to export JS file".
4. Copy it's contents over and look at the #include's.
5. Repeat 3 and 4 over untill no include is found. (Don't include doubble)
6. Save the export file.

Of course there is more to this then just these 6 steps, but it's to give the jist. It should also do some pre-compiling when clicking on debug etc.

/**** The Problems ****/

I changed the idea so it became possible, but what i would want te remove is #1. That should only have to hapen once.
Also it should intergrate more with komodo so when u click on debug it automaticle runs a newly "pre-compiled" script and not the scripts containing the #include witch would surely upset a JS engine anywhere.

Problem is I can't seem to find the inlets into the Komodo project in any significant way with JavaScript, I couldn't even ask it for the files it contained.

So i'm kind of stuck on how to proceed or just make an external pre-compiler. (Witch kind of defeats the idea of extensions)

Any help would be gratefully received.