Skip to content

Commit 0251ac1

Browse files
hi-ogawaclaude
andcommitted
refactor(rsc): use relative IDs in environment imports manifest
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]>
1 parent eac76d5 commit 0251ac1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/plugin-rsc/src/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ class RscPluginManager {
184184
const relativePath = normalizeRelativePath(
185185
path.relative(sourceOutDir, path.join(targetOutDir, meta.fileName)),
186186
)
187-
code += ` ${JSON.stringify(resolvedId)}: () => import(${JSON.stringify(relativePath)}),\n`
187+
// Use relative ID for stable builds across different machines
188+
const relativeId = this.toRelativeId(resolvedId)
189+
code += ` ${JSON.stringify(relativeId)}: () => import(${JSON.stringify(relativePath)}),\n`
188190
}
189191
code += '}\n'
190192

packages/plugin-rsc/src/plugins/import-environment.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ export function vitePluginImportEnvironment(
124124
resolvedId = resolved.id
125125
}
126126

127-
// Track discovered entry
127+
// Track discovered entry (keyed by absolute path for generateBundle lookup)
128128
manager.environmentImportMetaMap[resolvedId] = {
129-
// TODO: relative-ize resolveId
130129
resolvedId,
131130
targetEnv: environmentName,
132131
sourceEnv: this.environment.name,
@@ -140,7 +139,9 @@ export function vitePluginImportEnvironment(
140139
// Build: emit manifest lookup with static import
141140
// The manifest is generated in buildApp after all builds complete
142141
// Use placeholder that renderChunk will replace with correct relative path
143-
replacement = `(await import(${JSON.stringify(ENV_IMPORTS_MANIFEST_PLACEHOLDER)})).default[${JSON.stringify(resolvedId)}]()`
142+
// Use relative ID for stable builds across different machines
143+
const relativeId = manager.toRelativeId(resolvedId)
144+
replacement = `(await import(${JSON.stringify(ENV_IMPORTS_MANIFEST_PLACEHOLDER)})).default[${JSON.stringify(relativeId)}]()`
144145
}
145146

146147
const [start, end] = match.indices![0]!

0 commit comments

Comments
 (0)