make enclose & wrap work with sourceMap (#3396)

fixes #3313
This commit is contained in:
Alex Lam S.L
2019-05-04 20:25:52 +08:00
committed by GitHub
parent 11cdab745d
commit 354fec8a9c
6 changed files with 43 additions and 34 deletions

View File

@@ -151,12 +151,13 @@ function minify(files, options) {
if (quoted_props) {
reserve_quoted_keys(toplevel, quoted_props);
}
if (options.wrap) {
toplevel = toplevel.wrap_commonjs(options.wrap);
}
if (options.enclose) {
toplevel = toplevel.wrap_enclose(options.enclose);
}
[ "enclose", "wrap" ].forEach(function(action) {
var option = options[action];
if (!option) return;
var orig = toplevel.print_to_string().slice(0, -1);
toplevel = toplevel[action](option);
files[toplevel.start.file] = toplevel.print_to_string().replace(orig, "");
});
if (timings) timings.rename = Date.now();
if (options.rename) {
toplevel.figure_out_scope(options.mangle);