mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
refactor: turn tuono-fs-router-vite-plugin into tuono-react-vite-plugin (#756)
This commit is contained in:
+1
-2
@@ -31,7 +31,7 @@ const tuonoEslintConfig = tseslint.config(
|
||||
// #endregion shared
|
||||
|
||||
// #region package-specific
|
||||
'packages/tuono-fs-router-vite-plugin/tests/generator/**',
|
||||
'packages/tuono-react-vite-plugin/tests/generator/**',
|
||||
|
||||
'packages/tuono-lazy-fn-vite-plugin/tests/sources/**',
|
||||
|
||||
@@ -69,7 +69,6 @@ const tuonoEslintConfig = tseslint.config(
|
||||
{
|
||||
files: [REACT_FILES_MATCH],
|
||||
plugins: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
'react-hooks': eslintPluginReactHooks,
|
||||
},
|
||||
rules: {
|
||||
|
||||
+2
-2
@@ -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",
|
||||
+2
-1
@@ -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
-2
@@ -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
|
||||
|
||||
+2
-1
@@ -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>,
|
||||
+2
-1
@@ -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
-1
@@ -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'
|
||||
+3
-3
@@ -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()
|
||||
},
|
||||
+1
-1
@@ -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`)
|
||||
@@ -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,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(),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
Generated
+3
-3
@@ -208,9 +208,9 @@ importers:
|
||||
fast-text-encoding:
|
||||
specifier: ^1.0.6
|
||||
version: 1.0.6
|
||||
tuono-fs-router-vite-plugin:
|
||||
tuono-react-vite-plugin:
|
||||
specifier: workspace:*
|
||||
version: link:../tuono-fs-router-vite-plugin
|
||||
version: link:../tuono-react-vite-plugin
|
||||
tuono-router:
|
||||
specifier: workspace:*
|
||||
version: link:../tuono-router
|
||||
@@ -252,7 +252,7 @@ importers:
|
||||
specifier: 3.1.1
|
||||
version: 3.1.1(@types/debug@4.1.12)(@types/node@22.14.1)(happy-dom@17.4.4)(jiti@2.4.2)(lightningcss@1.29.1)(sugarss@4.0.1(postcss@8.5.3))
|
||||
|
||||
packages/tuono-fs-router-vite-plugin:
|
||||
packages/tuono-react-vite-plugin:
|
||||
dependencies:
|
||||
'@babel/core':
|
||||
specifier: ^7.24.4
|
||||
|
||||
Reference in New Issue
Block a user