jmoenig / morphic.js

a lively web GUI
GNU Affero General Public License v3.0
179 stars 49 forks source link

suggestion: splitting morphic.js in multiple files #4

Open davidedc opened 11 years ago

davidedc commented 11 years ago

morphic.js now counts 10471 lines and has passed the limit of what Github can handle to show diffs online. Also I found myself investigating a few times what the history of a particular class was.

Both issues prompt me to suggest a splitting of the file into smaller ones. If having one unique morphic.js file is critical, a barebone build system that is entirely cross-plarform and requires zero installations is possible: just a simple script (.sh in unix and .bat in windows) that "cat >>"s (unix) or "copy >>"es (windows) multiple files into a concatenated file.

I am a hipster coder, I code in Comic Sans and I know that not having a build system on a > 10K LOC project is very punk rock and a worthy topic of discussion with the snotty professional coders, I get it.

Still, I put forward my suggestion, I volunteer to provide implementation.

umaar commented 11 years ago

+1, smaller and more maintainable JS files could also encourage contributions from others.

ghost commented 9 years ago

I disagree. Imagine someone wants to use morphic.js after this has been splitted. You need a <script> element for every morph. That's confusing for most users.

ghost commented 9 years ago

You could just skip the /blob/ and go directly to /edit/ via typing https://github.com/jmoenig/morphic.js/edit/master/morphic.js . Simply wait some time and when finished loading the blob, close the tab. No need for this.

davidedc commented 9 years ago

ok this is implemented in both @milmazz's fork and in Zombie Kernel

jmoenig commented 9 years ago

I kinda like the idea of splitting up Morphic into several, more manageable files, but I also like to use it as just a single file, somewhat like JQuery, I'm really torn. Somehow I didn't think Morphic.js would have much of a life outside of Snap (and it really doesn't), but then again I like it to be some kind of "core" that is reusable for other projects.... (sigh... decisions....) :-)

cycomachead commented 9 years ago

somewhat like JQuery,

The answer here is a simple build script, and optionally a git hook. jQuery is not developed as a single file, but as dozens (hundreds even?) of smaller files. https://github.com/jquery/jquery/tree/master/src

(In general, I like smaller files within directories because it helps me see a more clear structure to an app's organization. Obviously, this is just a personal preference, but I do think it can help newer devs find what they're looking for more easily.)

milmazz commented 9 years ago

I disagree. Imagine someone wants to use morphic.js after this has been splitted. You need a <script> element for every morph. That's confusing for most users.

It's not necessary that way, in the development phase you can use a Task Manager like Gulp or Grunt. In the issue #12 you can see a possible solution using Gulp, with this task manager it's really easy for the developers create the build version of Morphic.js along with the minified copy and the associated map file. Among other things you can also automate JS Code Quality checks with JSLint, run unit tests on your code, etc.

milmazz commented 9 years ago

As @cycomachead mentioned before:

jQuery is not developed as a single file, but as dozens (hundreds even?) of smaller files.

jQuery uses the Asynchronous Module Definition (AMD) API to organize its internal dependencies, this lets you create custom builds when you are only interested on certain portions or individual modules of jQuery, and not the whole library.

Please, if you look the GitHub page for jQuery you will see that they let you build your own jQuery using Grunt as a Task Manager.

In the issue #12 you can see a possible solution for Morphic.js using Gulp Task Manager.

menasheh commented 6 years ago

Just saw this now, after I opened PR #47 - what do you guys think?