{"action":"created","issue":{"url":"https://api.github.com/repos/rails/sprockets/issues/388","repository_url":"https://api.github.com/repos/rails/sprockets","labels_url":"https://api.github.com/repos/rails/sprockets/issues/388/labels{/name}","comments_url":"https://api.github.com/repos/rails/sprockets/issues/388/comments","events_url":"https://api.github.com/repos/rails/sprockets/issues/388/events","html_url":"https://github.com/rails/sprockets/issues/388","id":180160030,"number":388,"title":"Sprockets Semicolon insertion causes sourcemap to be off by (n) number of lines","user":{"login":"danshultz","id":335510,"avatar_url":"https://avatars.githubusercontent.com/u/335510?v=3","gravatar_id":"","url":"https://api.github.com/users/danshultz","html_url":"https://github.com/danshultz","followers_url":"https://api.github.com/users/danshultz/followers","following_url":"https://api.github.com/users/danshultz/following{/other_user}","gists_url":"https://api.github.com/users/danshultz/gists{/gist_id}","starred_url":"https://api.github.com/users/danshultz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danshultz/subscriptions","organizations_url":"https://api.github.com/users/danshultz/orgs","repos_url":"https://api.github.com/users/danshultz/repos","events_url":"https://api.github.com/users/danshultz/events{/privacy}","received_events_url":"https://api.github.com/users/danshultz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-29T20:52:54Z","updated_at":"2016-10-08T13:02:48Z","closed_at":null,"body":"### Expected behavior\r\n\r\nWhen using sprockets with source maps, it's expected the sourcemap lines up with the original source.\r\n\r\n### Actual behavior\r\n\r\nEach source file will be off by (n) number of lines based upon the order it was appended and the (n) number of semicolons inserted.\r\n\r\nThe semicolons are inserted [here](https://github.com/rails/sprockets/blob/55b8c832c2ba021a7f25282f71789bf085b4b990/lib/sprockets/utils.rb#L102) which is after [default source](https://github.com/rails/sprockets/blob/55b8c832c2ba021a7f25282f71789bf085b4b990/lib/sprockets/preprocessors/default_source_map.rb) maps are created it appears.\r\n\r\n### System configuration\r\n\r\n- Sprockets 4.0.0.beta3\r\n- Ruby 2.3.1\r\n- Rails 4.2.6\r\n- Sprockets Rails 3.2.0\r\n\r\n### Example App\r\n\r\nThis can be reproduced in the test suite by introspecting the source map generation that happens during the [appends missing semicolons test run](https://github.com/rails/sprockets/blob/26c090a06e7a747e4eed7f59a0c162e50c820988/test/test_asset.rb#L1054).\r\n\r\nThe input JS is\r\n\r\ntest/fixtures/asset/semicolons/bar.js\r\n```javascript\r\nvar Bar\r\n```\r\n\r\ntest/fixtures/asset/semicolons/index.js\r\n```javascript\r\n//= require ./bar\r\n\r\n(function() {\r\n  var Foo\r\n})\r\n```\r\n\r\nThe output of the JS is\r\n\r\n```javascript\r\nvar Bar\r\n;\r\n\r\n(function() {\r\n  var Foo\r\n})\r\n;\r\n\r\n```\r\n\r\nThe source map representation is\r\n\r\n```ruby\r\n :map=>\r\n  [\r\n    # correct line\r\n    {:source=>\"semicolons/bar.source-d10fa4c82aa701b7cd015bb9588451ad753c08fc48952d5b8a3a1270aee1ad68.js\", :generated=>[1, 0], :original=>[1, 0]}, \r\n    # should be \":generated=>[3, 0]\"\r\n   {:source=>\"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js\", :generated=>[2, 0], :original=>[2, 0]},\r\n    # should be \":generated=>[4, 0]\"\r\n   {:source=>\"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js\", :generated=>[3, 0], :original=>[2, 0]},\r\n    # should be \":generated=>[5, 0]\"\r\n   {:source=>\"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js\", :generated=>[4, 0], :original=>[3, 0]},\r\n    # should be \":generated=>[6, 0]\"\r\n   {:source=>\"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js\", :generated=>[5, 0], :original=>[4, 0]},\r\n     # should be \":generated=>[7, 0]\"\r\n   {:source=>\"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js\", :generated=>[6, 0], :original=>[5, 0]}]\r\n``` "},"comment":{"url":"https://api.github.com/repos/rails/sprockets/issues/comments/252423503","html_url":"https://github.com/rails/sprockets/issues/388#issuecomment-252423503","issue_url":"https://api.github.com/repos/rails/sprockets/issues/388","id":252423503,"user":{"login":"danshultz","id":335510,"avatar_url":"https://avatars.githubusercontent.com/u/335510?v=3","gravatar_id":"","url":"https://api.github.com/users/danshultz","html_url":"https://github.com/danshultz","followers_url":"https://api.github.com/users/danshultz/followers","following_url":"https://api.github.com/users/danshultz/following{/other_user}","gists_url":"https://api.github.com/users/danshultz/gists{/gist_id}","starred_url":"https://api.github.com/users/danshultz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danshultz/subscriptions","organizations_url":"https://api.github.com/users/danshultz/orgs","repos_url":"https://api.github.com/users/danshultz/repos","events_url":"https://api.github.com/users/danshultz/events{/privacy}","received_events_url":"https://api.github.com/users/danshultz/received_events","type":"User","site_admin":false},"created_at":"2016-10-08T13:02:48Z","updated_at":"2016-10-08T13:02:48Z","body":"Thanks for posing that question @SamSaffron - I had wondered about that as well...especially since we are ensuring there is a newline before concatenating now which was not the case previously.\r\n\r\nhttps://github.com/rails/sprockets/blob/44b48d505820e578c01167a0a081f05814402ccc/lib/sprockets/safety_colons.rb\r\n\r\nAnyone have thoughts/opinions if this is still necessary?"}}
{"actor":{"display_login":"danshultz"}}