Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

component-builder

Package Overview
Dependencies
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

component-builder - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

7

History.md
0.11.0 / 2013-12-29
==================
* remove require aliases. Closes #117
* make better-assert a development dependency
* normalize URLs in CSS files
0.10.0 / 2013-10-17

@@ -3,0 +10,0 @@ ==================

162

lib/builder.js

@@ -21,2 +21,4 @@ /**

, basename = path.basename
, resolveURL = require('url').resolve
, requires = require('requires')
, strtojs = require('string-to-js');

@@ -463,3 +465,2 @@

batch.push(this.buildTemplates.bind(this));
batch.push(this.buildAliases.bind(this));
batch.push(this.buildStyles.bind(this));

@@ -475,5 +476,4 @@ batch.push(this.buildImages.bind(this));

var templates = res.shift();
var require = res.shift();
var custom = self._js;
var js = [scripts, json, templates, require, custom].filter(empty).join('\n');
var js = [scripts, json, templates, custom].filter(empty).join('\n');

@@ -492,128 +492,2 @@ fn(null, {

/**
* Build require() aliases.
*
* This is necessary to allow
* several components of the same
* name to be used. For example "learnboost/popover"
* and "visionmedia/popover" may co-exist within
* an application using this technique, as they
* are linked as shown here:
*
* ./user
* ./deps
* ./inherit -> component-inherit
*
* ./animal
* ./deps
* ./inherit -> component-inherit
*
* ./component-inherit
*
* ./pet-list
* ./deps
* ./pet -> pet
*
* ./user-list
* ./deps
* ./user -> user
*
* ./boot
* ./deps
* ./pet-list -> pets-list
* ./user-list -> pets-list
*
* Root-level dependencies are exposed at the global
* level so that users may utilize components with
* script tags within other frameworks etc.
*
* TODO: buildScripts() should do this, so that
* lazily-built components do not omit aliases.
*
* TODO: refactor, this is nasty
*
* @param {Function} fn
* @api private
*/
Builder.prototype.buildAliases = function(fn){
var self = this;
var aliases = [];
var batch = new Batch;
if (self.hasDependencies()) {
Object.keys(self.dependencies()).forEach(function(dep){
batch.push(function(done){
dep = normalize(dep);
self.lookup(dep, function(err, dir){
if (err) return done(err);
var builder = new Builder(dir, self);
var conf = builder.config;
self.emit('dependency', builder);
if (!conf.scripts) return done(null, '');
var main = conf.main;
var name = conf.name;
var aliases = conf.scripts.map(function(script){
var alias = self.root
? self.config.name + '/deps/' + name + '/' + script
: self.basename + '/deps/' + name + '/' + script;
return builder.alias(alias, script);
});
if (main) {
var alias = self.root
? self.config.name + '/deps/' + name + '/index.js'
: self.basename + '/deps/' + name + '/index.js';
aliases.push(builder.alias(alias, main));
}
if (self.root) {
aliases.push(builder.alias(name + '/index.js', main || 'index.js'));
}
aliases = aliases.join('\n');
builder.buildAliases(function(err, str){
if (err) return done(err);
done(null, aliases + '\n' + str);
});
});
});
});
}
batch.end(function(err, res){
if (err) return fn(err);
var name = self.root
? self.config.name
: self.basename;
if (self.config.main) {
res.push(self.alias(name + '/index.js', self.config.main));
}
fn(null, res.join('\n'));
});
};
/**
* Return an alias from script `a` to `b`.
*
* @param {String} a
* @param {String} b
* @return {String}
* @api private
*/
Builder.prototype.alias = function(a, b){
var name = this.root
? this.config.name
: this.basename;
return 'require.alias("' + name + '/' + b + '", "' + a + '");';
};
/**
* Build `type` and invoke `fn`.

@@ -954,2 +828,9 @@ *

js = requires(js, function(require){
var deps = builder.config.dependencies || {};
var path = require.path;
var name = canonicalized(path, deps) || path;
return 'require("' + name + '")';
});
if (builder.sourceUrls) {

@@ -969,2 +850,20 @@ js = JSON.stringify(js + '//@ sourceURL=' + file);

/**
* Return canonical name of `dep` in `deps`
* or undefined.
*
* @param {String} dep
* @param {Object} deps
* @return {String}
* @api private
*/
function canonicalized(dep, deps) {
for (var name in deps) {
if (dep == name.split('/')[1]) {
return normalize(name);
}
}
}
/**
* Return css with urls rewritten relative

@@ -998,3 +897,6 @@ * to the `.assetDest` directory. This allows

var name = normalize(builder.basename);
url = [builder.urlPrefix, name, dirname(file), url].filter(empty).join('/');
// trailing `/` needed to distinguish the URL as a folder
// for `url.resolve()`
var folder = [builder.urlPrefix, name, dirname(file)].filter(empty).join('/') + '/';
url = resolveURL(folder, url);
return 'url("' + url + '")';

@@ -1001,0 +903,0 @@ }

{
"name": "component-builder",
"version": "0.10.0",
"version": "0.11.0",
"description": "Component build tool",

@@ -11,15 +11,16 @@ "keywords": [

"dependencies": {
"component-require": "0.3.1",
"component-require": "1.0.0",
"batch": "0.2.1",
"mkdirp": "0.3.4",
"debug": "*",
"better-assert": "~0.1.0",
"cp": "~0.1.0",
"string-to-js": "0.0.1"
"string-to-js": "0.0.1",
"requires": "~1.0.0"
},
"devDependencies": {
"mocha": "*",
"should": "*",
"should": "1.x",
"ejs": "~0.8.3",
"styl": "0.2.2"
"styl": "0.2.2",
"better-assert": "~0.1.0"
},

@@ -26,0 +27,0 @@ "repository": {

@@ -76,2 +76,6 @@ # builder.js

### Builder#use(fn)
Give the builder a plugin to use. The `fn` args are `fn(builder [, done])`. If The plugin has async logic it should invoke the `done` callback as needed. Sync plugins should ignore this argument.
## Examples

@@ -78,0 +82,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc