patch export default within sandbox correctly (#5404)

fixes #5403
This commit is contained in:
Alex Lam S.L
2022-04-03 12:56:19 +01:00
committed by GitHub
parent 224c91b6c1
commit 696a20f10d
2 changed files with 20 additions and 1 deletions

View File

@@ -54,8 +54,8 @@ exports.same_stdout = semver.satisfies(process.version, "0.12") ? function(expec
exports.patch_module_statements = function(code) {
var count = 0, has_default = "", imports = [];
code = code.replace(/\bexport(?:\s*\{[^{}]*}\s*?(?:$|\n|;)|\s+default\b(?:\s*(\(|\{|class\s*\{|class\s+(?=extends\b)|(?:async\s+)?function\s*(?:\*\s*)?\())?|\b)/g, function(match, header) {
if (/^export\s+default/.test(match)) has_default = "var _uglify_export_default_;";
if (!header) return "";
has_default = "var _uglify_export_default_;";
if (header.length == 1) return "0, " + header;
var name = "_uglify_export_default_";
if (/^class\b/.test(header)) do {