Build tool

213 views
Skip to first unread message

Phoscur

unread,
Jan 30, 2012, 11:48:58 AM1/30/12
to nodejs
Hi,
I've seen some build tools out there, probably there are a lot more from
people who wrote their own.
What I want to be done on build:
-code check with jslint/jshint
-minification
-browser-side require() replacement
-automatic dependency resolving and including files
-running tests/specs
and the ability to run on filechanges.
My platform is windows.

Codesurgeon looks really nice, but doesn't have the ability to
browserify and needs a list of files, browserify doesn't perform jslint
checks and just didn't work when I tried it last time.

What build tools are you using? Should I give browserify another try?

regards,
Ph

Phoscur

unread,
Jan 31, 2012, 11:31:58 AM1/31/12
to nod...@googlegroups.com
So, this means, there are no other build tools out there?

deitch

unread,
Jan 31, 2012, 1:52:37 PM1/31/12
to nodejs

hij1nx

unread,
Jan 31, 2012, 2:12:54 PM1/31/12
to nodejs
Checkout codesurgeon. https://github.com/hij1nx/codesurgeon

We use this at nodejitsu and for a number of the http://github.com/flatiron
projects.

--
Paolo Fragomeni
Co-founder, CTO
Nodejitsu, Inc.
www.twitter.com/hij1nx
www.github.com/hij1nx


On Jan 31, 1:52 pm, deitch <a...@deitcher.net> wrote:
> Been a long ongoing discussion about this athttp://groups.google.com/group/nodejs/browse_thread/thread/4f5270afb0...

AJ ONeal

unread,
Jan 31, 2012, 2:52:46 PM1/31/12
to nod...@googlegroups.com

node-pakmanager installs browser packages from npm using a package.json - if RequireJS doesn't do this by now, then pakmanager would be a good thing to look into.


EnderJS is similar, but better cli, but the package detection isn't as smart.

RequireJS seems to be the most popular. I didn't use it because I didn't understand AMD before I had written pakmanager.


UglifyJS and google closure can minify


Some of those other things - such as linting - you can just run in a bash script with `find`.

Sent from my Android

--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Phoscur

unread,
Jan 31, 2012, 3:59:33 PM1/31/12
to nod...@googlegroups.com
That is not true. I've been watching that topic, and I couldn't see
anything useful for me in it. Ofc I don't want a build system like Ant.
Who likes XML nowadays??

I've seen cake, but that does not do any of the things I want to be done.

Phoscur

unread,
Jan 31, 2012, 4:08:01 PM1/31/12
to nod...@googlegroups.com
Yes, I've seen codesurgeon.
But it doesn't support this:

> -automatic dependency resolving and including files
How do you load all relevant files? Declaring all files explictly would
be a lot of work...


Building a custom require could work by prepending
> function require(module) {
> return require.cache[module];
> }
> require.cache = {};
And wrapping the module in:
> (function() {
> var exports = {};
> var module = {exports: exports};
>
> // module here
>
> require.cache.MODULENAME = module.exports;
> }());
But this is still not bulletproof..

Phoscur

unread,
Jan 31, 2012, 4:44:03 PM1/31/12
to nod...@googlegroups.com
Nice, those tools. I've seen once already, but had a closer look now.
EnderJS makes npm installed modules available in the browser, but not my own code.
RequireJS seems to be able to replace require() so it works in the browser too, but I don't want to go for a special syntax in each module. I like the way of node's require().

I prefer google closure compiler over uglifyjs, but it doesn't really change much..

How do I use pakmanager exactly? I guess I would have to separate my code I use on both sides in a special module with a package.json?

AJ ONeal

unread,
Jan 31, 2012, 5:08:30 PM1/31/12
to nod...@googlegroups.com, Phoscur
How do I use pakmanager exactly? I guess I would have to separate my code I use on both sides in a special module with a package.json?

Your directory structure might look like this:

- project
  - browser
  - server

then you

    cd project/browser
    mkdir lib
    touch lib/index.js # this is your client app
    npm init
    pakmanager build

However, in `package.json` you should use `browserDependencies` instead of `dependencies`.

I've published browser-safe versions of most of the core node modules to npm.

Since someone already claimed `events`, I had to publish it as `events.node`. 

However, `pakmanager` understands `package.json.provides` should override the name of the package. So even though you must `browserDependencies: { "events.node": "*" }, you should still `require('events')`.

If you're using ender modules, It will put out some benign warnings about ender modules that appear to be unused (because to access `jeesh` you require `ender`, and it doesn't understand that yet)

it outputs pakmanaged.js

then, minify as you please:
uglifyjs pakmanaged.js > pakmanaged.min.js

for the server side, you probably do something similar and you end up with a directory tree like this:

- project
  - browser
    - package.json
    - lib
      - index.js
      - submod.js
      - submod2.js
  - server
    - package.json
    - lib
      - index.js
      - othersubmod.js


My original goal for pakmanager was to get it pulled in as Ender 2.0, but we just haven't had enough time and coordination effort to discuss the specifics and get the ball rolling.

Does all of that make sense? If I explained anything poorly, I'll give it another go.

AJ ONeal 

Tim Branyen

unread,
Jan 31, 2012, 5:28:39 PM1/31/12
to nod...@googlegroups.com
Check out:

--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
tim branyen, bocoup

Phoscur

unread,
Jan 31, 2012, 5:33:24 PM1/31/12
to nod...@googlegroups.com

> Your directory structure might look like this:
>
> - project
> - browser
> - server
>
Where do you put code, you use on both sides?

I should be possible with just an entry point, say src/browser.js, to
scan throw the whole source directories bundling all files, getting
modules it can't find from node_modules/.


Phoscur

unread,
Jan 31, 2012, 5:49:51 PM1/31/12
to nod...@googlegroups.com
Looks like another solid build tool.
It doesn't meet all my requirements though:

> -browser-side require() replacement
> -automatic dependency resolving and including files
> and the ability to run on filechanges.


31.01.2012 23:28, Tim Branyen wrote:
> Check out:
>
> http://github.com/cowboy/grunt

Rick Waldron

unread,
Jan 31, 2012, 11:41:56 AM1/31/12
to nod...@googlegroups.com
@Ph,

Ben Alman, from Bocoup, is developing `grunt` which does _everything_ you've listed below. 


use:

npm install grunt -g

mkdir project

cd project

grunt init 

This will walk you through a command line "wizard" that will help you set up a project with a few reasonable defaults, additionally, there are several "types" of projects that have scaffolding that you can initialize.

grunt init:commonjs

grunt init:node

etc...

Rick

AJ ONeal

unread,
Jan 31, 2012, 7:28:26 PM1/31/12
to nod...@googlegroups.com
> Your directory structure might look like this:
>
> - project
>   - browser
>   - server 
>
Where do you put code, you use on both sides?

You create an npm module for it or you symlink it or you copy it. 

I should be possible with just an entry point, say src/browser.js, to
scan throw the whole source directories bundling all files, getting
modules it can't find from node_modules/.

you can `require('../server/blah.js')`, but I'd recommend using a symlink at worst.

I've thought about adding support to list local dependencies in package.json, but npm doesn't like that last time I checked.

I don't know if Isaac has blessed a solution for that particular problem or not.

Nathan Rajlich

unread,
Jan 31, 2012, 9:09:44 PM1/31/12
to nod...@googlegroups.com
You can also check out Browserbuild, from LearnBoost: https://github.com/LearnBoost/browserbuild

--

Phoscur

unread,
Feb 1, 2012, 12:23:05 AM2/1/12
to nod...@googlegroups.com
Great, an alternative to browserify! This is perfect. Now I can choose a build process to combine this with.
Thanks a lot!

So far I've seen
cake, grunt and codesurgeon for the build process
and
enderjs, requirejs, pakmanager, browserify and browserbuild to port node modules to the browserside.

This there more?

hij1nx

unread,
Feb 2, 2012, 12:51:11 AM2/2/12
to nodejs

do any of these do automatic dependency resolving?


On Feb 1, 12:23 am, Phoscur <phos...@pheelgood.net> wrote:
> Great, an alternative to browserify! This is perfect. Now I can choose a
> build process to combine this with.
> Thanks a lot!
>
> So far I've seen
> cake, grunt and codesurgeon for the build process
> and
> enderjs, requirejs, pakmanager, browserify and browserbuild to port node
> modules to the browserside.
>
> This there more?
>
> Am 01.02.2012 03:09, schrieb Nathan Rajlich:
>
>
>
>
>
>
>
> > You can also check out Browserbuild, from
> > LearnBoost:https://github.com/LearnBoost/browserbuild
>
> >     <mailto:nod...@googlegroups.com>
> >     To unsubscribe from this group, send email to
> >     nodejs+un...@googlegroups.com
> >     <mailto:nodejs%2Bunsu...@googlegroups.com>

Phoscur

unread,
Feb 2, 2012, 10:42:13 AM2/2/12
to nod...@googlegroups.com
Yes, both browserify and browserbuild assemble a concatenated file with all files used by require().

Eh, just had a closer look at their sourcecode...
browserbuild does not resolve dependencies, it just includes all files available.
browserify uses some kind of detective to included needed files (so this is indeed the dependency resolving i ment).

hij1nx

unread,
Feb 2, 2012, 2:37:40 PM2/2/12
to nodejs
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/hij1nx
www.github.com/hij1nx



On Feb 2, 10:42 am, Phoscur <phos...@pheelgood.net> wrote:
> Yes, both browserifyand browserbuild assemble a concatenated file with

CoolAJ86

unread,
Feb 3, 2012, 10:57:56 PM2/3/12
to nod...@googlegroups.com
pakmanager also inspects requires such as `require('./some/local/module')` and `require('some-npm-module')`.

It will give you warnings if you have deps listed in package.json which are not being used as well as if you're requiring files which are neither on the filesystem nor in package.json.

Phoscur

unread,
Feb 5, 2012, 10:50:22 PM2/5/12
to nod...@googlegroups.com
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.

Reply all
Reply to author
Forward
0 new messages