Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react-server): generate mapping of server route to client assets #331

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Jun 2, 2024

Looking back #257, the manifest manipulation looks too complicated, so I'm trying a new approach based on rollup's ModuleInfo.

We can solve this mapping in two steps:

# react-server build (routeManifestPluginServer)
# (mapping from server route to "use client" file id)
routes/page.tsx (server route) --(traverse ModuleInfo.imports)--> some-client.tsx (a file with "use client")

# browser build (routeManifestPluginClient)
# (mapping form "use client" file id to asset path)
some-client.tsx  ~(OutputBundle)~> assets/some-client-xxx.js (also follow Chunk.imports deeply)

todo

  • build time
    • use transform.meta and PluginContext.getModuleInfo to map from route to client reference (during server build)
    • map client reference id to browser asset file (during browser build)
  • runtime
  • test

@hi-ogawa hi-ogawa changed the title feat(react-server): preload client reference assets (2nd try) feat(react-server): generate mapping of server route to client assets Jun 3, 2024
@hi-ogawa hi-ogawa marked this pull request as ready for review June 3, 2024 05:10
@hi-ogawa hi-ogawa changed the base branch from main to refactor-route-utils June 3, 2024 09:59
@hi-ogawa hi-ogawa force-pushed the feat-client-reference-preload2 branch from 277c4dc to 01ded13 Compare June 3, 2024 10:05
@hi-ogawa
Copy link
Owner Author

hi-ogawa commented Jun 4, 2024

Merge activity

  • Jun 3, 11:09 PM EDT: @hi-ogawa started a stack merge that includes this pull request via Graphite.
  • Jun 3, 11:10 PM EDT: Graphite rebased this pull request as part of a merge.
  • Jun 3, 11:11 PM EDT: @hi-ogawa merged this pull request with Graphite.

Base automatically changed from refactor-route-utils to main June 4, 2024 03:09
@hi-ogawa hi-ogawa force-pushed the feat-client-reference-preload2 branch from 01ded13 to 3395097 Compare June 4, 2024 03:09
@hi-ogawa hi-ogawa merged commit 5c1011a into main Jun 4, 2024
4 checks passed
@hi-ogawa hi-ogawa deleted the feat-client-reference-preload2 branch June 4, 2024 03:11
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.

1 participant