mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
chore: add internal vite config (#568)
This commit is contained in:
committed by
GitHub
parent
d37b655add
commit
12e0937174
@@ -28,7 +28,7 @@ jobs:
|
||||
uses: ./.github/actions/install-node-dependencies
|
||||
|
||||
- name: Test project
|
||||
run: pnpm repo:root:format:check
|
||||
run: pnpm repo:root:format
|
||||
|
||||
ci_ok:
|
||||
name: Repo root CI OK
|
||||
|
||||
@@ -51,13 +51,13 @@ jobs:
|
||||
uses: ./.github/actions/install-node-dependencies
|
||||
|
||||
- name: Check formatting
|
||||
run: pnpm format:check
|
||||
run: pnpm run format
|
||||
|
||||
- name: Lint
|
||||
run: pnpm lint
|
||||
run: pnpm run lint
|
||||
|
||||
- name: Types
|
||||
run: pnpm types
|
||||
- name: Typecheck
|
||||
run: pnpm run typecheck
|
||||
|
||||
ci_ok:
|
||||
name: Typescript CI OK
|
||||
|
||||
@@ -6,3 +6,5 @@ dist
|
||||
vite.config.ts.timestamp-*
|
||||
|
||||
packages/tuono-lazy-fn-vite-plugin/tests/sources/*
|
||||
|
||||
e2e/fixtures/*/test-results
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "vite-config",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"format:fix": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"types": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"oxc-transform": "0.50.0",
|
||||
"rollup-plugin-preserve-directives": "0.4.0",
|
||||
"unplugin-isolated-decl": "0.11.0",
|
||||
"vite": "5.4.14",
|
||||
"vite-plugin-externalize-deps": "0.9.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { UserConfig } from 'vite'
|
||||
import { preserveDirectives } from 'rollup-plugin-preserve-directives'
|
||||
import { externalizeDeps } from 'vite-plugin-externalize-deps'
|
||||
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/vite'
|
||||
|
||||
interface Options {
|
||||
/** Entry file, e.g. `./src/index.ts` */
|
||||
entry: string | Array<string>
|
||||
}
|
||||
|
||||
export function defineViteConfig({ entry }: Options): UserConfig {
|
||||
const outDir = 'dist'
|
||||
|
||||
return {
|
||||
build: {
|
||||
outDir,
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
lib: {
|
||||
entry,
|
||||
formats: ['es'],
|
||||
fileName: 'esm/[name]',
|
||||
},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
preserveModules: true,
|
||||
entryFileNames: 'esm/[name].js',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
externalizeDeps(),
|
||||
preserveDirectives(),
|
||||
UnpluginIsolatedDecl({ transformer: 'oxc' }),
|
||||
],
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src"],
|
||||
"compilerOptions": {
|
||||
// Modules
|
||||
"moduleResolution": "node16",
|
||||
"module": "Node16",
|
||||
|
||||
// Emit
|
||||
"noEmit": false,
|
||||
"declaration": true,
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
+14
-5
@@ -6,6 +6,9 @@ import eslintPluginReact from 'eslint-plugin-react'
|
||||
// @ts-expect-error no types are available for this plugin
|
||||
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
|
||||
|
||||
const REACT_FILES_MATCH =
|
||||
'packages/{tuono,tuono-router}/**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'
|
||||
|
||||
/** @type import('typescript-eslint').ConfigArray */
|
||||
const tuonoEslintConfig = tseslint.config(
|
||||
{
|
||||
@@ -44,12 +47,17 @@ const tuonoEslintConfig = tseslint.config(
|
||||
// eslint-disable-next-line import/no-named-as-default-member
|
||||
tseslint.configs.strictTypeChecked,
|
||||
|
||||
// @ts-expect-error flat is optional but always defined on runtime
|
||||
eslintPluginReact.configs.flat.recommended,
|
||||
eslintPluginReact.configs.flat['jsx-runtime'],
|
||||
|
||||
// #region react
|
||||
{
|
||||
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
|
||||
files: [REACT_FILES_MATCH],
|
||||
...eslintPluginReact.configs.flat.recommended,
|
||||
},
|
||||
{
|
||||
files: [REACT_FILES_MATCH],
|
||||
...eslintPluginReact.configs.flat['jsx-runtime'],
|
||||
},
|
||||
{
|
||||
files: [REACT_FILES_MATCH],
|
||||
plugins: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
'react-hooks': eslintPluginReactHooks,
|
||||
@@ -59,6 +67,7 @@ const tuonoEslintConfig = tseslint.config(
|
||||
'react-hooks/exhaustive-deps': 'error',
|
||||
},
|
||||
},
|
||||
// #endregion react
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
|
||||
+12
-12
@@ -4,26 +4,26 @@
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
|
||||
"scripts": {
|
||||
"dev": "turbo dev --filter=./packages/*",
|
||||
"build": "turbo build --filter=./packages/*",
|
||||
"lint": "turbo lint --filter=./packages/*",
|
||||
"format": "turbo format --filter=./packages/*",
|
||||
"format:check": "turbo format:check --filter=./packages/*",
|
||||
"types": "turbo types --filter=./packages/*",
|
||||
"test": "turbo test --filter=./packages/*",
|
||||
"test:watch": "turbo test:watch --filter=./packages/*",
|
||||
"dev": "turbo dev --filter=./devtools/* --filter=./packages/*",
|
||||
"build": "turbo build --filter=./devtools/* --filter=./packages/*",
|
||||
"lint": "turbo lint --filter=./devtools/* --filter=./packages/*",
|
||||
"format:fix": "turbo format --filter=./devtools/* --filter=./packages/*",
|
||||
"format": "turbo format --filter=./devtools/* --filter=./packages/*",
|
||||
"typecheck": "turbo typecheck --filter=./devtools/* --filter=./packages/*",
|
||||
"test": "turbo test --filter=./devtools/* --filter=./packages/*",
|
||||
"test:watch": "turbo test:watch --filter=./devtools/* --filter=./packages/*",
|
||||
"test:e2e": "pnpm --filter='fixture-*' run test:e2e",
|
||||
"repo:root:format:check": "prettier . !./assets/** !./crates !./examples !./packages/** --check",
|
||||
"repo:root:format": "prettier . !./assets/** !./crates !./examples !./packages/** --write",
|
||||
"check-all": "turbo build lint format:check types --filter=!./examples"
|
||||
"repo:root:format": "prettier . !./assets/** !./crates !./examples !./devtools/** !./packages/** --check",
|
||||
"repo:root:format:fix": "prettier . !./assets/** !./crates !./examples !./devtools/** !./packages/** --write",
|
||||
"check-all": "turbo build lint format types --filter=!./examples"
|
||||
},
|
||||
"author": "Valerio Ageno",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "9.20.0",
|
||||
"@playwright/test": "1.50.1",
|
||||
"@types/node": "22.13.1",
|
||||
"eslint": "9.20.0",
|
||||
"@playwright/test": "^1.50.1",
|
||||
"eslint-import-resolver-typescript": "3.7.0",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-react": "7.37.4",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"dev": "vite build --watch",
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"format:check": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"types": "tsc --noEmit",
|
||||
"format": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"format:fix": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test:watch": "vitest",
|
||||
"test": "vitest run"
|
||||
},
|
||||
@@ -23,7 +23,7 @@
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"main": "dist/cjs/index.cjs",
|
||||
"main": "dist/esm/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -32,14 +32,8 @@
|
||||
],
|
||||
"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"
|
||||
}
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
@@ -50,8 +44,8 @@
|
||||
"vite": "^5.4.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tanstack/config": "0.7.13",
|
||||
"@types/babel__core": "7.20.5",
|
||||
"vite-config": "workspace:*",
|
||||
"vitest": "2.1.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,9 @@ async function getRouteNodes(
|
||||
return { routeNodes, rustHandlersNodes }
|
||||
}
|
||||
|
||||
export async function routeGenerator(config = defaultConfig): Promise<void> {
|
||||
export async function routeGenerator(
|
||||
config: Config = defaultConfig,
|
||||
): Promise<void> {
|
||||
if (!isFirst) {
|
||||
isFirst = true
|
||||
} else if (skipMessage) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { normalize } from 'path'
|
||||
import { normalize } from 'node:path'
|
||||
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import { defineConfig, mergeConfig } from 'vitest/config'
|
||||
import { tanstackBuildConfig } from '@tanstack/config/build'
|
||||
import { defineViteConfig } from 'vite-config'
|
||||
|
||||
const config = defineConfig({})
|
||||
|
||||
export default mergeConfig(
|
||||
config,
|
||||
tanstackBuildConfig({
|
||||
entry: './src/index.ts',
|
||||
srcDir: './src',
|
||||
}),
|
||||
)
|
||||
export default defineViteConfig({
|
||||
entry: './src/index.ts',
|
||||
})
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"dev": "vite build --watch",
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"format:check": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"types": "tsc --noEmit",
|
||||
"format": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"format:fix": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test:watch": "vitest",
|
||||
"test": "vitest run"
|
||||
},
|
||||
@@ -23,7 +23,7 @@
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"main": "dist/cjs/index.cjs",
|
||||
"main": "dist/esm/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -32,14 +32,8 @@
|
||||
],
|
||||
"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"
|
||||
}
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
@@ -50,13 +44,13 @@
|
||||
"react-intersection-observer": "^9.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tanstack/config": "0.7.13",
|
||||
"@testing-library/react": "16.2.0",
|
||||
"@types/react": "19.0.8",
|
||||
"@vitejs/plugin-react-swc": "3.7.2",
|
||||
"happy-dom": "16.8.1",
|
||||
"react": "19.0.0",
|
||||
"vite": "5.4.14",
|
||||
"vite-config": "workspace:*",
|
||||
"vitest": "2.1.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export class Router {
|
||||
basePath = '/'
|
||||
routeTree?: RouteTree
|
||||
|
||||
isServer = typeof document === 'undefined'
|
||||
isServer: boolean = typeof document === 'undefined'
|
||||
|
||||
routesById: Record<string, Route> = {}
|
||||
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
/// <reference types="vitest" />
|
||||
/// <reference types="vite/client" />
|
||||
import { defineConfig, mergeConfig } from 'vitest/config'
|
||||
import { tanstackBuildConfig } from '@tanstack/config/build'
|
||||
import { defineViteConfig } from 'vite-config'
|
||||
import react from '@vitejs/plugin-react-swc'
|
||||
|
||||
const config = defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
name: 'tuono-router',
|
||||
environment: 'happy-dom',
|
||||
globals: true,
|
||||
},
|
||||
})
|
||||
|
||||
export default mergeConfig(
|
||||
config,
|
||||
tanstackBuildConfig({
|
||||
defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
name: 'tuono-router',
|
||||
environment: 'happy-dom',
|
||||
globals: true,
|
||||
},
|
||||
}),
|
||||
defineViteConfig({
|
||||
entry: './src/index.ts',
|
||||
srcDir: './src',
|
||||
}),
|
||||
)
|
||||
|
||||
+16
-46
@@ -7,9 +7,9 @@
|
||||
"dev": "vite build --watch",
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"format:check": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"types": "tsc --noEmit",
|
||||
"format": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"format:fix": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test:watch": "vitest",
|
||||
"test": "vitest run"
|
||||
},
|
||||
@@ -20,58 +20,28 @@
|
||||
},
|
||||
"type": "module",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"main": "dist/cjs/index.cjs",
|
||||
"main": "dist/esm/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"exports": {
|
||||
"./build": {
|
||||
"import": {
|
||||
"types": "./dist/esm/build/index.d.ts",
|
||||
"default": "./dist/esm/build/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/build/index.d.ts",
|
||||
"default": "./dist/cjs/build/index.js"
|
||||
}
|
||||
"types": "./dist/esm/build/index.d.ts",
|
||||
"default": "./dist/esm/build/index.js"
|
||||
},
|
||||
"./config": {
|
||||
"import": {
|
||||
"types": "./dist/esm/config/index.d.ts",
|
||||
"default": "./dist/esm/config/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/config/index.d.ts",
|
||||
"default": "./dist/cjs/config/index.js"
|
||||
}
|
||||
"types": "./dist/esm/config/index.d.ts",
|
||||
"default": "./dist/esm/config/index.js"
|
||||
},
|
||||
"./ssr": {
|
||||
"import": {
|
||||
"types": "./dist/esm/ssr/index.d.ts",
|
||||
"default": "./dist/esm/ssr/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/ssr/index.d.ts",
|
||||
"default": "./dist/cjs/ssr/index.js"
|
||||
}
|
||||
"types": "./dist/esm/ssr/index.d.ts",
|
||||
"default": "./dist/esm/ssr/index.js"
|
||||
},
|
||||
"./hydration": {
|
||||
"import": {
|
||||
"types": "./dist/esm/hydration/index.d.ts",
|
||||
"default": "./dist/esm/hydration/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/ssr/index.d.ts",
|
||||
"default": "./dist/cjs/ssr/index.js"
|
||||
}
|
||||
"types": "./dist/esm/hydration/index.d.ts",
|
||||
"default": "./dist/esm/hydration/index.js"
|
||||
},
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
}
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
@@ -105,7 +75,6 @@
|
||||
"web-streams-polyfill": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tanstack/config": "0.7.13",
|
||||
"@types/babel__core": "7.20.5",
|
||||
"@types/babel__traverse": "7.20.6",
|
||||
"@types/node": "22.13.1",
|
||||
@@ -113,7 +82,8 @@
|
||||
"@types/react-dom": "19.0.3",
|
||||
"react": "19.0.0",
|
||||
"react-dom": "19.0.0",
|
||||
"vitest": "2.1.9"
|
||||
"vitest": "2.1.9",
|
||||
"vite-config": "workspace:*"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
/// <reference types="vitest" />
|
||||
/// <reference types="vite/client" />
|
||||
import { defineConfig, mergeConfig } from 'vitest/config'
|
||||
import { tanstackBuildConfig } from '@tanstack/config/build'
|
||||
import { defineViteConfig } from 'vite-config'
|
||||
import react from '@vitejs/plugin-react-swc'
|
||||
|
||||
const config = defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
|
||||
export default mergeConfig(
|
||||
config,
|
||||
tanstackBuildConfig({
|
||||
defineConfig({
|
||||
plugins: [react()],
|
||||
}),
|
||||
defineViteConfig({
|
||||
entry: [
|
||||
'./src/index.ts',
|
||||
'./src/build/index.ts',
|
||||
@@ -18,6 +16,5 @@ export default mergeConfig(
|
||||
'./src/ssr/index.ts',
|
||||
'./src/hydration/index.tsx',
|
||||
],
|
||||
srcDir: './src',
|
||||
}),
|
||||
)
|
||||
|
||||
Generated
+252
-1063
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
packages:
|
||||
- 'devtools/*'
|
||||
- 'packages/*'
|
||||
- 'examples/*'
|
||||
- 'e2e/fixtures/*'
|
||||
|
||||
+5
-3
@@ -6,12 +6,14 @@
|
||||
"dependsOn": ["^build"]
|
||||
},
|
||||
"format": {},
|
||||
"format:check": {},
|
||||
"types": {
|
||||
"format:fix": {},
|
||||
"typecheck": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputLogs": "new-only"
|
||||
},
|
||||
"test": {},
|
||||
"test": {
|
||||
"dependsOn": ["^build"]
|
||||
},
|
||||
"test:watch": {},
|
||||
"build": {
|
||||
"outputs": ["dist/**"],
|
||||
|
||||
Reference in New Issue
Block a user