Comparing version 3.0.0-rc3 to 3.0.0-rc4
#!/usr/bin/env node | ||
var fs = require('fs'), | ||
path = require('path'), | ||
Minilog = require('minilog'), | ||
@@ -11,7 +12,17 @@ Packer = require('../lib/amd/api.js'); | ||
'cache': { default: true }, | ||
'cache-method': { }, | ||
'cache-path': { }, | ||
'command': { }, | ||
'config': { }, | ||
'include': { }, | ||
'list-files': { }, | ||
'log': { default: 'warn' }, | ||
'main': { }, | ||
'log': { default: 'warn' } | ||
'out': { }, | ||
'vendor': { }, | ||
'vendor-base': { } | ||
}) | ||
.boolean('amd'), | ||
.boolean('amd') | ||
.boolean('cache') | ||
.boolean('ls-config'), | ||
argv = yargs.parse(process.argv); | ||
@@ -31,2 +42,19 @@ | ||
if (argv['cache-path']) { | ||
argv['cache-path'] = path.resolve(process.cwd(), argv['cache-path']); | ||
} | ||
if (argv['ls-config']) { | ||
var sorted = {}; | ||
Object.keys(argv).sort().forEach(function(key) { | ||
sorted[key] = argv[key]; | ||
}); | ||
if (argv['ls-config']) { | ||
console.error('\nOptions:'); | ||
Object.keys(sorted).forEach(function(key) { | ||
console.error(' --' + key + ' ' + require('util').inspect(sorted[key], null, 20, process.stderr.isTTY)); | ||
}); | ||
} | ||
} | ||
var p = new Packer(); | ||
@@ -33,0 +61,0 @@ |
@@ -45,2 +45,13 @@ var fs = require('fs'), | ||
// handle duplicate files | ||
var byContent = {}, | ||
canonicalName = {}; | ||
files.forEach(function(file) { | ||
if (!byContent[file.content]) { | ||
byContent[file.content] = [file]; | ||
} else { | ||
byContent[file.content].push(file); | ||
} | ||
}); | ||
var ignoredIds = [], | ||
@@ -87,5 +98,28 @@ notFound = {}; | ||
var source = (path.extname(file.filename) == '.json' ? 'module.exports = ' : '') + | ||
fs.readFileSync(file.content).toString(); | ||
var source, | ||
isDuplicate = byContent[file.content].length > 1, | ||
isMainFile = false; | ||
if (isDuplicate) { | ||
// prefer the shortest name | ||
if (!canonicalName[file.content]) { | ||
canonicalName[file.content] = byContent[file.content].map(function(file) { | ||
// not file.content | ||
return file.filename; | ||
}).sort(function(a, b) { return a.length - b.length; })[0]; | ||
} | ||
isMainFile = (canonicalName[file.content] != file.filename); | ||
} | ||
// for duplicates which are not the main file | ||
if (isDuplicate && isMainFile) { | ||
source = 'module.exports=require(\'' + idLookup[canonicalName[file.content]] + '\');'; | ||
if (!idLookup[canonicalName[file.content]]) { | ||
throw new Error('Could not resolve file: ' + file.filename + | ||
'. Please empty the gluejs cache folder and retry.'); | ||
} | ||
// console.log('dup replaced with redirect', file.filename, '=>', | ||
// canonicalName[file.content], 'id:', idLookup[canonicalName[file.content]]); | ||
} else { | ||
source = (path.extname(file.filename) == '.json' ? 'module.exports = ' : '') + | ||
fs.readFileSync(file.content).toString(); | ||
} | ||
var dep = { | ||
@@ -96,3 +130,3 @@ id: idLookup[file.filename], | ||
}; | ||
if (sourceMapEnabled) { | ||
if (sourceMapEnabled && !isDuplicate || (isDuplicate && isMainFile)) { | ||
dep.sourceFile = file.filename; | ||
@@ -99,0 +133,0 @@ } |
{ | ||
"name": "gluejs", | ||
"description": "Build CommonJS modules for the browser via a chainable API", | ||
"version": "3.0.0-rc3", | ||
"version": "3.0.0-rc4", | ||
"author": { | ||
@@ -42,3 +42,3 @@ "name": "Mikito Takada", | ||
"resolve": "~0.7.1", | ||
"transform-runner": "~0.1.3", | ||
"transform-runner": "~0.1.5", | ||
"umd": "~2.1.0", | ||
@@ -45,0 +45,0 @@ "yargs": "~1.2.6" |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
130621
2322
1
Updatedtransform-runner@~0.1.5