mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
* chore: update react router to v8 and modernize node infrastructure - Bump React Router to v8.0.0 and update associated dependencies. - Upgrade Node.js base image to v24. - Simplify TSConfig and Vite configuration by utilizing native TSConfig path resolution. - Add .env to gitignore. - Ensure consistent scripting and environment settings across SPA and SSR examples. Generated-by: aiautocommit * feat(node): detect React Router SPA mode from config Generated-by: aiautocommit * test(node): improve React Router SPA detection and handling Generated-by: aiautocommit * chore(deps): update mise.dev.lock Generated-by: aiautocommit * docs(node): clarify SPA detection limitation and manual override Generated-by: aiautocommit * test(node): bind React Router preview server to IPv4 in SPA example - Force preview host to 127.0.0.1 in Vite config and generation script. - Prevent connection mismatch issues between prerender requests and the preview server. Generated-by: aiautocommit
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package node
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestReactRouterSPAConfig(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
config string
|
|
isSPA bool
|
|
}{
|
|
{
|
|
name: "multiline config",
|
|
config: "export default {\n ssr: false,\n} satisfies Config;",
|
|
isSPA: true,
|
|
},
|
|
{
|
|
name: "inline config",
|
|
config: "export default { ssr: false } satisfies Config;",
|
|
isSPA: true,
|
|
},
|
|
{
|
|
name: "quoted property",
|
|
config: "export default { 'ssr': false } satisfies Config;",
|
|
isSPA: true,
|
|
},
|
|
{
|
|
name: "server rendering enabled",
|
|
config: "export default { ssr: true } satisfies Config;",
|
|
isSPA: false,
|
|
},
|
|
{
|
|
name: "server rendering omitted",
|
|
config: "export default {} satisfies Config;",
|
|
isSPA: false,
|
|
},
|
|
{
|
|
name: "dynamic server rendering",
|
|
config: "export default { ssr: process.env.SSR === 'true' } satisfies Config;",
|
|
isSPA: false,
|
|
},
|
|
{
|
|
name: "commented setting",
|
|
config: "export default {\n // ssr: false,\n} satisfies Config;",
|
|
isSPA: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
require.Equal(t, tt.isSPA, reactRouterSPAConfigRegex.MatchString(tt.config))
|
|
})
|
|
}
|
|
}
|