impr: React prerendering testing app#2597
Open
cieplypolar wants to merge 9 commits into
Open
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (355 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.87, 1.72, 3.23, 4.95, 6.12, 9.36, 19.12, 18.93]
line [0.83, 1.58, 3.32, 4.98, 6.07, 8.89, 18.72, 18.45]
line [0.75, 1.58, 3.75, 5.42, 6.45, 9.18, 17.52, 21.47]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.27, 0.44, 0.61, 0.73, 0.99, 1.10, 1.30, 1.44]
line [0.27, 0.46, 0.63, 0.83, 1.11, 1.10, 1.32, 1.40]
line [0.32, 0.47, 0.61, 0.68, 0.94, 0.99, 1.27, 1.34]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.76, 1.86, 3.46, 5.16, 10.53, 21.93, 45.96, 94.80]
line [0.82, 1.74, 3.22, 5.28, 10.11, 21.77, 45.77, 94.41]
line [0.70, 1.76, 2.99, 5.30, 10.36, 21.64, 46.21, 95.11]
|
d3946ca to
dcad552
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a minimal Next.js app to reproduce/test @typegpu/react behavior during prerendering, and adjusts unplugin-typegpu’s Babel transform so hoisted "use gpu" function declarations preserve module exports.
Changes:
- Introduces
apps/react-prerendering-test(Next.js static-export app) with a shader demo and an SSR-vs-no-SSR build check script. - Updates
packages/unplugin-typegpu/src/babel.tsto rewriteexport function .../export default function ...correctly when hoisting transformed declarations. - Updates
unplugin-typegputests andpnpm-lock.yamlfor the new app and dependency graph.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds the new app importer and Next.js-related dependency resolutions. |
| packages/unplugin-typegpu/src/babel.ts | Updates Babel hoisting/export rewrite logic for "use gpu" function declarations. |
| packages/unplugin-typegpu/test/use-gpu-directive.test.ts | Splits export-hoisting coverage into Babel/Rollup and updates snapshots. |
| apps/react-prerendering-test/package.json | Defines the new app’s dependencies and SSR-check scripts. |
| apps/react-prerendering-test/tsconfig.json | Adds Next/TS configuration for the new test app. |
| apps/react-prerendering-test/next.config.ts | Configures static export output and build directory. |
| apps/react-prerendering-test/babel.config.js | Enables unplugin-typegpu Babel plugin under Next’s Babel pipeline. |
| apps/react-prerendering-test/checkSsr.mts | Adds a helper script to run builds with SSR enabled/disabled. |
| apps/react-prerendering-test/README.md | Documents the intent and how to run the SSR checks. |
| apps/react-prerendering-test/app/layout.tsx | Adds a minimal layout/metadata for the app-router setup. |
| apps/react-prerendering-test/app/page.tsx | Adds the page that toggles SSR behavior for the shader component. |
| apps/react-prerendering-test/components/Shader.tsx | Implements a client-only demo using @typegpu/react + TypeGPU functions. |
| apps/react-prerendering-test/app/icon.svg | Adds an app icon asset. |
| apps/react-prerendering-test/.gitignore | Ignores Next build artifacts for this app. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
95
to
+99
| visibility.unshiftContainer('body', replacement as t.Statement); | ||
| this.alreadyTransformed.add(expression); | ||
| path.remove(); | ||
| const id = t.isFunctionDeclaration(path.node) ? path.node.id : undefined; | ||
| if (id && path.parentPath.isExportNamedDeclaration()) { | ||
| path.parentPath.replaceWith( |
| "start": "next start", | ||
| "dev:no-ssr": "DISABLE_SSR=1 next dev", | ||
| "build:no-ssr": "DISABLE_SSR=1 next build", | ||
| "check-ssr": "node checkSsr.mts" |
Comment on lines
+3
to
+6
| return { | ||
| presets: ['next/babel'], | ||
| plugins: ['./node_modules/unplugin-typegpu/dist/babel.js'], // cannot parse .ts file | ||
| }; |
Comment on lines
+98
to
+104
| if (id && path.parentPath.isExportNamedDeclaration()) { | ||
| path.parentPath.replaceWith( | ||
| t.exportNamedDeclaration(null, [t.exportSpecifier(t.cloneNode(id), t.cloneNode(id))]), | ||
| ); | ||
| } else if (id && path.parentPath.isExportDefaultDeclaration()) { | ||
| path.parentPath.replaceWith(t.exportDefaultDeclaration(t.cloneNode(id))); | ||
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Blocked by #2606.
before doing that, we must fix
@typegpu/reactso it doesn't throw on the server sideEDIT: my fault, didn't prefixed env variables with
NEXT_PUBLIC_