Context-insensitive parsing of sourceMappingURL
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
* **Version**: v18.13.0
* **Platform**: Darwin softs-MBP 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 x86_64
* **c8**: 7.13.0
First of all, thanks for your work!
The current regexp-based parsing of sourcemap urls does not consider the context where `sourceMappingURL=` appears:
https://github.com/bcoe/c8/blob/854f9f6c2ea36e583ea02fa3f8a850804e671df3/lib/source-map-from-file.js#L41
This causes files where `sourceMappingURL=` appears in string literal to not be covered. It would also happens if `sourceMappingURL=` appears in non-tail comments.
```js
// append-sourcemap-url.mjs
const appendSourcemapUrl = (content, sourcemap) =>
`${content}\n//# sourceMappingURL=data:text/json,${encodeURIComponent(sourcemap)}`;
appendSourcemapUrl("123;", '{"version":3}');
```
```text
npx c8 -- node append-sourcemap-url.mjs
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
```
Contributor guide
Assessment
This issue has not been assessed yet.