Skip to content

Instantly share code, notes, and snippets.

@Pewpewarrows
Created April 16, 2012 16:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pewpewarrows/2399955 to your computer and use it in GitHub Desktop.
Save Pewpewarrows/2399955 to your computer and use it in GitHub Desktop.
ASI Bug introduced during Concatenation
// This library file decides to use ASI everywhere
var fn = function () {
//...
} // semicolon missing at this line
// My site's code, starting with an IIFE
(function () {
//...
})();
@Pewpewarrows
Copy link
Author

When these two files become concatenated and minified, lib.js introduces a bug in my perfectly-valid my_app.js file because it decided to use ASI.

@madrobby
Copy link

You need to guard against this regardless—this is a common thing even for libraries that use semicolons everywhere.

The best way to do this, is follow the rules I've laid down in my blog post, specifically If your line starts with ( or [ write a single semicolon before that.

@Pewpewarrows
Copy link
Author

I get that, but what you're essentially saying is that everyone else in the community has to add safety guards to their code because you want to use an error correction component of the language to avoid writing some semicolons. You have to admit that it seems completely ass-backwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment