Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 56e2b85 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: |
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 #420.
In SSR builds,
injectSsrModuleIdappendsexport const $$moduleUrlto every project module, and since #407 that includes.ts/.jsmodules. A server entry therefore gains a$$moduleUrlnamed export.@cloudflare/vite-plugin's worker entry doesexport * from main, so the export reaches the Worker, and workerd refuses to start withIncorrect type for map entry '$$moduleUrl'.The SSR build now removes
$$moduleUrlfrom the export clause of entry chunks inrenderChunk. It only does this when the chunk's facade is a configured build input (build.lib.entry, a stringbuild.ssr, orrollupOptions/rolldownOptionsinput, in Vite's order) and no module imports the facade, statically or throughimport(). Serverlazy()reads$$moduleUrlonly from modules it reaches throughimport(), so lazy targets keep the export. Entry chunks that other plugins emit withemitFilealso keep it, because a framework may load them at runtime by path. The removed specifier is padded with spaces so the chunk's source map stays valid. Removing the export at render time leaves the transform unchanged, which matters because the transform cannot know whether a module will end up as an entry. With Cloudflare, the user'smainis reached only through the plugin's virtual worker entry.Verified with the issue's setup (vite 8.3.4,
@cloudflare/vite-plugin1.64.0, wrangler 4.151.0, solid-js 2.0.0-rc.15) against a packed tarball of this branch. I ranvite buildandvite preview, thencurl http://127.0.0.1:5391/:dist/server/server.jsends withexport { $$moduleUrl, worker_entry_default as default }and workerd fails to start.export { worker_entry_default as default }and the request returns HTTP 200. This holds for a.tsand a.tsxmain, minified and unminified, with an exported Durable Object class, and withoutput.footer: '// end'.import.meta.globlazy target's chunk still ends withexport { i as $$moduleUrl, r as default }.tsc --noEmitpasses. There is no unit test harness onnext, so this has no automated test.Still open:
$$moduleUrl.footerthat contains code would skip the removal.🤖 Generated with Claude Code