Skip to content

fix: resolve sources inside the sourceRoot directory on filesystem paths - #1

Open
LukaszKokot wants to merge 1 commit into
mainfrom
fix/source-root-directory
Open

LukaszKokot wants to merge 1 commit into
mainfrom
fix/source-root-directory

Conversation

@LukaszKokot

Copy link
Copy Markdown
Owner

resolveUrl() resolves filesystem segments with path.resolve(path.dirname(resolved), next), which strips the trailing slash resolveSources() adds to sourceRoot. A map with "sourceRoot": "src" and "sources": ["index.ts"] therefore resolves to index.ts beside the map instead of src/index.ts; the read fails and the whole map loses its sourcesContent. apache-arrow ships such maps. URL bases are unaffected because new URL() keeps the slash.

The fix keeps a trailing slash on the resolved base so the next segment resolves inside that directory. Maps without sourceRoot, ../ or absolute sources, URL roots and Windows drive paths resolve as before.

The new test fails on main with dist/index.ts and passes with the fix. Submitted upstream as 2wce#560.

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.

1 participant