Repository navigation
fix: resolve sources inside the sourceRoot directory on filesystem paths - #560
Open
LukaszKokot wants to merge 1 commit into
Open
LukaszKokot wants to merge 1 commit into
LukaszKokot wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 3fc9e2f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
resolveUrl()resolves each segment withpath.resolve(path.dirname(resolved), next).path.resolvestrips the trailing slash thatresolveSources()appends tosourceRoot, so the followingpath.dirnamedrops the root directory again.For a map at
<pkg>/data.mjs.mapwith"sourceRoot": "src"and"sources": ["data.ts"], the source resolves to<pkg>/data.tsinstead of<pkg>/src/data.ts. The read fails and, becausesourcesContentis only kept when every source resolves, the whole map loses itssourcesContent.apache-arrow@21.2.0ships maps like this, so bundles that include it silently lose the embedded sources for all of its modules.URL bases are not affected because
new URL()keeps the trailing slash.Fix
Keep a trailing slash on the resolved base so the next segment resolves inside that directory, mirroring URL resolution.
Checked against maps without
sourceRoot,../and absolute sources, URLsourceRootvalues (http:,webpack:///,file://), empty segments and Windows drive paths: unchanged.sourceRootvaluessrc,src/,./,../srcand absolute roots now resolve inside the root.Test
resolves sources inside the sourceRoot directoryfails onmainwithdist/index.tsinstead ofdist/src/index.tsand passes with the fix.Notes
This was done using Opus 5.5 🤖
We first applied the same patch -using pnpm- in one of our private iTwin repository