Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 274274b

Browse files
committed
Fix SSR dynamic imports
1 parent ee1f541 commit 274274b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

server/transformer.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,19 @@ export default {
9494
const s = new MagicString(source);
9595
deps.forEach((dep) => {
9696
const { specifier: depSpecifier, importUrl, loc } = dep;
97-
if (!isLikelyHttpURL(depSpecifier) && loc) {
97+
if (!loc) {
98+
return;
99+
}
100+
if (!isLikelyHttpURL(depSpecifier)) {
98101
const sep = importUrl.includes("?") ? "&" : "?";
99102
const version = depGraph.get(depSpecifier)?.version ?? depGraph.globalVersion;
100103
const url = `"${importUrl}${sep}ssr&v=${version.toString(36)}"`;
101104
s.overwrite(loc.start - 1, loc.end - 1, url);
102-
} else if (depSpecifier.startsWith(alephPkgUri + "/") && depSpecifier.endsWith(".tsx") && loc) {
105+
} else if (
106+
depSpecifier.startsWith(alephPkgUri + "/") && (
107+
depSpecifier.endsWith(".tsx") || alephPkgUri === "https://aleph"
108+
)
109+
) {
103110
const origin = Reflect.get(globalThis, "__ALEPH_SERVER_ORIGIN");
104111
const url = `"${origin}${toLocalPath(depSpecifier)}?ssr&v=${depGraph.globalVersion.toString(36)}"`;
105112
s.overwrite(loc.start - 1, loc.end - 1, url);

0 commit comments

Comments
 (0)