Mirror: 🎩 A tiny but capable push & pull stream library for TypeScript and Flow
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add special minification case for source calls

+12
+12
scripts/minify-bucklescript-plugin.js
··· 62 62 const callFn = path.node.arguments[0]; 63 63 const callArgs = path.node.arguments.slice(1); 64 64 65 + // Check whether the value of the call is unused 65 66 if (t.isExpressionStatement(path.parent)) { 66 67 path.replaceWith(t.callExpression(callFn, callArgs)); 67 68 return; 68 69 } 69 70 71 + // Check whether the callee is a local function definition whose arity matches 70 72 if (t.isIdentifier(callFn) && path.scope.hasBinding(callFn.name)) { 71 73 const callFnDefinition = path.scope.getBinding(callFn.name).path.node; 72 74 if ( ··· 76 78 path.replaceWith(t.callExpression(callFn, callArgs)); 77 79 return; 78 80 } 81 + } 82 + 83 + // Special case since sources don't return any value 84 + if ( 85 + t.isIdentifier(callFn) && 86 + callFn.name === 'source' && 87 + t.isReturnStatement(path.parent) 88 + ) { 89 + path.replaceWith(t.callExpression(callFn, callArgs)); 90 + return; 79 91 } 80 92 81 93 const arityLiteral = t.numericLiteral(callArgs.length);