mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #1031] Failed to resolve shim imports in sandbox environments #226
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#226
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @eashish93 on GitHub (May 2, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/1031
vinext@0.0.46ships twodist/server/*.jsfiles that still import a shim via a relative path, which #1006 was meant to eliminate. The samevite:import-analysisfailure that #1001 / #1006 fixed is back when running under@cloudflare/sandboxSDK.Files still wrong in 0.0.46
Should be:
…matching the pattern #1006 applied to the other 67 imports across 34 files.
Symptom
Fires on first paint inside a
@cloudflare/sandbox-managed container, every time.Why plain
vinext devdoesn't show itVite's
optimizeDepspre-bundles the shim and rewrites the absolute path import to?v=<hash>form, masking it. Under the@cloudflare/sandboxSDK invocation path the optimizer cache misses, so the raw absolute path reachesimport-analysis.normalizeUrl— which treats leading/as URL-relative-to-server-root, so/workspace/fooresolves to<root>/workspace/foo=/workspace/workspace/fooand fails.Versions
vinext@vitejs/plugin-rsc^0.5.25vite8.0.10@cloudflare/vite-plugin^1.35.0@cloudflare/sandbox^0.9.2Fix
Apply #1006's transform to those two files. Worth checking why the regression test added in #1006 didn't catch this in CI for 0.0.46.
Reproduce
Zip attached. README inside has the full mechanism walkthrough.
vinext-shim-bug-repro.zip
@james-elicx commented on GitHub (May 2, 2026):
The prerelease for the last commit on main is https://pkg.pr.new/vinext@a49be5c
Please can you try that?
@james-elicx commented on GitHub (May 2, 2026):
Oh I see. The build that gets published is resolving the aliases and they're going back to relative paths.
@eashish93 commented on GitHub (May 2, 2026):
Trying now. Zip file though I've uploaded is using 0.0.46 (not .45) btw and now you can easily reproduce it.
@james-elicx commented on GitHub (May 2, 2026):
Yes it won't make a difference, the imports are being transformed back to relative, which makes sense.
I think you should file an issue in the RSC plugin's repo as this sounds like a bug that will need fixing in how they deal with deps.
@eashish93 commented on GitHub (May 3, 2026):
I tried that pre-release and it's same, then I tried this patch:
That fixes the issue for me, but then another vite plugin error occur which recently fixed here #1008 .
So I asked claude to give me a patch to apply. Here's the patch for this one:
You can reproduce both error on same zip file, one by one. Apply first patch and then you'll get another error (related to #1008 , exportNames).
Also I'll try to file a bug on vite-plugin-react also, but they require live demo url for reproduction. Will try with github link there.
@james-elicx commented on GitHub (May 3, 2026):
The bug is in the RSC plugin or Vite from what I can tell - relative imports within our library should work fine...
@eashish93 commented on GitHub (May 3, 2026):
Linked here the bug I filed (description auto-gen via claude): https://github.com/vitejs/vite-plugin-react/issues/1207