Repository navigation
fix: resolve slash-prefixed lazy() moduleUrl keys in dev and build - #399
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: ec428e1 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 |
commit: |
Co-authored-by: Cursor <cursoragent@cursor.com>
ryansolid
force-pushed
the
fix/issue-390-lazy-leading-slash
branch
from
October 8, 2026 20:17
d6b5613 to
ec428e1
Compare
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.
Fixes #390.
Problem
A hand-written
lazy()moduleUrl with a leading slash (lazy(() => import("./Page"), undefined, "/src/Page.tsx")) never resolved. The compiler leaves three-argument calls alone, so the string reached the resolvers as written:devModuleUrland its generated mirror builtbase + "/" + key, giving a protocol-relative//src/Page.tsx. The CSS walk also missed becausepath.resolve(root, "/src/Page.tsx")is an absolute path outside the project.manifest[moduleUrl], and the baked manifest has no/src/Page.tsxkey, so no client assets or module map were emitted.Fix
Normalize on the plugin side so dev and build agree without a runtime change:
moduleUrlfallback indevManifestCode) strips leading slashes before building the URL and walking the module graph.virtual:solid-manifestdefines a non-enumerable"/" + keyalias for each record.for…in,Object.keys, andJSON.stringifystill see the manifest unchanged, soregisterEntryAssets,_entry, and external manifest consumers aren't affected.Tests
examples/start-ssr: aSlashLazyfixture on/lazy-assetswith a"/src/SlashLazy.tsx"key.runLazyAssetChecksasserts that dev preloads/src/SlashLazy.tsx(it was//src/SlashLazy.tsxbefore the fix) and that prod preloads the manifest's hashed file (no preload was emitted before). The checks also pass under a non-rootbase.examples/css-matrix/test/bridge.mjs: the HTTP bridge resolves a slash-prefixed key to the same URL and CSS, and the generated fallbackresolveSyncmaps it to the root-relative URL.Ran locally: start-ssr
dev,prod, andbase; css-matrixrunandbridge; and the ssr example. The new assertions fail onnextwithout thesrc/change.Open question
The issue leaves open whether to normalize in the plugin or in
@solidjs/web'sresolveAssets. This PR normalizes in the plugin, which covers hand-rolled server entries that importvirtual:solid-manifest. A runtime-sidemanifest[key] ?? manifest[key.slice(1)]would make the build aliases unnecessary. The alternative is rejecting slash keys with an error instead of normalizing them.Made with Cursor