Skip to content

Conversation

@hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented May 26, 2025

Entirely removing __vite__mapDeps and __vitePreload means that we give up supporting lazy preload and css for dynamic import inside client boundary. But this is probably reasonable since we expect client boundary as js/css code splitting boundary.

todo

  • disable __vite__mapDeps entirely and test (by patching out vite:build-import-analysis?)
  • manage js chunks preload per client reference on our own
    • test
  • manage css per client reference on our own
    • test
  • move off client virtual from main browser bundle
    • do the same for ssr? it should still be able to bundle server easily as extra adapter build pass.
      • how does xxxpack/parcel allow post-bundling e.g. for cloudflare deploy? wouldn't their "chunk load" break? (e.g. parcelRequire.load(chunk)?)
        • Parcel has import "(server-dep-chunk)" hoisted to entry, so post-bundler can detect. Even though import(url) used by parcelRequire.load is not statically analyzable, wrangler can handle dynamic import as long as chunks are detected for deployment.
        • it likely breaks for other "common" adapter bundling solution.
        • also dynamic import is eagerly loaded, so it doesn't benefit from code splitting of client/server references on server.
      • react-server-dom-webpack patches __webpack_require__.u to overwrite chunk loading logic from flight payload.
    • ssr id re-mapping shouldn't be done by chunk file name level e.g. users might merge multiple client reference chunks for browser build but not on ssr build.
    • do the same for server reference?
  • test dynamic import inside client boundary
  • refactor
  • update @hiogawa/react-server
  • What if vite doesn't have __vite__mapDeps perf: reduce preload marker markup size vitejs/vite#14550 and have dependent chunks inline like before that PR? That would essentially avoid baking client chunks in main browser bundle and dependency chunks are only encoded in each chunk itself. Wouldn't that approach technically equivalent in terms of "rsc spirit"?
  • what about dev?

Copy link
Owner Author

hi-ogawa commented May 26, 2025

@hi-ogawa hi-ogawa force-pushed the 05-26-refactor_rsc_load_client_reference_without_vite_preload branch 4 times, most recently from c467b30 to f4672f4 Compare June 2, 2025 00:45
@hi-ogawa hi-ogawa force-pushed the 05-26-refactor_rsc_load_client_reference_without_vite_preload branch from b49c01c to 2fea96a Compare June 2, 2025 08:29
hi-ogawa added a commit that referenced this pull request Jun 13, 2025
fix extracted from #948.

The idea from #891. Collecting `facadeModuleId` is not enough to cover the case where `viteRscCss` doesn't appear in code-split entry.
@hi-ogawa hi-ogawa mentioned this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants