Posts

Showing posts with the label Builder

Create a JS builder with node.js

A very good and common practice with JS projects bigger than 100 lines of code is to split code in different files. Benefits are clear: smaller pieces of code to maintain swappable portions for experiments and/or improvements or new features, as example including for a build magic2.js and get it, rather than change drastically magic.js and follow the repository logs better organization of the code, and I'll come back on this in this post possibility to distribute bigger closures, as example the jQuery approach create ad hoc builds including or excluding portion of the library, specially suitable for specific version of the code that must be compatible with IE only Solutions All Over The Place There are really tons of solutions able to make the described build process easy to use and easy to go. As example, I have created my own one and I am using it with basically every project I am working with: the JavaScript Builder . However, this builder requires a couple of extra technologi...

JavaScript Builder from Falsy Values

Update: uglify-js as third option Thanks to @kitgoncharov JSBuilder now includes the option to run uglify-js through Rhino ... still cross platform, a builder for any taste. as promised during my workshop, I have created a Google Code Project with the builder used to demonstrate most advanced and common techniques to make a library, application, snippet, small and fast. What Is JSBuilder It's a truly simple Python module based over a certain hierarchy able to combine multiple files and produce a minified version of the application. A similar approach has been used since ages with jQuery, and I am pretty sure there are tons of builders out there able to do similar task. I personally created ages ago a similar project compatible with all windows platform . However, that project was missing the possibility to put everything together, preserve some piece of code if necessary, replace some string runtime, and produce if necessary different outputs through the simplified module approac...

ES5 Common Design Patterns Examples - Part 1

// Abstract Factory /* ({}).createInstance() (function (a, b, c) { this.sum = a + b + c; }).createInstance([1, 2, 3]) */ Object.defineProperty( // (C) WebReflection - Mit Style License Object.prototype, "createInstance", { value: (function (create) { return function createInstance(args) { var self = this, isFunction = typeof self == "function", obj = create(isFunction ? self.prototype : self) ; isFunction && args != null && self.apply(obj, args); return obj; }; }(Object.create)) } ); // Abstract Builder /* var person = Object.builder({ setup: function (name) { this.create(); this.instance.name = name; } }); person.setup("WebReflection"); alert(person.instance.name); person.create(); person.instance.name = "Andrea"; alert(person.instance.name); */ Object.defineProperty( // (C) WebReflection - Mit Style License Function.prototype, "builder", { ...