fix(assets-loader): join public paths with path.posix so remote assets work on Windows - #1457
Open
KallinikosMil wants to merge 2 commits into
Open
Conversation
…s work on Windows `convertToRemoteAssets` built the remote asset URL with `path.join(remotePublicPath, assetPath)`. On Windows that rewrites the separators to backslashes and, because `https:` is not a drive letter, prefixes the result with `.\` — so `new URL` throws `Invalid URL` and any bundle that contains a remote asset fails to build. `extractAssets` did the same to `publicPath`, which is served over HTTP and always uses forward slashes. Both values are URLs, not filesystem paths, so they are now joined with `path.posix.join`. On Linux and macOS `path.join` and `path.posix.join` are the same function, so the output there is unchanged. Before, on Windows: tester-app 4 failed / 10 passed, every failure `TypeError: Invalid URL` from the assets loader. After: 14 / 14. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018U3wcP5Qm39cas5MtVVabw
|
@KallinikosMil is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 3a2e375 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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.
Summary
On Windows, any bundle that contains a remote asset fails to build:
The cause is in
convertToRemoteAssets:path.joinis a filesystem-path function. On Windows it rewrites the separators to backslashes and, becausehttps:is not a drive letter, prefixes the result with.\:extractAssetshas the same shape one level up —publicPath = path.join(customPublicPath, publicPath)— on a value that is served over HTTP and is always forward-slashed. It is a bit ironic: the line immediately above each of these already normalises the path withpathSeparatorRegexpso it uses forward slashes, and thepath.jointhen undoes that on Windows.Fix
Both values are URLs, not filesystem paths, so they are now joined with
path.posix.join. On Linux and macOSpath.joinispath.posix.join, so output there is byte-for-byte unchanged — this is a no-op everywhere the loader currently works. Two lines, plus comments saying why so it does not get "fixed" back.Found the same way as #1450: running
pnpm teston Windows againstmain. The tester app was the one that surfaced it, since it builds a real bundle with a remote asset for both platforms.Verification (Windows, current
main)tester-app(apps/tester-app, vitest)Invalid URL@callstack/repack(jest)pnpm lint:cipnpm typecheckChecked and not touched: the other
path.joincalls inassetsLoader.ts(lines 174–188) build the on-diskdestinationfor extracted files, which genuinely is a filesystem path — those are correct as they are.Related, not fixed here
tests/integrationis still red on Windows after this (50 of 58). With this change the eightInvalid URLfailures are gone from it, but the remaining ones are all in the test harness rather than the loader: the memfsvolume.toTree()snapshots expect/out/…and receive\out/…. That is a separate fix in the test setup, and I would rather keep this PR to the production bug.This also unblocks the
windows-latestmatrix you asked for on #1450 —@callstack/repack,repack-dev-server,metro-compat,resolver-casesandtester-appare all green on Windows now, so that follow-up can cover everything excepttests/integrationhonestly rather than excluding two workspaces.🤖 Generated with Claude Code
https://claude.ai/code/session_018U3wcP5Qm39cas5MtVVabw