Skip to content

Commit 7e7f885

Browse files
committed
use function.prototype
1 parent faf0685 commit 7e7f885

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

babel-preset/transforms/transform-remove-console.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
var template = require('babel-template');
2-
module.exports = function (babel) {
3-
var t = babel.types;
2+
module.exports = function () {
43
return {
54
visitor: {
65
CallExpression(path) {
7-
if (path.get("callee").matchesPattern("console", true)) {
8-
path.node.callee = template(`
9-
(function () {
10-
Array.prototype.slice.call(arguments).forEach(m => (typeof m === 'function') ? m() : m)
11-
})
12-
`)().expression
6+
const callee = path.get("callee")
7+
if (callee.matchesPattern("console", true) && !callee.matchesPattern("console.error")) {
8+
path.node.callee = template(`Function.prototype`)().expression
139
}
1410
}
1511
}

0 commit comments

Comments
 (0)