Comparing version 3.0.0-rc4 to 3.0.0-rc5
@@ -298,2 +298,3 @@ var fs = require('fs'), | ||
vendor: opts.vendorMap, | ||
basepaths: opts.vendor.basepaths || {}, | ||
exclude: opts.vendor.exclude, | ||
@@ -300,0 +301,0 @@ extras: ['underscore'], |
@@ -221,2 +221,16 @@ var fs = require('fs'), | ||
var vendorByPath = {}; | ||
Object.keys(opts.vendor).forEach(function(id) { | ||
var filename = opts.vendor[id]; | ||
vendorByPath[filename] = id; | ||
}); | ||
// remapped basepaths support (e.g. "core": "../lib/core") | ||
var basepaths = {}; | ||
basepaths[opts.basepath] = ''; | ||
Object.keys(opts.basepaths).forEach(function(prefix) { | ||
var stripBase = path.resolve(opts.basepath, opts.basepaths[prefix]); | ||
basepaths[stripBase] = prefix; | ||
}); | ||
while (!sorter.isEmpty()) { | ||
@@ -231,4 +245,28 @@ var file = sorter.next(), | ||
if (!file.id) { | ||
file.id = (path.dirname(file.filename) + '/' + | ||
path.basename(file.filename, path.extname(file.filename))).substr(opts.basepath.length + 1); | ||
// is it a vendor file? Vendor files should use their name in the vendor hash as their | ||
// file.id - and since amdresolve may have resolved them earlier already (as amdresolve is | ||
// just extracted from r.js, it is not very configurable), detect this. | ||
if (vendorByPath[file.filename]) { | ||
file.id = vendorByPath[file.filename]; | ||
} else { | ||
var hasKnownBasepath = Object.keys(basepaths).some(function(stripBase) { | ||
var isMatch = (file.filename.substr(0, stripBase.length) == stripBase); | ||
if (isMatch) { | ||
var noExtension = (path.dirname(file.filename) + '/' + path.basename(file.filename, path.extname(file.filename))), | ||
relative = path.relative(stripBase, noExtension); | ||
file.id = basepaths[stripBase] + (relative.charAt(0) == '/' ? relative : '/' + relative); | ||
if (file.id.charAt(0) == '/') { | ||
file.id = file.id.substr(1); | ||
} | ||
} | ||
return isMatch; | ||
}); | ||
if (!hasKnownBasepath) { | ||
var str = 'WARN: Unknown basepath - file cannot be included: ' + file.filename; | ||
console.error(str); | ||
throw new Error(str); | ||
} else { | ||
//console.log(file.filename, '=>', file.id); | ||
} | ||
} | ||
} | ||
@@ -235,0 +273,0 @@ console.log(' ' + file.id + ' (' + sorter.verify(file) + ') '); |
{ | ||
"name": "gluejs", | ||
"description": "Build CommonJS modules for the browser via a chainable API", | ||
"version": "3.0.0-rc4", | ||
"version": "3.0.0-rc5", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Mikito Takada", |
132274
2359