refactor: turn tuono-fs-router-vite-plugin into tuono-react-vite-plugin (#756)

This commit is contained in:
Valerio Ageno
2025-04-28 20:54:40 +02:00
committed by GitHub
parent 22844a37fa
commit b48f7244b7
47 changed files with 24 additions and 20 deletions
@@ -1,5 +1,5 @@
{
"name": "tuono-fs-router-vite-plugin",
"name": "tuono-react-vite-plugin",
"version": "0.19.4",
"description": "Plugin for the tuono's file system router. Tuono is the react/rust fullstack framework",
"homepage": "https://tuono.dev",
@@ -16,7 +16,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/tuono-labs/tuono.git",
"directory": "packages/tuono-fs-router-vite-plugin"
"directory": "packages/tuono-react-vite-plugin"
},
"keywords": [],
"author": "Valerio Ageno",
@@ -1,5 +1,6 @@
import type { RouteNode } from '../types'
import { spaces } from './utils'
import type { RouteNode } from './types'
export function buildRouteConfig(nodes: Array<RouteNode>, depth = 1): string {
const children = nodes.map((node) => {
@@ -3,6 +3,8 @@ import path from 'path'
import { format } from 'prettier'
import type { Config, RouteNode } from '../types'
import { buildRouteConfig } from './build-route-config'
import { hasParentRoute } from './has-parent-route'
import {
@@ -17,7 +19,6 @@ import {
removeUnderscores,
} from './utils'
import type { Config, RouteNode } from './types'
import {
ROUTES_FOLDER,
LAYOUT_PATH_ID,
@@ -26,7 +27,7 @@ import {
} from './constants'
import { sortRouteNodes } from './sort-route-nodes'
import isDefaultExported from './utils/is-default-exported'
import isDefaultExported from './is-default-exported'
let latestTask = 0
@@ -1,6 +1,7 @@
import type { RouteNode } from '../types'
import { LAYOUT_PATH_ID } from './constants'
import { multiSortBy } from './utils'
import type { RouteNode } from './types'
export function hasParentRoute(
routes: Array<RouteNode>,
@@ -1,4 +1,5 @@
import type { RouteNode } from './types'
import type { RouteNode } from '../types'
import { multiSortBy } from './utils'
import { LAYOUT_PATH_ID } from './constants'
@@ -1,4 +1,4 @@
import type { RouteNode } from './types'
import type { RouteNode } from '../types'
export function removeExt(d: string, keepExtension: boolean = false): string {
return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d
@@ -0,0 +1 @@
export { TuonoReactPlugin } from './plugin'
@@ -2,13 +2,13 @@ import { normalize } from 'node:path'
import type { Plugin } from 'vite'
import { routeGenerator } from './generator'
import { routeGenerator } from './fs-routing/generator'
const ROUTES_DIRECTORY_PATH = './src/routes'
let lock = false
export function TuonoFsRouterPlugin(): Plugin {
export function TuonoReactPlugin(): Plugin {
const generate = async (): Promise<void> => {
if (lock) return
lock = true
@@ -31,7 +31,7 @@ export function TuonoFsRouterPlugin(): Plugin {
}
return {
name: 'vite-plugin-tuono-fs-router',
name: 'vite-plugin-tuono-react',
configResolved: async (): Promise<void> => {
await generate()
},
@@ -2,7 +2,7 @@ import fs from 'fs/promises'
import { describe, it, expect } from 'vitest'
import { routeGenerator } from '../src/generator'
import { routeGenerator } from '../src/fs-routing/generator'
describe('generator works', async () => {
const folderNames = await fs.readdir(`${process.cwd()}/tests/generator`)
+1 -1
View File
@@ -71,7 +71,7 @@
"@rollup/plugin-inject": "^5.0.5",
"@vitejs/plugin-react-swc": "^3.8.0",
"fast-text-encoding": "^1.0.6",
"tuono-fs-router-vite-plugin": "workspace:*",
"tuono-react-vite-plugin": "workspace:*",
"tuono-router": "workspace:*",
"url-search-params-polyfill": "^8.2.5",
"vite": "^6.1.1",
+2 -2
View File
@@ -2,7 +2,7 @@ import type { InlineConfig, Plugin } from 'vite'
import { build, createServer, mergeConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import inject from '@rollup/plugin-inject'
import { TuonoFsRouterPlugin } from 'tuono-fs-router-vite-plugin'
import { TuonoReactPlugin } from 'tuono-react-vite-plugin'
import type { TuonoConfig } from '../config'
@@ -71,7 +71,7 @@ function createBaseViteConfigFromTuonoConfig(
// @ts-expect-error see above comment
react({ include: pluginFilesInclude }),
TuonoFsRouterPlugin(),
TuonoReactPlugin(),
],
}