refactor: create standalone router package (#22)

* refactor: create standalone router package

* fix: add jsdom to tuono-router package

* fix: remove test in tuono vite.config

* update turbo to latest

* fix: wait build before lint

* fix: router types
This commit is contained in:
Valerio Ageno
2024-08-11 17:14:54 +02:00
committed by GitHub
parent 8604858a61
commit 75c790dd6e
32 changed files with 112 additions and 25 deletions
+8 -7
View File
@@ -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",
@@ -37,6 +38,6 @@
"vitest": "^1.5.2"
},
"dependencies": {
"turbo": "^2.0.4"
"turbo": "^2.0.12"
}
}
+2
View File
@@ -0,0 +1,2 @@
dist
pnpm-lock.yaml
+5
View File
@@ -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
View File
@@ -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"
}
}
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react"
},
"include": ["src", "tests", "vite.config.ts"]
}
+23
View File
@@ -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',
}),
)
+3 -8
View File
@@ -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",
@@ -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"
},
+1 -1
View File
@@ -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
+1 -1
View File
@@ -7,7 +7,7 @@ import {
RouterProvider,
dynamic,
useRouter,
} from './router'
} from 'tuono-router'
export type { TuonoProps } from './types'
+1 -1
View File
@@ -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'
-6
View File
@@ -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(
+5 -1
View File
@@ -1,7 +1,11 @@
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"lint": {},
"lint": {
"dependsOn": [
"^build"
]
},
"format": {},
"format:check": {},
"types": {