aboutsummaryrefslogtreecommitdiff
path: root/lib/minify.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-17 00:20:48 +0100
committerGitHub <noreply@github.com>2020-04-17 07:20:48 +0800
commit83f42ede367316193205572a04959098b45e711d (patch)
tree24c79e434bfd00aa47c85ed9f84b5dbd6a8056a9 /lib/minify.js
parent0ce71bbec0c9f0d49ec86f8b959f12a7bf9df21d (diff)
downloadtracifyjs-83f42ede367316193205572a04959098b45e711d.tar.gz
tracifyjs-83f42ede367316193205572a04959098b45e711d.zip
support optional output of `names` in source maps (#3784)
Diffstat (limited to 'lib/minify.js')
-rw-r--r--lib/minify.js26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/minify.js b/lib/minify.js
index ab397f5e..2182d653 100644
--- a/lib/minify.js
+++ b/lib/minify.js
@@ -129,6 +129,7 @@ function minify(files, options) {
content: null,
filename: null,
includeSources: false,
+ names: true,
root: null,
url: null,
}, true);
@@ -138,7 +139,7 @@ function minify(files, options) {
warnings.push(warning);
}, options.warnings == "verbose");
if (timings) timings.parse = Date.now();
- var source_maps, toplevel;
+ var toplevel;
if (files instanceof AST_Toplevel) {
toplevel = files;
} else {
@@ -151,19 +152,17 @@ function minify(files, options) {
if (typeof source_map_content == "string" && source_map_content != "inline") {
source_map_content = parse_source_map(source_map_content);
}
- source_maps = source_map_content && Object.create(null);
+ if (source_map_content) options.sourceMap.orig = Object.create(null);
for (var name in files) if (HOP(files, name)) {
options.parse.filename = name;
options.parse.toplevel = toplevel = parse(files[name], options.parse);
- if (source_maps) {
- if (source_map_content == "inline") {
- var inlined_content = read_source_map(name, toplevel);
- if (inlined_content) {
- source_maps[name] = parse_source_map(inlined_content);
- }
- } else {
- source_maps[name] = source_map_content;
+ if (source_map_content == "inline") {
+ var inlined_content = read_source_map(name, toplevel);
+ if (inlined_content) {
+ options.sourceMap.orig[name] = parse_source_map(inlined_content);
}
+ } else if (source_map_content) {
+ options.sourceMap.orig[name] = source_map_content;
}
}
}
@@ -202,12 +201,7 @@ function minify(files, options) {
}
if (!HOP(options.output, "code") || options.output.code) {
if (options.sourceMap) {
- options.output.source_map = SourceMap({
- content: options.sourceMap.includeSources,
- file: options.sourceMap.filename,
- orig: source_maps,
- root: options.sourceMap.root
- });
+ options.output.source_map = SourceMap(options.sourceMap);
if (options.sourceMap.includeSources) {
if (files instanceof AST_Toplevel) {
throw new Error("original source content unavailable");