From 27247e8e56ed3af5fb5873caea4fbd4f0a3b8640 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 13 Sep 2012 19:28:56 -0700 Subject: [PATCH] Remove `freeExports` var when not used via `exports` build option. Former-commit-id: 66950af3a18b35412fbe1092e19c5d7ef0c9a029 --- build.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.js b/build.js index 81bf00bde..b5750143b 100755 --- a/build.js +++ b/build.js @@ -1183,6 +1183,10 @@ // remove `if (freeExports) {...}` if it's empty source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports\) *{\s*}(?:\s*else *{\n([\s\S]+?) *})?/, '$1'); + if ((source.match(/\bfreeExports\b/g) || []).length < 2) { + source = removeVar(source, 'freeExports'); + } + /*------------------------------------------------------------------------*/ // customize Lo-Dash's IIFE