I wrote a library for this. It's small (3.8kb) and has a cli for building.

http://www.screenr.com/wOas
https://github.com/gigafied/minion

It allows you to develop locally without having to build every time you
make changes, it handles the dependency loading asynchronously.

When you are ready to push to production, there is a build that resolves
dependencies and allows you to specify multiple build groups to output to
however many minified js files you want.

The one downside I suppose, is that it is strictly centered around the idea
of using Classical Inheritance, so if you're not implementing inheritance
in your current project in some fashion, it might take a bit of work to
implement.

I'd also suggest looking into RequireJS.

I'm personally not a fan of getting require() to work in the browser like
it does in node. require() is synchronous, which is something that works
for node, but doesn't work at all in the browser paradigm. What you get as
a result of this, is forcing users to have to build everytime they change
one js file, I don't know why you would want to do that, or how that is a
workable solution.

Taka


On Thu, Feb 9, 2012 at 11:08 AM, Adam Crabtree <[email protected]> wrote:

> Honestly, all browser-side modules should adhere whether initially or
> through a build process to the AMD pattern as this is where the current
> momentum is and it is a module definition pattern first and foremost built
> for the browser environment. Also, this pattern is very compatible with
> node modules.
>
> Additionally, AMD is independent of common AMD script
> loader implementations that involve an asynchronous require. Even
> Browserify, I believe, uses an AMD compatible define pattern, though I
> haven't looked recently.
>
> How you get the modules to the browser is your concern, so using AMD is
> still compatible with a YUI style combo-loader, Browserify's upfront
> script, or a dynamic includes a la requirejs.
>
> Cheers,
> Adam Crabtree
>
>
> On Tue, Feb 7, 2012 at 4:04 PM, Azer Koçulu <[email protected]> wrote:
>
>> I would like to mention OneJS (http://github.com/azer/onejs) in this
>> topic. It's a new one, creates stand-alone JavaScript files that can be run
>> on all JS platforms, from NodeJS packages. Here is a usage example;
>>
>> $ onejs build package.json build/standalone.js (an example output:
>> http://multiplayerchess.com/mpc.js)
>>
>> You can simply publish the built file and start using it. To make sure it
>> works, you can call it from NodeJS, too;
>>
>> $ node
>> > var foo = require("./build/standalone")
>> > foo.main() // calls the main module defined by package.json
>> > foo.require('process').stdout.write("hello world")
>> > foo.stdout()
>> "hello world"
>>
>> On browsers, it puts all source code under a root object that takes its
>> name from package name. The wrapper code it generates is unobtrusive.
>>
>> It comes with emulation of "process" module and an "install" command for
>> emulation of other supported NodeJS modules. Let's assume we need to
>> include "assert" and "util" modules of NodeJS into the web build:
>>
>> $ onejs install assert util
>>
>> I use this tool to build my online chess app, MultiplayerChess.com. Being
>> able to use NPM on frontend projects is a very good thing.  You can check
>> its source code out;
>> https://github.com/azer/multiplayerchess.com/tree/master/frontend
>>
>> Best,
>>
>> Azer
>>
>> http://azer.kodfabrik.com
>>
>> On Tue, Feb 7, 2012 at 8:49 AM, Phoscur <[email protected]> wrote:
>>
>>>  Thank you! That is useful information. I'm going to spend some time
>>> with the YUI documentation.
>>>
>>> Am 07.02.2012 07:27, schrieb Joe Developer:
>>>
>>> Here is what I do:
>>>
>>>  1. Leverage the YUI3 module system:
>>> http://yuilibrary.com/yui/docs/yui/yui-loader-ext.html
>>> 2. Define my own modules within those conventions.
>>> 3. Use a combo handler: https://github.com/rgrove/combohandler I use a
>>> slightly modified one which runs the resulting file through uglify and
>>> caches the result.
>>>
>>>  Why?
>>> 1. Because I find YUI3 awesome and leverage it anyway, it has an
>>> ecosystem which includes profiling, tests, doc generation, build tools -
>>> and then everything else you might expect from a modern js lib / framework,
>>> plus excellent documentation.
>>>
>>>  2. Because it is flexible and offers a number of advantages; I can
>>> choose to hand-roll the dependency hierarchy while sketching it out, then
>>> move on to automating it from build tools. I can choose if I want to load
>>> the minified, debug instrumented or plain raw version of a given file, I
>>> can even choose to load the tests for it alongside.
>>>
>>>  3. The combo loader system is smart enough to only load what is
>>> actually needed on a given page, if a module is already on the page it
>>> doesn't get loaded twice, I'm not stuck with a monolithic file ( though I
>>> can choose to go that path in practice if it has actual benefit for the
>>> situation ), I can *still* choose what flavor the module that I wan't to
>>> load, on the fly, in production.
>>>
>>>  It ends up something like: <script charset="utf-8" src="
>>> /js/?/yui3/build/classnamemanager/classnamemanager-min.js&yui3/build/oop/oop-min.js&yui3/build/event-custom-base/event-custom-base-min.js&yui3/build/dom-core/dom-core-min.js&yui3/build/dom-base/dom-base-min.js<http://dating.datingvip.dev:3000/js/?/yui3/build/classnamemanager/classnamemanager-min.js&yui3/build/oop/oop-min.js&yui3/build/event-custom-base/event-custom-base-min.js&yui3/build/dom-core/dom-core-min.js&yui3/build/dom-base/dom-base-min.js&yui3/build/selector-native/selector-native-min.js&yui3/build/selector/selector-min.js&yui3/build/node-core/node-core-min.js&yui3/build/node-base/node-base-min.js&yui3/build/event-base/event-base-min.js&yui3/build/event-delegate/event-delegate-min.js&yui3/build/node-event-delegate/node-event-delegate-min.js&yui3/build/array-extras/array-extras-min.js&yui3/build/attribute-core/attribute-core-min.js&yui3/build/base-core/base-core-min.js&yui3/build/event-custom-complex/event-custom-complex-min.js&yui3/build/attribute-events/attribute-events-min.js&yui3/build/attribute-extras/attribute-extras-min.js&yui3/build/attribute-base/attribute-base-min.js&yui3/build/base-%20base/base-base-min.js&yui3/build/base-build/base-build-min.js&yui3/build/history-base/history-base-min.js&yui3/build/event-synthetic/event-synthetic-min.js&yui3/build/history-html5/history-html5-min.js&yui3/build/history-hash/history-hash-min.js&yui3/build/history-hash-ie/history-hash-ie-min.js&yui3/build/router/router-min.js&yui3/build/pjax-base/pjax-base-min.js&yui3/build/view/view-min.js&yui3/build/app-base/app-base-min.js&yui3/build/escape/escape-min.js&yui3/build/handlebars-base/handlebars-base-min.js&yui3/build/handlebars-compiler/handlebars-compiler-min.js&yui3/build/event-key/event-key-min.js&yui3/build/dom-style/dom-style-min.js&yui3/build/node-style/node-style-min.js&yui3/build/transition/transition-min.js&yui3/build/cookie/cookie-min.js&yui3/build/intl/intl-min.js>"
>>> async > </script>
>>>
>>>   You could fairly easily do your jslinting as part of the build
>>> process for individual files, or pull out predefined 'monolithic' files
>>> from the combohandler where you then do the jslinting in that part of the
>>> stack.
>>>
>>>  Preloading / lazyloading ability is built-in.
>>>
>>>  See: https://github.com/ericf/photosnear.me for a full-app example of
>>> how it can be leveraged.
>>>
>>>
>>> On Tue, Feb 7, 2012 at 12:27 PM, Phoscur <[email protected]> wrote:
>>>
>>>>  Splitting this from Build 
>>>> tool<https://groups.google.com/group/nodejs/browse_thread/thread/9814da6a8873db2f/fdfaefa8ca5db7aa>.
>>>>
>>>>
>>>> What I want:
>>>> -given entry.js, the tool has to resolve it's dependencies inspecting
>>>> require, recursivly including all relevant files
>>>> -conviently do jslint/hint checks as codestrings are already loaded
>>>> -possibility to minify for production
>>>> -filewatching and possibly caching
>>>>
>>>> To sum up for now:
>>>> -browserify <https://github.com/substack/node-browserify>: still the
>>>> mightiest for this task I've seen. Does basically all mentionend above. But
>>>> it's "just works(TM)" just won't work for me. I keep running into bugs or
>>>> bad documentation.
>>>> -browserbuild <https://github.com/LearnBoost/browserbuild>: KISS
>>>> implementation, combining all available source files and a simple
>>>> browserside require() replacement
>>>> -pakmanager <https://github.com/coolaj86/node-pakmanager>: like
>>>> browserbuild, but with ender.js require() implementation.
>>>> The last two don't satisfy my needs.
>>>>
>>>> Lazy- or Preload modules:
>>>> Also I noticed that browserify and browserbuild use lazy module
>>>> loading. So the source of each file is wrapped in a function which is
>>>> invoked the first time a module is required. I had implemented this
>>>> diffrently before: I just wrapped a closure around each file source to
>>>> execute when it's loaded. I think it's better to preload all libraries and
>>>> prototypes like I did, although I'm not sure if this would have impact on
>>>> the responsiveness of the interface. Better a long load in the beginning
>>>> that lags in the first minutes. The algorithm for preloading addintionally
>>>> has to include some sorting to execute the files in the right order.
>>>>
>>>> regards,
>>>> Ph
>>>>
>>>>
>>>>
>>>> I wrote:
>>>>
>>>> Yeah, of course. But browserify does this better as anything else, and
>>>> it's IMO the most important part of the JavaScript build process. So a
>>>> lot of focus should go on this and every single nodejs build tool should
>>>> support it by default.
>>>>
>>>> Just specifying one file to start this assembly and then adding all
>>>> required files and modules recursivly seems to be the right approch for
>>>> me. Right?
>>>> Running that through jslint/hint and running tests aswell as diffrent
>>>> dev/production versions seems to me all a build tool for nodejs needs to 
>>>> do.
>>>> I don't see any build tool available which does this well enough.
>>>>
>>>> hij1nx wrote:
>>>>
>>>>
>>>> You could call Browserify a build tool, but it has a single purpose
>>>> (which is good!), it will bundle your commonjs for use in the browser.
>>>> But a lot of the tools mentioned are more general purpose software
>>>> build tools.
>>>>
>>>> --
>>>> Paolo Fragomeni
>>>> Co-founder, CTO
>>>> Nodejitsu, Inc.www.twitter.com/hij1nxwww.github.com/hij1nx
>>>>
>>>>    --
>>>> Job Board: http://jobs.nodejs.org/
>>>> Posting guidelines:
>>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To post to this group, send email to [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>>
>>>
>>>  --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>>  --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>
>>  --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>
>
> --
> Better a little with righteousness
>        than much gain with injustice.
> Proverbs 16:8
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to