-
-
Notifications
You must be signed in to change notification settings - Fork 226
feat(rsc): add import.meta.viteRsc.import API
#1063
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
Draft
hi-ogawa
wants to merge
31
commits into
main
Choose a base branch
from
01-16-feat_rsc_add_import_._environment_._
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
- Add architecture.md documenting build pipeline and data flow - Add bundler-comparison.md comparing RSC approaches across bundlers - Add implementation plan for new ergonomic import API - Stub import-environment.ts plugin file Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add import-environment plugin with transform/renderChunk hooks - Dev mode: rewrite to globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__ - Build mode: emit marker, resolve in renderChunk to relative import - Auto-discover entries and inject into target environment's input - Handle empty SSR input case in buildApp orchestration Co-Authored-By: Claude Opus 4.5 <[email protected]>
Document the preferred implementation using static import functions in a manifest file, which supports custom entryFileNames and enables proper static analysis by bundlers. Key additions: - Manifest with static import functions (not dynamic lookups) - Bidirectional support (RSC → SSR and SSR → RSC) - Updated data flow showing entry injection after both scans - Per-environment manifest generation Co-Authored-By: Claude Opus 4.5 <[email protected]>
…leNames Replace hardcoded output filenames with a manifest approach that supports custom entryFileNames config. The manifest uses static import functions for proper bundler analysis. Changes: - Transform emits manifest lookup instead of markers - resolveId marks manifest as external during build - generateBundle tracks resolvedId → outputFileName mapping - writeEnvironmentImportsManifest generates manifest after all builds - Split entry injection for bidirectional support (RSC↔SSR) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace direct rollupOptions.input mutation with: - Virtual scan placeholder for scan builds without configured entries - emitFile in buildStart for emitting discovered entries in real builds This follows the fullstack plugin pattern and provides cleaner separation between scan and real build phases. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use a placeholder in transform and replace with correct relative path in renderChunk, similar to how BUILD_ASSETS_MANIFEST_NAME is handled. This ensures manifest imports work correctly for nested chunk outputs. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Let Rollup auto-name emitted chunks instead of deriving entry names from specifiers. The actual output filename is tracked via generateBundle anyway, so the explicit name was unnecessary. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…tMetaMap Add fileName field to EnvironmentImportMeta instead of tracking output filenames in a separate map. This simplifies the data structure and removes the TODO about merging the maps. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use toRelativeId() for manifest keys instead of absolute paths. This ensures stable builds across different machines/environments. Before: "/home/user/.../entry.ssr.tsx" After: "src/framework/entry.ssr.tsx" Co-Authored-By: Claude Opus 4.5 <[email protected]>
Change from `Record<resolvedId, meta>` to `Record<sourceEnv, Record<resolvedId, meta>>`. This properly handles the case where the same module is imported from multiple source environments, avoiding overwrites. Co-Authored-By: Claude Opus 4.5 <[email protected]>
de75327 to
b2b877a
Compare
Add documentation for the new import.meta.viteRsc.import() API in both README.md and types/index.d.ts with JSDoc, examples, and type signatures. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…esolution - Replace `rscBundle` with `bundles: Record<string, OutputBundle>` in RscPluginManager - Lookup fileName from bundles in writeEnvironmentImportsManifest instead of mutating meta - Remove generateBundle hook from import-environment plugin (no longer needed) - Remove unused fileName field from EnvironmentImportMeta type Co-Authored-By: Claude Opus 4.5 <[email protected]>
…nv][resolvedId] - Update type definition to add targetEnv as middle key - Update write logic in transform to use new structure - Update buildStart to lookup by targetEnv directly (more efficient) - Update writeEnvironmentImportsManifest to iterate by targetEnv Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.
Summary
Add
import.meta.viteRsc.import()- a more ergonomic API for cross-environment module loading.Comparison
Before (
loadModule):After (
import):How it works
__VITE_ENVIRONMENT_RUNNER_IMPORT__(same asloadModule)__vite_rsc_env_imports_manifest.js)Documentation
README.md- API documentation with comparisontypes/index.d.ts- TypeScript types with JSDocTest plan
🤖 Generated with Claude Code