@bazel/terser
Advanced tools
Comparing version 4.6.1 to 5.0.0-rc.0
45
index.js
@@ -29,2 +29,41 @@ #!/usr/bin/env node | ||
// Returns a single quotes version of str | ||
function singleQuotes(str) { | ||
return `'${str.replace(/'/g, '').replace(/"/g, '')}'`; | ||
} | ||
// Ensures that args are well formed. | ||
// Work-around for an issue on Windows when exec bin path is not quoted. | ||
// In --source-map, base=bazel-out/x64_windows-opt-exec-2B5CBBC6/bin must | ||
// be quoted such as base='bazel-out/x64_windows-opt-exec-2B5CBBC6/bin' pr | ||
// terser fails with | ||
// ERROR: `includeSources,base=bazel-out/x64_windows-opt-exec-2B5CBBC6/bin,content=inline,url=bundle.min.js.map` is not a supported option | ||
function fixArgs(args) { | ||
const sourceMapIndex = args.indexOf('--source-map'); | ||
if (sourceMapIndex === -1) { | ||
return args; | ||
} | ||
let sourceMapOptions = args[sourceMapIndex + 1].split(','); | ||
sourceMapOptions = sourceMapOptions.map(o => { | ||
const s = o.split('='); | ||
if (s.length == 1) { | ||
return o; | ||
} | ||
switch (s[0]) { | ||
case 'base': | ||
case 'content': | ||
case 'url': | ||
return `${s[0]}=${singleQuotes(s[1])}`; | ||
default: | ||
return o; | ||
} | ||
}); | ||
return [ | ||
...args.slice(0, sourceMapIndex + 1), | ||
sourceMapOptions.join(','), | ||
...args.slice(sourceMapIndex + 2), | ||
]; | ||
} | ||
/** | ||
@@ -39,4 +78,6 @@ * Replaces directory url with the outputFile name in the url option of source-map argument | ||
let sourceMapOptions = residualArgs[sourceMapIndex + 1].split(','); | ||
// set the correct sourcemap url for this output file | ||
let sourceMapOptions = residualArgs[sourceMapIndex + 1].split(',').map( | ||
sourceMapOptions = sourceMapOptions.map( | ||
o => o.startsWith('url=') ? `url='${path.basename(outputFile)}.map'` : o); | ||
@@ -148,2 +189,4 @@ | ||
function main() { | ||
process.argv = fixArgs(process.argv) | ||
// Peek at the arguments to find any directories declared as inputs | ||
@@ -150,0 +193,0 @@ let argv = process.argv.slice(2); |
@@ -8,3 +8,3 @@ { | ||
"license": "Apache-2.0", | ||
"version": "4.6.1", | ||
"version": "5.0.0-rc.0", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type" : "git", |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
35392
247
2