Skip to content

hotfix(rolldown): fix breaking change #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/generators/web/utils/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ export default () => {
* Builds a server-side rendering (SSR) program.
*
* @param {string} componentCode - Code expression representing a JSX component
* @param {string} variable - The variable to output it to
*/
const buildServerProgram = (componentCode, variable) => {
const buildServerProgram = componentCode => {
return [
// JSX component imports
...baseImports,
Expand All @@ -88,7 +87,7 @@ export default () => {

// Render the component to an HTML string
// The output can be embedded directly into the server's HTML template
`const ${variable} = render(${componentCode});`,
`return render(${componentCode});`,
].join('\n');
};

Expand Down
13 changes: 2 additions & 11 deletions src/generators/web/utils/processing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { toJs, jsx } from 'estree-util-to-js';

import bundleCode from './bundle.mjs';

// Generate a unique variable name to capture the result of the server-side code.
// This prevents naming conflicts.
const SSRvariable = `_${Math.random().toString(36).slice(2)}`;

/**
* Executes server-side JavaScript code in a safe, isolated context.
* This function takes a string of JavaScript code, bundles it, and then runs it
Expand All @@ -26,12 +22,7 @@ export async function executeServerCode(serverCode, requireFn) {
// Create a new Function from the bundled server code.
// The `require` argument is passed into the function's scope, allowing the
// `bundledServer` code to use it for dynamic imports.
// The `return ${variable};` statement ensures that the value assigned to
// the dynamic variable within the `bundledServer` code is returned by this function.
const executedFunction = new Function(
'require',
`${bundledServer}\nreturn ${SSRvariable};`
);
const executedFunction = new Function('require', bundledServer);

// Execute the dynamically created function with the provided `requireFn`.
// The result of this execution is the dehydrated content from the server-side rendering.
Expand Down Expand Up @@ -62,7 +53,7 @@ export async function processJSXEntry(
// `buildServerProgram` takes the JSX-derived code and prepares it for server execution.
// `executeServerCode` then runs this code in a Node.js environment to produce
// the initial HTML content (dehydrated state) that will be sent to the client.
const serverCode = buildServerProgram(code, SSRvariable);
const serverCode = buildServerProgram(code);
const dehydrated = await executeServerCode(serverCode, requireFn);

// `buildClientProgram` prepares the JSX-derived code for client-side execution.
Expand Down
Loading