Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle sourcemap sources emtpy edge case #94

Merged
merged 1 commit into from Mar 27, 2020

Conversation

j03m
Copy link
Contributor

@j03m j03m commented Mar 27, 2020

For source maps, the sources property can potentially be an empty array if mappings
doesn't provide any information about its origin. For example if you compile an empty
js file with babel, a valid sourcemap can be created with [] for sources. Here
we add a fallback to file in this case and adds a fixture to test for it.

The new test fixtures empty.js, emtpy.compiled.js and empty.compiled.js.map
simulate this scenario for a unit test.

This is bug 1 from the previous PR. To see the problem in action, comment out the fix line in lib/v8-to-istanbul and you will see the crash that happens when we try to load a sourcemap like this.

For source maps, the sources property can potentially be an empty array if mappings
doesn't provide any information about its origin. For example if you compile an empty
js file with babel, a valid sourcemap can be created with `[]` for `sources`. Here
we add a fallback to `file` in this case and adds a fixture to test for it.

The new test fixtures `empty.js`, `emtpy.compiled.js` and `empty.compiled.js.map`
simulate this scenario for a unit test.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 417

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 95.298%

Totals Coverage Status
Change from base Build 415: 0.01%
Covered Lines: 513
Relevant Lines: 532

💛 - Coveralls

@bcoe bcoe changed the title fix: Handle sourcemap sources emtpy edge case fix: handle sourcemap sources emtpy edge case Mar 27, 2020
@bcoe bcoe merged commit 628af48 into istanbuljs:master Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants