Skip to content

Commit 4563301

Browse files
committed
fix: misc fix from #673
1 parent 01aabbd commit 4563301

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ runs:
1515
with:
1616
node-version: 20
1717

18-
- run: corepack enable
18+
- run: npm install -g corepack@latest && corepack enable
1919
shell: bash
2020

2121
- run: pnpm i

packages/pre-bundle-new-url/examples/basic/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"exclude": ["node_modules"],
33
"compilerOptions": {
4+
"skipLibCheck": true,
45
"strict": true,
56
"verbatimModuleSyntax": true,
67
"noEmit": true,

packages/react-server-next/src/compat/og.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ export class ImageResponse extends Response {
88
constructor(...args: ConstructorParameters<typeof OgType.ImageResponse>) {
99
const body = new ReadableStream({
1010
async start(controller) {
11-
const ogModule = await import("@vercel/og");
12-
const response = new ogModule.ImageResponse(...args);
13-
tinyassert(response.body);
14-
for await (const chunk of response.body) {
15-
controller.enqueue(chunk);
11+
try {
12+
const ogModule = await import("@vercel/og");
13+
const response = new ogModule.ImageResponse(...args);
14+
tinyassert(response.body);
15+
for await (const chunk of response.body) {
16+
controller.enqueue(chunk);
17+
}
18+
controller.close();
19+
} catch (e) {
20+
console.error("[ERROR:ImageResponse]", e);
1621
}
17-
controller.close();
1822
},
1923
});
2024
const headers = new Headers(args[1]?.headers);

packages/react-server/src/features/prerender/plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function prerenderPlugin({
3333
}): Plugin[] {
3434
return [
3535
{
36-
name: prerenderPlugin + ":build",
36+
name: prerenderPlugin.name + ":build",
3737
enforce: "post",
3838
apply: () => manager.buildType === "ssr",
3939
writeBundle: {
@@ -44,7 +44,7 @@ export function prerenderPlugin({
4444
},
4545
},
4646
{
47-
name: prerenderPlugin + ":preview",
47+
name: prerenderPlugin.name + ":preview",
4848
apply: (_config, env) => !!env.isPreview,
4949
configurePreviewServer(server) {
5050
const outDir = server.config.build.outDir;

packages/react-server/src/plugin/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,22 @@ export function vitePluginReactServer(
439439
}),
440440
),
441441
{
442+
// externalize `dist/rsc/index.js` import as relative path in ssr build
442443
name: "virtual:react-server-build",
443444
resolveId(source) {
444445
if (source === "virtual:react-server-build") {
445-
// externalize as relative path
446-
// from: dist/server/index.js (ssr build)
447-
// to: dist/rsc/index.js (rsc build)
448-
return { id: "../rsc/index.js", external: true };
446+
return { id: "__VIRTUAL_REACT_SERVER_BUILD__", external: true };
447+
}
448+
return;
449+
},
450+
renderChunk(code, chunk) {
451+
if (code.includes("__VIRTUAL_REACT_SERVER_BUILD__")) {
452+
const replacement = path.relative(
453+
path.join(outDir, "server", chunk.fileName, ".."),
454+
path.join(outDir, "rsc", "index.js"),
455+
);
456+
code = code.replace("__VIRTUAL_REACT_SERVER_BUILD__", replacement);
457+
return { code };
449458
}
450459
return;
451460
},

0 commit comments

Comments
 (0)