Skip to content

Commit

Permalink
fix: fix source path in sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao Zeng committed Jun 19, 2019
1 parent 8645faa commit 9cba7b9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
9 changes: 7 additions & 2 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/proc-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ const procFile = function (fname, options, code) {
}
// Ignore non-string sources
return typeof source === 'string'
? jscc(source, fname, _getJsccOpts(options))
: source
? jscc(source, fname, _getJsccOpts(options))
: source
}).then(ret =>{
if(ret.map) {
ret.map.sources[0] = fname
}
return ret
})
}

Expand Down
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ describe('Source Map', function () {
expect(map).to.be.an(Object)
// file is null
// expect(map.file).to.be('cc.js')
expect(map.sources[0]).to.be('fixtures/cc.js')
expect(map.sources[0]).to.match(/test\/fixtures\/cc\.js/)
expect(map.sourcesContent[0]).to.be(null)
expect(map.mappings).not.empty()
})
Expand All @@ -283,7 +283,7 @@ describe('Source Map', function () {
expect(map).to.be.an(Object)
// file is null
// expect(map.file).to.be('cc.js')
expect(map.sources[0]).to.be('fixtures/cc.js')
expect(map.sources[0]).to.match(/test\/fixtures\/cc\.js/)
expect(map.sourcesContent[0]).to.be('//#if _EXPROT_DEFAULT\nexport function main () {\n return \'test\'\n}\n/*#else\nexport default function main () {\n return \'test\'\n}\n//#endif */\n')
expect(map.mappings).not.empty()
})
Expand Down Expand Up @@ -332,7 +332,7 @@ describe('Source Map', function () {
({code, map}) => {
expect(map.file).to.be('cc.js')
expect(map.sources[0]).to.be('fixtures/cc.js')
expect(map.sourcesContent[0]).to.be('//#if _EXPROT_DEFAULT\nexport function main () {\n return \'test\'\n}\n/*#else\nexport default function main () {\n return \'test\'\n}\n//#endif */\n')
expect(map.sourcesContent[0]).to.be(null)
expect(map.mappings).not.empty()
}
)
Expand Down

0 comments on commit 9cba7b9

Please sign in to comment.