Complete Rewrite, CommonJS Support, New Option, Multiple Enhancements, Bug Fixes
Complete Rewrite
- AMDclean has been completely rewritten using... AMDclean. Yes, that's right; AMDclean is it's own user. Check out the source for yourself.
CommonJS Support
- AMDclean now provides full-fledged CommonJS support by working in conjunction with the Require.js cjsTranslate option. #45
- The only caveat is that the Require.js filesystem lookup is still used (sorry
npm
andnode_modules
fanboys)
New Option
- The
createAnonymousAMDModule
has been added, to easily allow library authors to expose an anonymous AMD module instead of always a named AMD module. If you would like to use it, you need to make sure to set thecreateAnonymousAMDModule
option totrue
(it isfalse
by default).
Multiple Enhancements
- Make sure to not strip out callback function parameters unless the
advancedOptimizations
option is set totrue
(helps with debugging) #44 - Make sure to still optimize a module even if there is one dependency. The important thing to check for is what is inside the callback function. #43
- Make sure to not clean optional
define()
wrappers, that are inside of conditional AMD checks, when thetransformAMDChecks
option is set totrue
. Very important for library development. #46 - Change the default
wrap
AMDclean option to be:
'wrap': {
'start': ';(function() {',
'end': '}());'
}
Reason: Lot's of people are using the Require.js wrap
option and becoming confused why all modules are being declared in the global scope. #47
- Wrap a conditional ternary operator around the module return value of scripts. #48 D3 example:
if (true) {
d3 = function () {
return typeof d3 === 'function' ? d3() : d3;
}();
}
Bug Fixes
- Comments outside of your modules are no longer being removed. This has been an annoying issue.
- Optimized modules, that return a function, do not have their function arguments hoisted by accident