This commit is contained in:
2026-05-07 02:15:20 +08:00
parent da0a6d0f81
commit ccc46844b6
141 changed files with 2358 additions and 1661 deletions

View File

@@ -29,6 +29,7 @@
"build": "pnpm run gen-index && tsc -p tsconfig.build.json && vite build"
},
"devDependencies": {
"@rollup/plugin-typescript": "^12.3.0",
"@types/node": "^25.6.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",

View File

@@ -1,26 +1,12 @@
{
// tsconfig.base.json用于被 tesconfig.json 和 tesconfig.build.json 继承
"compilerOptions": {
// 输出模块语法,使用版本号最新的那个,而不是实验性语法 ESNext
"module": "es2022",
// 模块解析策略,模拟 Vite / Rollup / webpack支持 exports / imports不强制 Node ESM 的严格规则
"moduleResolution": "bundler",
// 显式声明使用的类型包
"types": ["node", "react"],
// 允许 ESM 导入 CJS
"lib": ["ES2025", "DOM", "DOM.Iterable"],
"strict": true,
"esModuleInterop": true,
// 跳过 node_modules 类型检查,加快构建,避免第三方类型污染
"skipLibCheck": true,
/**
* JS
* - Vite / Next / Nuxt bundler
* - tsc emit
*/
"noEmit": true
"isolatedModules": true,
"verbatimModuleSyntax": true
}
}

View File

@@ -1,74 +1,12 @@
{
// 此文件仅用于类型检查,不用于类型检查,构建时会指定使用 tsconfig.build.json
"extends": "./tsconfig.base.json",
"compilerOptions": {
// Browser api需要加 "DOM""DOM.Iterable"
// Node api需要加 "ES2025",始终使用带版本号的最新版本
// NextJs api属于同构server 端会预处理 DOM计算url三个都需要 "ES2025", "DOM", "DOM.Iterable"
"lib": ["ES2025", "DOM", "DOM.Iterable"],
/**
* 使
* - nodeNode.js API
* - reactJSX / React
* - vite/clientimport.meta / env
*/
"types": ["node", "react"],
/**
* React JSX
* - 使 React 17+ JSX Transform
* - import React
*/
"jsx": "react-jsx",
/**
*
* - tsc / tsc -b
*/
"outDir": "./dist",
/**
*
* - dist src
* - declaration
*/
"rootDir": "./src",
/**
* .d.ts
* - / npm
* -
*/
"declaration": true,
/**
* JS
* - Vite / Next / Nuxt bundler
* - tsc emit
*/
"noEmit": true,
/**
*
* - esbuild / SWC / bundler
* - enum / namespace
*/
"isolatedModules": true
"jsx": "react-jsx",
"declaration": true
},
/**
*
* - src
* - exclude
*/
"include": ["src"],
/**
*
* -
* - dist / test / config
* -
*/
"exclude": [
"node_modules",
"dist",

View File

@@ -1,16 +1,8 @@
{
// 此文件仅用于类型检查,不用于构建,构建时会指定使用 tsconfig.build.json
"extends": "./tsconfig.base.json",
"compilerOptions": {
// node api 使用最新版本号的 "ESxxxx"browser api 使用 "DOM" 和 "DOM.Iterable"
"lib": ["ES2025", "DOM", "DOM.Iterable"],
//显式声明使用的类型包,避免找不到模块
"types": ["node", "react"],
// React JSX 编译模式
"jsx": "react-jsx"
"jsx": "react-jsx",
"noEmit": true
},
// 将类型检查范围扩大至整个子项目,而不只是 src 文件夹,
"include": ["**/*"]
"include": ["."]
}

View File

@@ -1,6 +1,7 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import typescript from "@rollup/plugin-typescript";
export default defineConfig({
plugins: [
@@ -9,4 +10,22 @@ export default defineConfig({
insertTypesEntry: true,
}),
],
esbuild: false,
build: {
rollupOptions: {
plugins: [typescript({ tsconfig: "./tsconfig.build.json" })],
external: ["react", "react-dom", "react/jsx-runtime"],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
},
},
},
sourcemap: true,
cssCodeSplit: true,
},
});

View File

@@ -29,6 +29,7 @@
"build": "pnpm run gen-index && tsc -p tsconfig.build.json && vite build"
},
"devDependencies": {
"@rollup/plugin-typescript": "^12.3.0",
"@types/node": "^25.6.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",

View File

@@ -1,22 +1,12 @@
{
// tsconfig.base.json用于被 tesconfig.json 和 tesconfig.build.json 继承
"compilerOptions": {
// 输出模块语法,使用版本号最新的那个,而不是实验性语法 ESNext
"module": "es2022",
// 模块解析策略,模拟 Vite / Rollup / webpack支持 exports / imports不强制 Node ESM 的严格规则
"moduleResolution": "bundler",
// 显式声明使用的类型包
"types": ["node", "react"],
// 开启所有严格类型检查,防止 any / 隐式 any 扩散
"lib": ["ES2025", "DOM", "DOM.Iterable"],
"strict": true,
// 允许 ESM 导入 CJS
"esModuleInterop": true,
// 跳过 node_modules 类型检查,加快构建,避免第三方类型污染
"skipLibCheck": true
"skipLibCheck": true,
"isolatedModules": true,
"verbatimModuleSyntax": true
}
}

View File

@@ -1,74 +1,12 @@
{
// 此文件仅用于类型检查,不用于类型检查,构建时会指定使用 tsconfig.build.json
"extends": "./tsconfig.base.json",
"compilerOptions": {
// Browser api需要加 "DOM""DOM.Iterable"
// Node api需要加 "ES2025",始终使用带版本号的最新版本
// NextJs api属于同构server 端会预处理 DOM计算url三个都需要 "ES2025", "DOM", "DOM.Iterable"
"lib": ["ES2025", "DOM", "DOM.Iterable"],
/**
* 使
* - nodeNode.js API
* - reactJSX / React
* - vite/clientimport.meta / env
*/
"types": ["node", "react"],
/**
* React JSX
* - 使 React 17+ JSX Transform
* - import React
*/
"jsx": "react-jsx",
/**
*
* - tsc / tsc -b
*/
"outDir": "./dist",
/**
*
* - dist src
* - declaration
*/
"rootDir": "./src",
/**
* .d.ts
* - / npm
* -
*/
"declaration": true,
/**
* JS
* - Vite / Next / Nuxt bundler
* - tsc emit
*/
"noEmit": true,
/**
*
* - esbuild / SWC / bundler
* - enum / namespace
*/
"isolatedModules": true
"jsx": "react-jsx",
"declaration": true
},
/**
*
* - src
* - exclude
*/
"include": ["src"],
/**
*
* -
* - dist / test / config
* -
*/
"exclude": [
"node_modules",
"dist",

View File

@@ -1,16 +1,8 @@
{
// 此文件仅用于类型检查,不用于构建,构建时会指定使用 tsconfig.build.json
"extends": "./tsconfig.base.json",
"compilerOptions": {
// node api 使用最新版本号的 "ESxxxx"browser api 使用 "DOM" 和 "DOM.Iterable"
"lib": ["ES2025", "DOM", "DOM.Iterable"],
//显式声明使用的类型包,避免找不到模块
"types": ["node", "react"],
// React JSX 编译模式
"jsx": "react-jsx"
"jsx": "react-jsx",
"noEmit": true
},
// 将类型检查范围扩大至整个子项目,而不只是 src 文件夹,
"include": ["**/*"]
"include": ["."]
}

View File

@@ -2,6 +2,7 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import path from "path";
import typescript from "@rollup/plugin-typescript";
export default defineConfig({
plugins: [
@@ -11,6 +12,8 @@ export default defineConfig({
}),
],
esbuild: false,
build: {
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
@@ -20,6 +23,7 @@ export default defineConfig({
},
rollupOptions: {
plugins: [typescript({ tsconfig: "./tsconfig.build.json" })],
external: ["react", "react-dom", "react/jsx-runtime"],
output: {
globals: {
@@ -31,9 +35,5 @@ export default defineConfig({
sourcemap: true,
cssCodeSplit: true,
watch: {
exclude: ["node_modules", "dist", ".git"],
},
},
});