-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add rsbuild support for TanStack Start #6623
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
Open
ScriptedAlchemy
wants to merge
18
commits into
TanStack:main
Choose a base branch
from
ScriptedAlchemy:feat/rsbuild
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cab475a
Add rsbuild Start plugin implementation
cursoragent 0f73fe3
Implement rsbuild Start plugin parity
cursoragent bbd2c2d
Fix SSR server static index handling
cursoragent d0ade15
Fix rsbuild preview and css handling
cursoragent 20fe2f2
Fix redirect serialization heuristics
cursoragent 9c1a6b2
Merge pull request #1 from ScriptedAlchemy/cursor/rsbuild-plugin-spa-…
ScriptedAlchemy 87f6ea4
Harden PR CI and refine rsbuild build env handling
cursoragent ad20294
Merge pull request #5 from ScriptedAlchemy/cursor/branch-implementati…
ScriptedAlchemy 8d0e57d
Revert PR workflow audit changes
ScriptedAlchemy fbde76b
ci: apply automated fixes
autofix-ci[bot] ffc2b97
ci: retrigger PR checks after preview service failure
ScriptedAlchemy 1d4155b
fix: address PR review issues in rsbuild integration
ScriptedAlchemy 13a7530
ci: apply automated fixes
autofix-ci[bot] 448340d
fix: restore response typing in server fn fetcher
ScriptedAlchemy 4ccdde4
fix: satisfy response-like eslint guard in server handler
ScriptedAlchemy 21d9b11
refactor: resolve remaining PR #6623 review suggestions
ScriptedAlchemy 56efe06
ci: apply automated fixes
autofix-ci[bot] ef21285
fix: address remaining unresolved PR review threads
ScriptedAlchemy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import path from 'node:path' | ||
| import { fileURLToPath } from 'node:url' | ||
| import { defineConfig } from '@rsbuild/core' | ||
| import { pluginReact } from '@rsbuild/plugin-react' | ||
| import { tanstackStart } from '@tanstack/react-start/plugin/rsbuild' | ||
| import { isSpaMode } from './tests/utils/isSpaMode' | ||
| import { isPrerender } from './tests/utils/isPrerender' | ||
|
|
||
| const currentDir = path.dirname(fileURLToPath(import.meta.url)) | ||
|
|
||
| const spaModeConfiguration = { | ||
| enabled: true, | ||
| prerender: { | ||
| outputPath: 'index.html', | ||
| }, | ||
| } | ||
|
|
||
| const prerenderConfiguration = { | ||
| enabled: true, | ||
| filter: (page: { path: string }) => | ||
| ![ | ||
| '/this-route-does-not-exist', | ||
| '/redirect', | ||
| '/i-do-not-exist', | ||
| '/not-found/via-beforeLoad', | ||
| '/not-found/via-loader', | ||
| '/specialChars/search', | ||
| '/specialChars/hash', | ||
| '/specialChars/malformed', | ||
| '/users', | ||
| ].some((p) => page.path.includes(p)), | ||
| maxRedirects: 100, | ||
| } | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [ | ||
| pluginReact(), | ||
| ...tanstackStart({ | ||
| spa: isSpaMode ? spaModeConfiguration : undefined, | ||
| prerender: isPrerender ? prerenderConfiguration : undefined, | ||
| }), | ||
| ], | ||
| tools: {}, | ||
| source: { | ||
| alias: { | ||
| '~': path.resolve(currentDir, 'src'), | ||
| }, | ||
| }, | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { spawn } from 'node:child_process' | ||
|
|
||
| const command = process.argv[2] | ||
| const args = process.argv.slice(3) | ||
|
|
||
| if (!command) { | ||
| console.error('Missing bundler command') | ||
| process.exit(1) | ||
| } | ||
|
|
||
| const bundler = process.env.BUNDLER === 'rsbuild' ? 'rsbuild' : 'vite' | ||
|
|
||
| const extractPort = (args) => { | ||
| const portIndex = args.indexOf('--port') | ||
| if (portIndex >= 0 && args[portIndex + 1]) { | ||
| return args[portIndex + 1] | ||
| } | ||
| return null | ||
| } | ||
|
|
||
| const run = (cmd, cmdArgs) => | ||
| new Promise((resolve, reject) => { | ||
| const child = spawn(cmd, cmdArgs, { | ||
| stdio: 'inherit', | ||
| env: process.env, | ||
| shell: process.platform === 'win32', | ||
| }) | ||
| child.on('error', (error) => { | ||
| reject(error) | ||
| }) | ||
| child.on('close', (code) => { | ||
| if (code === 0) { | ||
| resolve() | ||
| } else { | ||
| reject(new Error(`${cmd} exited with code ${code}`)) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| try { | ||
| if (bundler === 'rsbuild' && command === 'preview') { | ||
| const port = extractPort(args) | ||
| if (port) { | ||
| process.env.PORT = port | ||
| } | ||
| await run('node', ['server.js']) | ||
| } else { | ||
| await run(bundler, [command, ...args]) | ||
|
|
||
| if (command === 'build') { | ||
| await run('tsc', ['--noEmit']) | ||
| } | ||
| } | ||
| } catch (error) { | ||
| console.error(error) | ||
| process.exit(1) | ||
| } | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,57 @@ | ||
| @import 'tailwindcss' source('../'); | ||
|
|
||
| @layer base { | ||
| *, | ||
| ::after, | ||
| ::before, | ||
| ::backdrop, | ||
| ::file-selector-button { | ||
| border-color: var(--color-gray-200, currentcolor); | ||
| } | ||
| } | ||
|
|
||
| @layer base { | ||
| html { | ||
| color-scheme: light dark; | ||
| } | ||
|
|
||
| * { | ||
| @apply border-gray-200 dark:border-gray-800; | ||
| } | ||
|
|
||
| html, | ||
| body { | ||
| @apply text-gray-900 bg-gray-50 dark:bg-gray-950 dark:text-gray-200; | ||
| } | ||
|
|
||
| .using-mouse * { | ||
| outline: none !important; | ||
| } | ||
| *, | ||
| *::before, | ||
| *::after, | ||
| ::backdrop, | ||
| ::file-selector-button { | ||
| box-sizing: border-box; | ||
| border-color: #e5e7eb; | ||
| } | ||
|
|
||
| html { | ||
| color-scheme: light dark; | ||
| } | ||
|
|
||
| body { | ||
| margin: 0; | ||
| font-family: | ||
| system-ui, | ||
| -apple-system, | ||
| BlinkMacSystemFont, | ||
| 'Segoe UI', | ||
| sans-serif; | ||
| background-color: #f9fafb; | ||
| color: #111827; | ||
| } | ||
|
|
||
| .using-mouse * { | ||
| outline: none !important; | ||
| } | ||
|
|
||
| .p-2 { | ||
| padding: 0.5rem; | ||
| } | ||
|
|
||
| .py-2 { | ||
| padding-top: 0.5rem; | ||
| padding-bottom: 0.5rem; | ||
| } | ||
|
|
||
| .flex { | ||
| display: flex; | ||
| } | ||
|
|
||
| .gap-2 { | ||
| gap: 0.5rem; | ||
| } | ||
|
|
||
| .text-lg { | ||
| font-size: 1.125rem; | ||
| } | ||
|
|
||
| .font-bold { | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| .italic { | ||
| font-style: italic; | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { fileURLToPath } from 'node:url' | ||
| import path from 'pathe' | ||
| import { TanStackStartRsbuildPluginCore } from '@tanstack/start-plugin-core/rsbuild' | ||
| import type { TanStackStartInputConfig } from '@tanstack/start-plugin-core' | ||
|
|
||
| type RsbuildPlugin = { | ||
| name: string | ||
| setup: (api: any) => void | ||
| } | ||
|
|
||
| const currentDir = path.dirname(fileURLToPath(import.meta.url)) | ||
| const defaultEntryDir = path.resolve( | ||
| currentDir, | ||
| '..', | ||
| '..', | ||
| 'plugin', | ||
| 'default-entry', | ||
| ) | ||
| const defaultEntryPaths = { | ||
| client: path.resolve(defaultEntryDir, 'client.tsx'), | ||
| server: path.resolve(defaultEntryDir, 'server.ts'), | ||
| start: path.resolve(defaultEntryDir, 'start.ts'), | ||
| } | ||
|
|
||
| export function tanstackStart( | ||
| options?: TanStackStartInputConfig, | ||
| ): Array<RsbuildPlugin> { | ||
| return TanStackStartRsbuildPluginCore( | ||
| { | ||
| framework: 'react', | ||
| defaultEntryPaths, | ||
| }, | ||
| options, | ||
| ) | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.