-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unwrapping redundant IIFEs #22
Comments
This is definitely possible and shouldn't be too difficult. Basically, if there is only one AST object (e.g function) in the callback function body and no dependencies, then convert the module to the optimized format. I'll try to get this done in the next day or two. |
Brilliant! |
If you can think of any other optimizations, definitely let me know. I think the project is stable enough now that we can now focus on more minor optimizations like this. |
These optimizations have now been incorporated with the Thanks for pointing out these optimizations Rich! |
Excellent! Many thanks. It's been great to watch amdclean get better and better - developing a library as a collection of AMD modules is such a pleasure (testing without building, etc) and it's only practical to do so because of amdclean. Great work. |
You and I like to build libraries in a similar way. Love using AMD for it. And I appreciate all the kind words, but you should give yourself credit too. AMDClean wouldn't be where it is now without you. Hopefully once I find some free time I can contribute to some of your awesome projects, like Ractive.js |
That'd be great :) |
In my library I have many small modules that are used often, like this:
utils/isNumeric.js
After it's been through r.js and amdclean, it looks like this:
In this case, there are no dependencies, and no variable declarations - just a single return statement. So it could be rewritten like this:
I think this is probably quite a common case in libraries that use AMD for internal code organisation. In fact the example on http://gregfranko.com/amdclean/ is another one:
I was wondering if it's possible to identify these cases (i.e. no dependencies, definition body is a single return statement) and discard the outer IIFE when they're encountered?
The text was updated successfully, but these errors were encountered: