Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion: splitting morphic.js in multiple files #4

Open
davidedc opened this issue Jan 26, 2013 · 9 comments · May be fixed by #47
Open

suggestion: splitting morphic.js in multiple files #4

davidedc opened this issue Jan 26, 2013 · 9 comments · May be fixed by #47

Comments

@davidedc
Copy link

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
Copy link

umaar commented Feb 25, 2013

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

@ghost
Copy link

ghost commented Feb 10, 2015

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
Copy link

ghost commented Feb 10, 2015

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
Copy link
Author

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

@jmoenig
Copy link
Owner

jmoenig commented Feb 10, 2015

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
Copy link

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
Copy link

milmazz commented Feb 11, 2015

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
Copy link

milmazz commented Feb 11, 2015

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants