Expected behavior
When using sprockets with source maps, it's expected the sourcemap lines up with the original source.
Actual behavior
Each source file will be off by (n) number of lines based upon the order it was appended and the (n) number of semicolons inserted.
The semicolons are inserted here which is after default source maps are created it appears.
System configuration
- Sprockets 4.0.0.beta3
- Ruby 2.3.1
- Rails 4.2.6
- Sprockets Rails 3.2.0
Example App
This can be reproduced in the test suite by introspecting the source map generation that happens during the appends missing semicolons test run.
The input JS is
test/fixtures/asset/semicolons/bar.js
test/fixtures/asset/semicolons/index.js
//= require ./bar
(function() {
var Foo
})
The output of the JS is
var Bar
;
(function() {
var Foo
})
;
The source map representation is
:map=>
[
# correct line
{:source=>"semicolons/bar.source-d10fa4c82aa701b7cd015bb9588451ad753c08fc48952d5b8a3a1270aee1ad68.js", :generated=>[1, 0], :original=>[1, 0]},
# should be ":generated=>[3, 0]"
{:source=>"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js", :generated=>[2, 0], :original=>[2, 0]},
# should be ":generated=>[4, 0]"
{:source=>"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js", :generated=>[3, 0], :original=>[2, 0]},
# should be ":generated=>[5, 0]"
{:source=>"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js", :generated=>[4, 0], :original=>[3, 0]},
# should be ":generated=>[6, 0]"
{:source=>"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js", :generated=>[5, 0], :original=>[4, 0]},
# should be ":generated=>[7, 0]"
{:source=>"semicolons/index.source-47a14a5ea5ac770cc99d947179aa913a0869508bc555bac2a621e5aba564485e.js", :generated=>[6, 0], :original=>[5, 0]}]
Expected behavior
When using sprockets with source maps, it's expected the sourcemap lines up with the original source.
Actual behavior
Each source file will be off by (n) number of lines based upon the order it was appended and the (n) number of semicolons inserted.
The semicolons are inserted here which is after default source maps are created it appears.
System configuration
Example App
This can be reproduced in the test suite by introspecting the source map generation that happens during the appends missing semicolons test run.
The input JS is
test/fixtures/asset/semicolons/bar.js
test/fixtures/asset/semicolons/index.js
The output of the JS is
The source map representation is