From a652d72a740746c4139ce3e3116feadd80c07df2 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Thu, 7 Aug 2025 11:00:58 -0400 Subject: [PATCH 1/2] hotfix(rolldown): fix breaking change --- src/generators/web/utils/generate.mjs | 5 ++--- src/generators/web/utils/processing.mjs | 13 ++----------- tmp.txt | 0 3 files changed, 4 insertions(+), 14 deletions(-) create mode 100644 tmp.txt diff --git a/src/generators/web/utils/generate.mjs b/src/generators/web/utils/generate.mjs index a9f3be84..d382f9c9 100644 --- a/src/generators/web/utils/generate.mjs +++ b/src/generators/web/utils/generate.mjs @@ -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, @@ -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'); }; diff --git a/src/generators/web/utils/processing.mjs b/src/generators/web/utils/processing.mjs index cdd9ce22..82610a90 100644 --- a/src/generators/web/utils/processing.mjs +++ b/src/generators/web/utils/processing.mjs @@ -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 @@ -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. @@ -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. diff --git a/tmp.txt b/tmp.txt new file mode 100644 index 00000000..e69de29b From d26d4b3f0c96e832a6b5cc6137fa7bb728d710ab Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Thu, 7 Aug 2025 11:04:26 -0400 Subject: [PATCH 2/2] Delete tmp.txt --- tmp.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tmp.txt diff --git a/tmp.txt b/tmp.txt deleted file mode 100644 index e69de29b..00000000