这是indexloc提供的服务,不要输入任何密码
Skip to content

refactor: create standalone router package #22

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 6 commits into from
Aug 11, 2024
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
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
"scripts": {
"dev": "turbo dev --filter tuono",
"build": "turbo build --filter tuono",
"lint": "turbo lint --filter tuono",
"format": "turbo format --filter tuono",
"format:check": "turbo format:check --filter tuono",
"lint": "turbo lint",
"format": "turbo format",
"format:check": "turbo format:check",
"types": "turbo types --filter tuono",
"test": "turbo test",
"test:watch": "turbo test:watch"
"test:watch": "turbo test:watch"
},
"workspaces": [
"tuono",
"tuono-lazy-fn-vite-plugin",
"tuono-fs-router-vite-plugin"
"tuono-lazy-fn-vite-plugin",
"tuono-fs-router-vite-plugin",
"tuono-router"
],
"author": "Valerio Ageno",
"license": "MIT",
Expand All @@ -37,6 +38,6 @@
"vitest": "^1.5.2"
},
"dependencies": {
"turbo": "^2.0.4"
"turbo": "^2.0.12"
}
}
2 changes: 2 additions & 0 deletions packages/router/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
pnpm-lock.yaml
5 changes: 5 additions & 0 deletions packages/router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# tuono-router

This package holds the logic related to the client/server react routing.

Check [tuono](https://github.com/Valerioageno/tuono) for more.
56 changes: 56 additions & 0 deletions packages/router/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "tuono-router",
"version": "0.8.3",
"description": "React routing component for the framework tuono. Tuono is the react/rust fullstack framework",
"scripts": {
"dev": "vite build --watch",
"build": "vite build",
"lint": "eslint --ext .ts,.tsx ./src -c ../../.eslintrc",
"format": "prettier -u --write --ignore-unknown '**/*'",
"format:check": "prettier --check --ignore-unknown '**/*'",
"types": "tsc --noEmit",
"test:watch": "vitest",
"test": "vitest run"
},
"keywords": [],
"author": "Valerio Ageno",
"license": "MIT",
"type": "module",
"types": "dist/esm/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"files": [
"dist",
"src",
"README.md"
],
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
},
"./package.json": "./package.json"
},
"peerDependencies": {
"react": ">=16.3.0",
"react-dom": ">=16.3.0"
},
"dependencies": {
"vite": "^5.2.11",
"zustand": "4.4.7"
},
"devDependencies": {
"@tanstack/config": "^0.7.11",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"jsdom": "^24.0.0",
"prettier": "^3.2.4",
"vitest": "^1.5.2"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/router/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react"
},
"include": ["src", "tests", "vite.config.ts"]
}
23 changes: 23 additions & 0 deletions packages/router/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference types="vitest" />
/// <reference types="vite/client" />
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackBuildConfig } from '@tanstack/config/build'
import react from '@vitejs/plugin-react'

const config = defineConfig({
plugins: [react()],
test: {
name: 'react-router',
watch: true,
environment: 'jsdom',
globals: true,
},
})

export default mergeConfig(
config,
tanstackBuildConfig({
entry: './src/index.ts',
srcDir: './src',
}),
)
11 changes: 3 additions & 8 deletions packages/tuono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"lint": "eslint --ext .ts,.tsx ./src -c ../../.eslintrc",
"format": "prettier -u --write --ignore-unknown '**/*'",
"format:check": "prettier --check --ignore-unknown '**/*'",
"types": "tsc --noEmit",
"test:watch": "vitest",
"test": "vitest run"
"types": "tsc --noEmit"
},
"type": "module",
"types": "dist/esm/index.d.ts",
Expand Down Expand Up @@ -92,17 +90,14 @@
"react-meta-tags": "^1.0.1",
"tuono-fs-router-vite-plugin": "workspace:*",
"tuono-lazy-fn-vite-plugin": "workspace:*",
"vite": "^5.2.11",
"zustand": "4.4.7"
"tuono-router": "workspace:*",
"vite": "^5.2.11"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/babel-traverse": "^6.25.10",
"@types/babel__traverse": "^7.20.6",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"jsdom": "^24.0.0",
"prettier": "^3.2.4",
"vitest": "^1.5.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/tuono/src/hydration/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { hydrateRoot } from 'react-dom/client'
import { RouterProvider, createRouter } from '../router'
import { RouterProvider, createRouter } from 'tuono-router'

type RouteTree = any

Expand Down
2 changes: 1 addition & 1 deletion packages/tuono/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RouterProvider,
dynamic,
useRouter,
} from './router'
} from 'tuono-router'

export type { TuonoProps } from './types'

Expand Down
2 changes: 1 addition & 1 deletion packages/tuono/src/ssr/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react'
import { renderToString, renderToStaticMarkup } from 'react-dom/server'
import MetaTagsServer from 'react-meta-tags/server'
import { MetaTagsContext } from 'react-meta-tags'
import { RouterProvider, createRouter } from '../router'
import { RouterProvider, createRouter } from 'tuono-router'

type RouteTree = any
type Mode = 'Dev' | 'Prod'
Expand Down
6 changes: 0 additions & 6 deletions packages/tuono/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import react from '@vitejs/plugin-react'

const config = defineConfig({
plugins: [react()],
test: {
name: 'react-router',
watch: true,
environment: 'jsdom',
globals: true,
},
})

export default mergeConfig(
Expand Down
6 changes: 5 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"lint": {},
"lint": {
"dependsOn": [
"^build"
]
},
"format": {},
"format:check": {},
"types": {
Expand Down