-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.
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
sourceslike:
!["sources":["e:/PR/node-c8-repro/src/demo.ts"]](https://private-user-images.githubusercontent.com/22674396/279920535-476d2bdc-0617-47d1-bcfd-42eec8edaead.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjI4ODAzNTYsIm5iZiI6MTc2Mjg4MDA1NiwicGF0aCI6Ii8yMjY3NDM5Ni8yNzk5MjA1MzUtNDc2ZDJiZGMtMDYxNy00N2QxLWJjZmQtNDJlZWM4ZWRhZWFkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTExMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUxMTExVDE2NTQxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyNjFlZGRjNDk4ZTI5ZWQ0MTFkY2IxOGU2ZjVkOTYzNWYzYWU0NTgzYjUxNWE0MTIyMzU0MDNmOTUzMmNmODImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.HJrATQ4lmiYiuRaHpZgl00Z-aRVnPqKETppRhBQF7A8)
- Verify that these malformed paths do affect some tools like using c8 with
--exclude-after-remapoption 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-remapnow 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).hrefprior to thereturninnode/lib/internal/source_map/source_map_cache.js
Lines 254 to 258 in a1693c6
function sourcesToAbsolute(baseURL, data) { data.sources = data.sources.map((source) => { source = (data.sourceRoot || '') + source; return new URL(source, baseURL).href; });
Metadata
Metadata
Assignees
Labels
source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.