Closed
Description
Version
v20.9.0
Platform
Microsoft Windows NT 10.0.22635.0 x64
Subsystem
module
What steps will reproduce the bug?
- Clone and install
git clone https://github.com/PaperStrike/node-c8-repro.git cd node-c8-repro npm ci
- Generate coverage json file on Windows
This will generate some malformed
npm run gen-coverage
sources
like:
- Verify that these malformed paths do affect some tools like using c8 with
--exclude-after-remap
option enabled.# this is c8 without --exclude-after-remap npm run report-coverage # this is c8 with --exclude-after-remap npm run report-coverage-failing
- Manually modify the malformed path to file URL.
- Verify that c8
--exclude-after-remap
now works fine.
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
The generated source map sources
field should contain absolute file URLs as the document stated.
What do you see instead?
The generated source map cache contains a malformed path and breaks third-party tools.
Additional information
- This has been issued in Malformed source URLs in source map cache on Windows TypeStrong/ts-node#1769, ts-node has tried to use absolute file URLs but the change sadly breaks many others (10.8.1 regression - URL polluting relative file path TypeStrong/ts-node#1790) and was reverted.
- I guess it could be fixed by inserting a line
if (path.isAbsolute(source)) return url.pathToFileURL(source).href
prior to thereturn
innode/lib/internal/source_map/source_map_cache.js
Lines 254 to 258 in a1693c6
Activity