component-builder
Advanced tools
Comparing version 1.1.10 to 1.1.11
@@ -397,3 +397,4 @@ | ||
var debug = require('debug')('component-builder:scripts'); | ||
var relative = require('path').relative; | ||
var path = require('path'); | ||
var relative = path.relative; | ||
var requires = require('requires'); | ||
@@ -469,5 +470,5 @@ var fs = require('graceful-fs'); | ||
+ '} else if (typeof define == "function" && define.amd) {\n' | ||
+' define([], function(){ return require("' + canonical + '"); });\n' | ||
+' define("' + canonical + '", [], function(){ return require("' + canonical + '"); });\n' | ||
+ '} else {\n' | ||
+ ' this["' + alias + '"] = require("' + canonical + '");\n' | ||
+ ' (this || window)["' + alias + '"] = require("' + canonical + '");\n' | ||
+ '}\n' | ||
@@ -621,2 +622,8 @@ + '})()\n'; | ||
// rewrite asset paths | ||
js = assetPaths(js, function (asset) { | ||
asset = relative(file.manifest.path, path.resolve(path.dirname(file.filename), asset)); | ||
return path.join(utils.rewriteUrl(file.branch), asset); | ||
}); | ||
var name = file.name; | ||
@@ -815,3 +822,13 @@ if (this.sourceMap || this.sourceURL) { | ||
// local | ||
if (branch.locals[target]) return branch.locals[target].canonical + tail; | ||
var localDeps = Object.keys(branch.locals); | ||
for (var i = 0; i < localDeps.length; i++) { | ||
// Find a local dependency that matches as a prefix of the target | ||
// or the whole target, and return the canonical path. | ||
var re = new RegExp("^("+localDeps[i]+")(.*)$"); | ||
if (m = re.exec(target)) { | ||
var dep = m[1]; | ||
var tail = m[2]; | ||
return branch.locals[dep].canonical + tail; | ||
} | ||
} | ||
@@ -840,1 +857,10 @@ // <repo> | ||
} | ||
// private helpers | ||
function assetPaths(source, replacer) { | ||
return source.replace(/\/\* component:file \*\/\s+['"](\S+)['"]/g, function (match, p1) { | ||
var replacement = replacer(p1); | ||
return replacement ? JSON.stringify(replacement) : match; | ||
}); | ||
} |
@@ -433,2 +433,3 @@ /** | ||
if (isAbsolute(uri)) return uri; | ||
if (isFragment(uri)) return uri; | ||
uri = resolve(file.path, uri); | ||
@@ -468,1 +469,13 @@ uri = resolve(prefix + utils.rewriteUrl(branch) + '/', uri); | ||
} | ||
/** | ||
* Check if a URL is just a Fragment identifier. | ||
* | ||
* @param {String} url | ||
* @return {Boolean} | ||
* @api public | ||
*/ | ||
function isFragment(url) { | ||
return !url.indexOf('#'); | ||
} |
@@ -0,1 +1,9 @@ | ||
1.1.11 / 2014-09-13 | ||
================== | ||
* [support for nested local dependencies](https://github.com/componentjs/builder2.js/pull/75) | ||
* [allow using fragment identifier in css url.](https://github.com/componentjs/builder2.js/pull/77) | ||
* [Use canonical name as ID for AMD define()](https://github.com/componentjs/builder2.js/pull/78) | ||
* [fix `this` in strict mode](https://github.com/componentjs/builder2.js/pull/79) | ||
1.1.10 / 2014-08-08 | ||
@@ -2,0 +10,0 @@ ================== |
var debug = require('debug')('component-builder:scripts'); | ||
var relative = require('path').relative; | ||
var path = require('path'); | ||
var relative = path.relative; | ||
var requires = require('requires'); | ||
@@ -76,5 +77,5 @@ var fs = require('graceful-fs'); | ||
+ '} else if (typeof define == "function" && define.amd) {\n' | ||
+' define([], function(){ return require("' + canonical + '"); });\n' | ||
+' define("' + canonical + '", [], function(){ return require("' + canonical + '"); });\n' | ||
+ '} else {\n' | ||
+ ' this["' + alias + '"] = require("' + canonical + '");\n' | ||
+ ' (this || window)["' + alias + '"] = require("' + canonical + '");\n' | ||
+ '}\n' | ||
@@ -206,2 +207,8 @@ + '})()\n'; | ||
// rewrite asset paths | ||
js = assetPaths(js, function (asset) { | ||
asset = relative(file.manifest.path, path.resolve(path.dirname(file.filename), asset)); | ||
return path.join(utils.rewriteUrl(file.branch), asset); | ||
}); | ||
var name = file.name; | ||
@@ -400,3 +407,13 @@ if (this.sourceMap || this.sourceURL) { | ||
// local | ||
if (branch.locals[target]) return branch.locals[target].canonical + tail; | ||
var localDeps = Object.keys(branch.locals); | ||
for (var i = 0; i < localDeps.length; i++) { | ||
// Find a local dependency that matches as a prefix of the target | ||
// or the whole target, and return the canonical path. | ||
var re = new RegExp("^("+localDeps[i]+")(.*)$"); | ||
if (m = re.exec(target)) { | ||
var dep = m[1]; | ||
var tail = m[2]; | ||
return branch.locals[dep].canonical + tail; | ||
} | ||
} | ||
@@ -425,1 +442,12 @@ // <repo> | ||
} | ||
// private helpers | ||
function assetPaths(source, replacer) { | ||
return source.replace(/\/\* component:file \*\/\s+['"](\S+)['"]/g, function (match, p1) { | ||
var replacement = replacer(p1); | ||
return replacement ? JSON.stringify(replacement) : match; | ||
}); | ||
} |
@@ -29,2 +29,3 @@ var resolve = require('url').resolve; | ||
if (isAbsolute(uri)) return uri; | ||
if (isFragment(uri)) return uri; | ||
uri = resolve(file.path, uri); | ||
@@ -64,1 +65,13 @@ uri = resolve(prefix + utils.rewriteUrl(branch) + '/', uri); | ||
} | ||
/** | ||
* Check if a URL is just a Fragment identifier. | ||
* | ||
* @param {String} url | ||
* @return {Boolean} | ||
* @api public | ||
*/ | ||
function isFragment(url) { | ||
return !url.indexOf('#'); | ||
} |
{ | ||
"name": "component-builder", | ||
"description": "builder for component", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jonathan Ong", |
@@ -1,2 +0,2 @@ | ||
# component-builder2 [![Build Status](https://travis-ci.org/component/builder2.js.png)](https://travis-ci.org/component/builder2.js) | ||
# component-builder2 [![Build Status](https://travis-ci.org/componentjs/builder2.js.png)](https://travis-ci.org/componentjs/builder2.js) | ||
@@ -3,0 +3,0 @@ Another version of component's builder. Some differences: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
203717
6074
10