component-builder
Advanced tools
Comparing version 0.5.3 to 0.5.5
0.5.5 / 2012-12-30 | ||
================== | ||
* add lookup and readfile caching mechanisms. Closes #50 | ||
* update require | ||
0.5.4 / 2012-12-20 | ||
================== | ||
* remove rework dep | ||
0.5.3 / 2012-12-20 | ||
@@ -3,0 +14,0 @@ ================== |
@@ -15,3 +15,3 @@ | ||
, mkdir = require('mkdirp') | ||
, rework = require('rework') | ||
, utils = require('./utils') | ||
, dirname = path.dirname | ||
@@ -36,2 +36,3 @@ , basename = path.basename; | ||
var self = this; | ||
this._cache = {}; | ||
this._hooks = {}; | ||
@@ -96,2 +97,3 @@ this._files = {}; | ||
Builder.prototype.inherit = function(dep){ | ||
dep._cache = this._cache; | ||
dep._hooks = this._hooks; | ||
@@ -192,2 +194,3 @@ dep.paths = this.paths; | ||
Builder.prototype.lookup = function(name, fn){ | ||
var cache = this._cache; | ||
var paths = this.paths; | ||
@@ -197,11 +200,27 @@ var self = this; | ||
debug('lookup %s', name); | ||
function next() { | ||
var path = paths[i++]; | ||
// no more paths | ||
if (!path) return fn(new Error('failed to lookup "' + self.name + '"\'s dependency "' + name + '"')); | ||
// path | ||
var dir = join(path, name); | ||
debug('check %s', dir); | ||
var key = name + ':' + dir; | ||
// check cache | ||
var val = cache[key]; | ||
if (null != val) { | ||
if (!val) return next(); | ||
return fn(null, val); | ||
} | ||
// lookup | ||
debug('lookup %s', name); | ||
fs.exists(dir, function(yes){ | ||
cache[key] = false; | ||
if (!yes) return next(); | ||
debug('found %s', dir); | ||
cache[key] = dir; | ||
fn(null, dir); | ||
@@ -309,4 +328,10 @@ }); | ||
var self = this; | ||
var cache = this._cache; | ||
if (this.conf) return fn(null, this.conf); | ||
var path = this.path('component.json'); | ||
var conf = cache[path]; | ||
if (conf) return fn(null, this.conf = conf); | ||
debug('reading %s', path); | ||
@@ -316,3 +341,3 @@ fs.readFile(path, 'utf8', function(err, str){ | ||
try { | ||
self.conf = JSON.parse(str); | ||
self.conf = cache[path] = JSON.parse(str); | ||
// TODO: lame, remove me | ||
@@ -777,7 +802,7 @@ if (!self._emittedConfig) { | ||
if (builder.sourceUrls) { | ||
return 'require.register("' + file + '", Function("module, exports, require",\n' | ||
return 'require.register("' + file + '", Function("exports, require, module",\n' | ||
+ JSON.stringify(js + '//@ sourceURL=' + file) | ||
+ '\n));'; | ||
} else { | ||
return 'require.register("' + file + '", function(module, exports, require){\n' | ||
return 'require.register("' + file + '", function(exports, require, module){\n' | ||
+ js | ||
@@ -811,12 +836,13 @@ + '\n});'; | ||
function rewrite(url) { | ||
if (isData(url)) return url; | ||
if (isAbsolute(url)) return url; | ||
function rewrite(_, url) { | ||
var orig = 'url(' + url + ')'; | ||
url = utils.stripQuotes(url); | ||
if (isData(url)) return orig; | ||
if (isAbsolute(url)) return orig; | ||
var name = normalize(builder.name); | ||
return join(builder.urlPrefix, '/', name, dirname(file), url); | ||
url = join(builder.urlPrefix, '/', name, dirname(file), url); | ||
return 'url("' + url + '")'; | ||
} | ||
return rework(css) | ||
.use(rework.url(rewrite)) | ||
.toString(); | ||
return css.replace(/\burl *\(([^)]+)\)/g, rewrite); | ||
} | ||
@@ -823,0 +849,0 @@ |
{ | ||
"name": "component-builder", | ||
"version": "0.5.3", | ||
"version": "0.5.5", | ||
"description": "Component build tool", | ||
@@ -11,5 +11,4 @@ "keywords": [ | ||
"dependencies": { | ||
"component-require": "0.1.0", | ||
"component-require": "0.1.1", | ||
"batch": "0.2.1", | ||
"rework": "0.10.2", | ||
"mkdirp": "0.3.4", | ||
@@ -16,0 +15,0 @@ "debug": "*", |
23123
5
8
755
+ Addedcomponent-require@0.1.1(transitive)
- Removedrework@0.10.2
- Removedcolor-parser@0.1.0(transitive)
- Removedcommander@1.0.4(transitive)
- Removedcomponent-require@0.1.0(transitive)
- Removedcss@1.0.7(transitive)
- Removedcss-parse@1.0.4(transitive)
- Removedcss-stringify@1.0.4(transitive)
- Removedkeypress@0.1.0(transitive)
- Removedrework@0.10.2(transitive)
Updatedcomponent-require@0.1.1