improve export compatibility mode (#4703)
This commit is contained in:
parent
e6ebf827ce
commit
13ad10a6b5
|
|
@ -51,7 +51,7 @@ exports.same_stdout = semver.satisfies(process.version, "0.12") ? function(expec
|
||||||
};
|
};
|
||||||
exports.strip_exports = function(code) {
|
exports.strip_exports = function(code) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
return code.replace(/\bexport(?:\s*\{[^}]*};|\s+default\b(?:\s*(\(|\{|class\s*\{|class\s+(?=extends\b)|(?:async\s+)?function\s*(?:\*\s*)?\())?|\b)/g, function(match, header) {
|
return 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 (!header) return "";
|
if (!header) return "";
|
||||||
if (header.length == 1) return "!!" + header;
|
if (header.length == 1) return "!!" + header;
|
||||||
return header.slice(0, -1) + " _" + ++count + header.slice(-1);
|
return header.slice(0, -1) + " _" + ++count + header.slice(-1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user