Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Encapsulate build files in IIFE #5196

Closed
bogdanalexe90 opened this issue Jan 10, 2016 · 6 comments
Closed

Encapsulate build files in IIFE #5196

bogdanalexe90 opened this issue Jan 10, 2016 · 6 comments

Comments

@bogdanalexe90
Copy link
Contributor

When using ui-bootstrap-tpls.js with gulp-useref into a build process resulting code is not working. This is due to a missing ; at the end of the file. Adding the ; or encapsulating into an IIFE solves the issue.

I suggest better to encapsulate all the lib into an IIFE.

@bogdanalexe90
Copy link
Contributor Author

The actual error is:
Uncaught TypeError: angular.module(...).run(...) is not a function

Because in my file the next thing is an IIFE, so concatenated code looks like:

angulat.module.run(...)(function(){...}());

So the js engine tries to evaluate it as a function.

@wesleycho
Copy link
Contributor

Not sure why it is like that - this should be fixed on next release after #5197 gets in.

There is no benefit of wrapping everything in an IIFE here - all of the innards are encapsulated in angular modules, and there is no global being set by UI Bootstrap.

@wesleycho
Copy link
Contributor

@philBrown please read the Code of Conduct - if you do not change the tone/attitude in your comments (as this is not the first issue where this is exhibited), you will be blocked from commenting, and the Angular team will be notified of this violation.

@philBrown
Copy link
Contributor

@wesleycho my apologies, it's been a long day (previous comment removed).

I am able to work around this by using the pre-minified version of ui-bootstrap-tpls.min.js instead of the main file for now.

Do you have a rough timeframe on a 1.0.1 release?

@wesleycho
Copy link
Contributor

@philBrown not a problem, we all have them - hope you get some rest!

We're likely to release a 1.0.1 on Monday evening PST or Tuesday morning PST if I have agreement from the others.

@anjmao
Copy link

anjmao commented Feb 12, 2016

I general it is best practice to wrap library to IIFE and also use strict mode

(function() {
    'use strict';
    //your library code here
})();

I don't get it why angular bootstrap don't do it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants