{"action":"created","issue":{"url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/470","labels_url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/470/labels{/name}","comments_url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/470/comments","events_url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/470/events","html_url":"https://github.com/cyberdelia/django-pipeline/pull/470","id":90690340,"number":470,"title":"Safely concatenate JavaScript","user":{"login":"lydell","id":2142817,"avatar_url":"https://avatars.githubusercontent.com/u/2142817?v=3","gravatar_id":"","url":"https://api.github.com/users/lydell","html_url":"https://github.com/lydell","followers_url":"https://api.github.com/users/lydell/followers","following_url":"https://api.github.com/users/lydell/following{/other_user}","gists_url":"https://api.github.com/users/lydell/gists{/gist_id}","starred_url":"https://api.github.com/users/lydell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lydell/subscriptions","organizations_url":"https://api.github.com/users/lydell/orgs","repos_url":"https://api.github.com/users/lydell/repos","events_url":"https://api.github.com/users/lydell/events{/privacy}","received_events_url":"https://api.github.com/users/lydell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-24T14:21:24Z","updated_at":"2015-08-01T17:32:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cyberdelia/django-pipeline/pulls/470","html_url":"https://github.com/cyberdelia/django-pipeline/pull/470","diff_url":"https://github.com/cyberdelia/django-pipeline/pull/470.diff","patch_url":"https://github.com/cyberdelia/django-pipeline/pull/470.patch"},"body":"Most JavaScript packages wrap their code in IIFEs, which is good.\r\n\r\nPipeline used to concatenate JS only with a newline. That can break those IIFES\r\nthough:\r\n\r\n    (function() {\r\n      // package A\r\n    }()) // No semicolon! Most people put one here, but unfortunately not all!\r\n    (function() {\r\n      // package B\r\n    }());\r\n\r\nThe above is equivalent to:\r\n\r\n    (function() {\r\n      // package A\r\n    }())(function() {\r\n      // package B\r\n    }());\r\n\r\nSuddenly we have a function call!\r\n\r\nWith this commit, JS is concatenated with a newline followed by a semicolon,\r\nwhich fixes the above issue:\r\n\r\n    (function() {\r\n      // package A\r\n    }()) // No semicolon! Most people put one here, but unfortunately not all!\r\n    ;(function() {\r\n      // package B\r\n    }());\r\n\r\nThere is no need to worry about superfluos semicolons, such as:\r\n\r\n    (function() {\r\n      // package A\r\n    }());\r\n    ;;(function() {\r\n      // package B\r\n    }());\r\n\r\nThat is still valid JavaScript and the extra semicolons will be removed by the\r\nminifier.\r\n\r\n---\r\n\r\nAn example of a package that has an IIFEE without semicolon is: [mapbox.js](https://github.com/mapbox/mapbox.js/). I think any package built with browserify could be affected."},"comment":{"url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/comments/126938978","html_url":"https://github.com/cyberdelia/django-pipeline/pull/470#issuecomment-126938978","issue_url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/470","id":126938978,"user":{"login":"cyberdelia","id":44535,"avatar_url":"https://avatars.githubusercontent.com/u/44535?v=3","gravatar_id":"","url":"https://api.github.com/users/cyberdelia","html_url":"https://github.com/cyberdelia","followers_url":"https://api.github.com/users/cyberdelia/followers","following_url":"https://api.github.com/users/cyberdelia/following{/other_user}","gists_url":"https://api.github.com/users/cyberdelia/gists{/gist_id}","starred_url":"https://api.github.com/users/cyberdelia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyberdelia/subscriptions","organizations_url":"https://api.github.com/users/cyberdelia/orgs","repos_url":"https://api.github.com/users/cyberdelia/repos","events_url":"https://api.github.com/users/cyberdelia/events{/privacy}","received_events_url":"https://api.github.com/users/cyberdelia/received_events","type":"User","site_admin":false},"created_at":"2015-08-01T17:32:15Z","updated_at":"2015-08-01T17:32:15Z","body":"Thanks a lot!"}}