Skip to content

Commit

Permalink
fix: misc fix from #673
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Feb 4, 2025
1 parent 01aabbd commit 4563301
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ runs:
with:
node-version: 20

- run: corepack enable
- run: npm install -g corepack@latest && corepack enable
shell: bash

- run: pnpm i
Expand Down
1 change: 1 addition & 0 deletions packages/pre-bundle-new-url/examples/basic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"exclude": ["node_modules"],
"compilerOptions": {
"skipLibCheck": true,
"strict": true,
"verbatimModuleSyntax": true,
"noEmit": true,
Expand Down
16 changes: 10 additions & 6 deletions packages/react-server-next/src/compat/og.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ export class ImageResponse extends Response {
constructor(...args: ConstructorParameters<typeof OgType.ImageResponse>) {
const body = new ReadableStream({
async start(controller) {
const ogModule = await import("@vercel/og");
const response = new ogModule.ImageResponse(...args);
tinyassert(response.body);
for await (const chunk of response.body) {
controller.enqueue(chunk);
try {
const ogModule = await import("@vercel/og");
const response = new ogModule.ImageResponse(...args);
tinyassert(response.body);
for await (const chunk of response.body) {
controller.enqueue(chunk);
}
controller.close();
} catch (e) {
console.error("[ERROR:ImageResponse]", e);
}
controller.close();
},
});
const headers = new Headers(args[1]?.headers);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server/src/features/prerender/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function prerenderPlugin({
}): Plugin[] {
return [
{
name: prerenderPlugin + ":build",
name: prerenderPlugin.name + ":build",
enforce: "post",
apply: () => manager.buildType === "ssr",
writeBundle: {
Expand All @@ -44,7 +44,7 @@ export function prerenderPlugin({
},
},
{
name: prerenderPlugin + ":preview",
name: prerenderPlugin.name + ":preview",
apply: (_config, env) => !!env.isPreview,
configurePreviewServer(server) {
const outDir = server.config.build.outDir;
Expand Down
17 changes: 13 additions & 4 deletions packages/react-server/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,22 @@ export function vitePluginReactServer(
}),
),
{
// externalize `dist/rsc/index.js` import as relative path in ssr build
name: "virtual:react-server-build",
resolveId(source) {
if (source === "virtual:react-server-build") {
// externalize as relative path
// from: dist/server/index.js (ssr build)
// to: dist/rsc/index.js (rsc build)
return { id: "../rsc/index.js", external: true };
return { id: "__VIRTUAL_REACT_SERVER_BUILD__", external: true };
}
return;
},
renderChunk(code, chunk) {
if (code.includes("__VIRTUAL_REACT_SERVER_BUILD__")) {
const replacement = path.relative(
path.join(outDir, "server", chunk.fileName, ".."),
path.join(outDir, "rsc", "index.js"),
);
code = code.replace("__VIRTUAL_REACT_SERVER_BUILD__", replacement);
return { code };
}
return;
},
Expand Down

0 comments on commit 4563301

Please sign in to comment.