Skip to content

Commit ca2a1ff

Browse files
committed
Merge branch 'main' into 07-31-feat_rsc_support_customizing_react-server_conditioned_environment
2 parents e794a0e + ff44ae4 commit ca2a1ff

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

packages/plugin-rsc/src/plugin.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -963,20 +963,6 @@ function hashString(v: string) {
963963
return createHash('sha256').update(v).digest().toString('hex').slice(0, 12)
964964
}
965965

966-
function normalizeReferenceId(
967-
id: string,
968-
name: 'client' | 'rsc' | (string & {}),
969-
) {
970-
if (!server) {
971-
return hashString(path.relative(config.root, id))
972-
}
973-
974-
// align with how Vite import analysis would rewrite id
975-
// to avoid double modules on browser and ssr.
976-
const environment = server.environments[name]!
977-
return normalizeViteImportAnalysisUrl(environment, id)
978-
}
979-
980966
/** @experimental */
981967
export function vitePluginUseClient(
982968
useClientPluginOptions: Pick<
@@ -1289,7 +1275,14 @@ export function vitePluginUseServer(
12891275
// module identity of `import(id)` like browser, so we simply strip it off.
12901276
id = id.split('?v=')[0]!
12911277
}
1292-
normalizedId_ = normalizeReferenceId(id, serverEnvironmentName)
1278+
if (config.command === 'build') {
1279+
normalizedId_ = hashString(path.relative(config.root, id))
1280+
} else {
1281+
normalizedId_ = normalizeViteImportAnalysisUrl(
1282+
server.environments[serverEnvironmentName]!,
1283+
id,
1284+
)
1285+
}
12931286
}
12941287
return normalizedId_
12951288
}

0 commit comments

Comments
 (0)