@4399ywkf/core 5.0.25 → 5.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { Y as YwkfConfig } from '../schema-CGQSqjRr.js';
2
- export { D as DevServerConfig, E as EnvConfig, H as HtmlConfig, M as MicroFrontendConfig, O as OutputConfig, P as PerformanceConfig, R as RouterConfig, S as StyleConfig, T as ToolsConfig, d as defaultConfig, a as defineConfig } from '../schema-CGQSqjRr.js';
1
+ import { Y as YwkfConfig } from '../schema-runIYOB7.js';
2
+ export { D as DevServerConfig, E as EnvConfig, H as HtmlConfig, M as MicroFrontendConfig, O as OutputConfig, P as PerformanceConfig, R as RouterConfig, S as StyleConfig, T as ToolsConfig, d as defaultConfig, a as defineConfig } from '../schema-runIYOB7.js';
3
3
  import '@rspack/core';
4
4
  import '../types-DbUq-VY8.js';
5
5
  import 'react';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/loader.ts","../../src/config/schema.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport deepmerge from \"deepmerge\";\nimport { defaultConfig, type YwkfConfig } from \"./schema.js\";\n\n/** 支持的配置文件名 */\nconst CONFIG_FILES = [\"ywkf.config.ts\", \"ywkf.config.mts\", \"ywkf.config.js\", \"ywkf.config.mjs\"];\n\n/**\n * 查找配置文件\n */\nexport function findConfigFile(cwd: string): string | null {\n for (const file of CONFIG_FILES) {\n const configPath = resolve(cwd, file);\n if (existsSync(configPath)) {\n return configPath;\n }\n }\n return null;\n}\n\n/**\n * 加载 TypeScript 配置文件\n */\nasync function loadTsConfig(configPath: string): Promise<YwkfConfig> {\n const jiti = (await import(\"jiti\")).default;\n const loader = jiti(configPath, {\n interopDefault: true,\n });\n\n const config = loader(configPath);\n return config.default || config;\n}\n\n/**\n * 加载 JavaScript 配置文件\n */\nasync function loadJsConfig(configPath: string): Promise<YwkfConfig> {\n const fileUrl = pathToFileURL(configPath).href;\n const module = await import(fileUrl);\n return module.default || module;\n}\n\n/**\n * 加载配置文件\n */\nexport async function loadConfigFile(configPath: string): Promise<YwkfConfig> {\n const ext = extname(configPath);\n\n if (ext === \".ts\" || ext === \".mts\") {\n return loadTsConfig(configPath);\n }\n\n return loadJsConfig(configPath);\n}\n\n/**\n * 合并配置\n */\nexport function mergeConfig(\n userConfig: YwkfConfig,\n baseConfig: YwkfConfig = defaultConfig,\n): Required<YwkfConfig> {\n return deepmerge(baseConfig, userConfig, {\n arrayMerge: (_, sourceArray) => sourceArray,\n }) as Required<YwkfConfig>;\n}\n\n/**\n * 解析并加载完整配置\n * @param cwd 工作目录\n * @returns 合并后的完整配置\n */\nexport async function resolveConfig(cwd: string): Promise<{\n config: Required<YwkfConfig>;\n configPath: string | null;\n}> {\n const configPath = findConfigFile(cwd);\n\n if (!configPath) {\n console.warn(\"⚠️ 未找到配置文件 (ywkf.config.ts),使用默认配置\");\n return {\n config: defaultConfig as Required<YwkfConfig>,\n configPath: null,\n };\n }\n\n try {\n const userConfig = await loadConfigFile(configPath);\n const config = mergeConfig(userConfig);\n\n return { config, configPath };\n } catch (error) {\n console.error(\"❌ 配置文件加载失败:\", error);\n throw error;\n }\n}\n\n/**\n * 获取应用路径解析器\n */\nexport function createPathResolver(cwd: string) {\n return {\n resolveApp: (relativePath: string) => resolve(cwd, relativePath),\n cwd,\n };\n}\n","import type { Configuration as RspackConfig } from \"@rspack/core\";\nimport type { PluginConfig } from \"../plugin/types.js\";\n\n/**\n * 开发服务器配置\n */\nexport interface DevServerConfig {\n /** 开发服务器端口 */\n port?: number;\n /** 开发服务器主机 */\n host?: string;\n /** 代理配置 */\n proxy?: Record<string, string | object>;\n /** 是否开启 HTTPS */\n https?: boolean;\n}\n\n/**\n * 输出配置\n */\nexport interface OutputConfig {\n /** 输出目录 */\n path?: string;\n /** 公共路径 */\n publicPath?: string;\n /** 是否清理输出目录 */\n clean?: boolean;\n}\n\n/**\n * HTML 配置\n */\nexport interface HtmlConfig {\n /** 页面标题 */\n title?: string;\n /** HTML 模板路径 */\n template?: string;\n /** favicon 路径 */\n favicon?: string;\n /** 挂载根元素 ID */\n mountRoot?: string;\n}\n\n/**\n * 样式配置\n */\nexport interface StyleConfig {\n /** 是否启用 CSS Modules */\n cssModules?: boolean;\n /** Less 配置 */\n less?: {\n /** 是否启用 */\n enabled?: boolean;\n /** Less 选项 */\n lessOptions?: Record<string, unknown>;\n };\n /** Sass 配置 */\n sass?: {\n /** 是否启用 */\n enabled?: boolean;\n /** Sass 选项 */\n sassOptions?: Record<string, unknown>;\n };\n /** 是否启用 TailwindCSS */\n tailwindcss?: boolean;\n}\n\n/**\n * 路由配置\n */\nexport interface RouterConfig {\n /** 路由基础路径 */\n basename?: string;\n /** 是否启用约定式路由 */\n conventional?: boolean;\n /** 约定式路由扫描目录 */\n pagesDir?: string;\n /** 排除的文件/目录模式 */\n exclude?: (string | RegExp)[];\n}\n\n/**\n * 微前端配置\n */\nexport interface MicroFrontendConfig {\n /** 是否启用微前端模式 */\n enabled?: boolean;\n /** 应用名称(用于 UMD 导出) */\n name?: string;\n /** 微前端框架类型 */\n framework?: \"qiankun\" | \"garfish\";\n}\n\n/**\n * 性能配置\n */\nexport interface PerformanceConfig {\n /** 是否启用 Rsdoctor 分析 */\n rsdoctor?: boolean;\n /** 是否开启代码分割 */\n splitChunks?: boolean;\n /** 是否移除 console */\n dropConsole?: boolean;\n}\n\n/**\n * 工具链配置\n */\nexport interface ToolsConfig {\n /**\n * 自定义 Rspack 配置\n * @param config 当前配置\n * @param context 上下文信息\n * @returns 修改后的配置\n */\n rspack?: (\n config: RspackConfig,\n context: { isDev: boolean; isProd: boolean },\n ) => RspackConfig | undefined;\n}\n\n/**\n * 环境变量配置\n */\nexport interface EnvConfig {\n /** 公共环境变量文件路径 */\n publicEnvFile?: string;\n /** 环境特定的变量文件目录 */\n envDir?: string;\n}\n\n/**\n * 框架完整配置\n */\nexport interface YwkfConfig {\n /** 应用名称 */\n appName?: string;\n /** 应用中文名 */\n appCName?: string;\n /** 开发服务器配置 */\n dev?: DevServerConfig;\n /** 输出配置 */\n output?: OutputConfig;\n /** HTML 配置 */\n html?: HtmlConfig;\n /** 样式配置 */\n style?: StyleConfig;\n /** 路由配置 */\n router?: RouterConfig;\n /** 微前端配置 */\n microFrontend?: MicroFrontendConfig;\n /** 性能配置 */\n performance?: PerformanceConfig;\n /** 工具链配置 */\n tools?: ToolsConfig;\n /** 环境变量配置 */\n env?: EnvConfig;\n /** 路径别名 */\n alias?: Record<string, string>;\n /** 插件列表 */\n plugins?: PluginConfig[];\n}\n\n/**\n * 定义配置的辅助函数(提供类型提示)\n */\nexport function defineConfig(config: YwkfConfig): YwkfConfig {\n return config;\n}\n\n/**\n * 默认配置\n */\nexport const defaultConfig: Required<YwkfConfig> = {\n appName: \"app\",\n appCName: \"应用\",\n dev: {\n port: 3000,\n host: \"localhost\",\n proxy: {},\n https: false,\n },\n output: {\n path: \"dist\",\n publicPath: \"/\",\n clean: true,\n },\n html: {\n title: \"应用\",\n template: \"public/index.html\",\n favicon: \"public/favicon.ico\",\n mountRoot: \"root\",\n },\n style: {\n cssModules: true,\n less: { enabled: true, lessOptions: { javascriptEnabled: true } },\n sass: { enabled: true, sassOptions: {} },\n tailwindcss: true,\n },\n router: {\n basename: \"/\",\n conventional: false,\n pagesDir: \"src/pages\",\n exclude: [\n /\\/components?\\//,\n /\\/models\\//,\n /\\/utils?\\//,\n /^_/,\n /\\.d\\.ts$/,\n /\\.(test|spec|e2e)\\.(ts|tsx|js|jsx)$/,\n ],\n },\n microFrontend: {\n enabled: false,\n name: \"app\",\n framework: \"qiankun\",\n },\n performance: {\n rsdoctor: false,\n splitChunks: true,\n dropConsole: false,\n },\n tools: {},\n env: {\n publicEnvFile: \"config/env/.env.public\",\n envDir: \"config/env\",\n },\n alias: {},\n plugins: [],\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SA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/config/schema.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport deepmerge from \"deepmerge\";\nimport { defaultConfig, type YwkfConfig } from \"./schema.js\";\n\n/** 支持的配置文件名 */\nconst CONFIG_FILES = [\"ywkf.config.ts\", \"ywkf.config.mts\", \"ywkf.config.js\", \"ywkf.config.mjs\"];\n\n/**\n * 查找配置文件\n */\nexport function findConfigFile(cwd: string): string | null {\n for (const file of CONFIG_FILES) {\n const configPath = resolve(cwd, file);\n if (existsSync(configPath)) {\n return configPath;\n }\n }\n return null;\n}\n\n/**\n * 加载 TypeScript 配置文件\n */\nasync function loadTsConfig(configPath: string): Promise<YwkfConfig> {\n const jiti = (await import(\"jiti\")).default;\n const loader = jiti(configPath, {\n interopDefault: true,\n });\n\n const config = loader(configPath);\n return config.default || config;\n}\n\n/**\n * 加载 JavaScript 配置文件\n */\nasync function loadJsConfig(configPath: string): Promise<YwkfConfig> {\n const fileUrl = pathToFileURL(configPath).href;\n const module = await import(fileUrl);\n return module.default || module;\n}\n\n/**\n * 加载配置文件\n */\nexport async function loadConfigFile(configPath: string): Promise<YwkfConfig> {\n const ext = extname(configPath);\n\n if (ext === \".ts\" || ext === \".mts\") {\n return loadTsConfig(configPath);\n }\n\n return loadJsConfig(configPath);\n}\n\n/**\n * 合并配置\n */\nexport function mergeConfig(\n userConfig: YwkfConfig,\n baseConfig: YwkfConfig = defaultConfig,\n): Required<YwkfConfig> {\n return deepmerge(baseConfig, userConfig, {\n arrayMerge: (_, sourceArray) => sourceArray,\n }) as Required<YwkfConfig>;\n}\n\n/**\n * 解析并加载完整配置\n * @param cwd 工作目录\n * @returns 合并后的完整配置\n */\nexport async function resolveConfig(cwd: string): Promise<{\n config: Required<YwkfConfig>;\n configPath: string | null;\n}> {\n const configPath = findConfigFile(cwd);\n\n if (!configPath) {\n console.warn(\"⚠️ 未找到配置文件 (ywkf.config.ts),使用默认配置\");\n return {\n config: defaultConfig as Required<YwkfConfig>,\n configPath: null,\n };\n }\n\n try {\n const userConfig = await loadConfigFile(configPath);\n const config = mergeConfig(userConfig);\n\n return { config, configPath };\n } catch (error) {\n console.error(\"❌ 配置文件加载失败:\", error);\n throw error;\n }\n}\n\n/**\n * 获取应用路径解析器\n */\nexport function createPathResolver(cwd: string) {\n return {\n resolveApp: (relativePath: string) => resolve(cwd, relativePath),\n cwd,\n };\n}\n","import type { Configuration as RspackConfig } from \"@rspack/core\";\nimport type { PluginConfig } from \"../plugin/types.js\";\n\n/**\n * 开发服务器配置\n */\nexport interface DevServerConfig {\n /** 开发服务器端口 */\n port?: number;\n /** 开发服务器主机 */\n host?: string;\n /** 代理配置 */\n proxy?: Record<string, string | object>;\n /** 是否开启 HTTPS */\n https?: boolean;\n}\n\n/**\n * 输出配置\n */\nexport interface OutputConfig {\n /** 输出目录 */\n path?: string;\n /** 公共路径 */\n publicPath?: string;\n /** 是否清理输出目录 */\n clean?: boolean;\n}\n\n/**\n * HTML 配置\n */\nexport interface HtmlConfig {\n /** 页面标题 */\n title?: string;\n /** HTML 模板路径 */\n template?: string;\n /** favicon 路径 */\n favicon?: string;\n /** 挂载根元素 ID */\n mountRoot?: string;\n}\n\n/**\n * 样式配置\n */\nexport interface StyleConfig {\n /** 是否启用 CSS Modules */\n cssModules?: boolean;\n /** Less 配置 */\n less?: {\n /** 是否启用 */\n enabled?: boolean;\n /** Less 选项 */\n lessOptions?: Record<string, unknown>;\n };\n /** Sass 配置 */\n sass?: {\n /** 是否启用 */\n enabled?: boolean;\n /** Sass 选项 */\n sassOptions?: Record<string, unknown>;\n };\n /** 是否启用 TailwindCSS */\n tailwindcss?: boolean;\n}\n\n/**\n * 路由配置\n */\nexport interface RouterConfig {\n /** 路由基础路径 */\n basename?: string;\n /** 是否启用约定式路由 */\n conventional?: boolean;\n /** 约定式路由扫描目录 */\n pagesDir?: string;\n /** 排除的文件/目录模式 */\n exclude?: (string | RegExp)[];\n /**\n * 懒加载的加载状态配置\n * - `false`:禁用全局默认加载状态(各路由仍可通过 loading.tsx 单独配置)\n * - `{ component: string }`:自定义全局默认加载组件的导入路径\n * - 不配置:使用内置默认加载组件\n *\n * @example\n * // 禁用加载状态\n * loading: false\n *\n * @example\n * // 自定义加载组件\n * loading: { component: \"@/components/Loading\" }\n */\n loading?: false | { component: string };\n}\n\n/**\n * 微前端配置\n */\nexport interface MicroFrontendConfig {\n /** 是否启用微前端模式 */\n enabled?: boolean;\n /** 应用名称(用于 UMD 导出) */\n name?: string;\n /** 微前端框架类型 */\n framework?: \"qiankun\" | \"garfish\";\n}\n\n/**\n * 性能配置\n */\nexport interface PerformanceConfig {\n /** 是否启用 Rsdoctor 分析 */\n rsdoctor?: boolean;\n /** 是否开启代码分割 */\n splitChunks?: boolean;\n /** 是否移除 console */\n dropConsole?: boolean;\n}\n\n/**\n * 工具链配置\n */\nexport interface ToolsConfig {\n /**\n * 自定义 Rspack 配置\n * @param config 当前配置\n * @param context 上下文信息\n * @returns 修改后的配置\n */\n rspack?: (\n config: RspackConfig,\n context: { isDev: boolean; isProd: boolean },\n ) => RspackConfig | undefined;\n}\n\n/**\n * 环境变量配置\n */\nexport interface EnvConfig {\n /** 公共环境变量文件路径 */\n publicEnvFile?: string;\n /** 环境特定的变量文件目录 */\n envDir?: string;\n}\n\n/**\n * 框架完整配置\n */\nexport interface YwkfConfig {\n /** 应用名称 */\n appName?: string;\n /** 应用中文名 */\n appCName?: string;\n /** 开发服务器配置 */\n dev?: DevServerConfig;\n /** 输出配置 */\n output?: OutputConfig;\n /** HTML 配置 */\n html?: HtmlConfig;\n /** 样式配置 */\n style?: StyleConfig;\n /** 路由配置 */\n router?: RouterConfig;\n /** 微前端配置 */\n microFrontend?: MicroFrontendConfig;\n /** 性能配置 */\n performance?: PerformanceConfig;\n /** 工具链配置 */\n tools?: ToolsConfig;\n /** 环境变量配置 */\n env?: EnvConfig;\n /** 路径别名 */\n alias?: Record<string, string>;\n /** 插件列表 */\n plugins?: PluginConfig[];\n}\n\n/**\n * 定义配置的辅助函数(提供类型提示)\n */\nexport function defineConfig(config: YwkfConfig): YwkfConfig {\n return config;\n}\n\n/**\n * 默认配置\n */\nexport const defaultConfig: Required<YwkfConfig> = {\n appName: \"app\",\n appCName: \"应用\",\n dev: {\n port: 3000,\n host: \"localhost\",\n proxy: {},\n https: false,\n },\n output: {\n path: \"dist\",\n publicPath: \"/\",\n clean: true,\n },\n html: {\n title: \"应用\",\n template: \"public/index.html\",\n favicon: \"public/favicon.ico\",\n mountRoot: \"root\",\n },\n style: {\n cssModules: true,\n less: { enabled: true, lessOptions: { javascriptEnabled: true } },\n sass: { enabled: true, sassOptions: {} },\n tailwindcss: true,\n },\n router: {\n basename: \"/\",\n conventional: false,\n pagesDir: \"src/pages\",\n exclude: [\n /\\/components?\\//,\n /\\/models\\//,\n /\\/utils?\\//,\n /^_/,\n /\\.d\\.ts$/,\n /\\.(test|spec|e2e)\\.(ts|tsx|js|jsx)$/,\n ],\n },\n microFrontend: {\n enabled: false,\n name: \"app\",\n framework: \"qiankun\",\n },\n performance: {\n rsdoctor: false,\n splitChunks: true,\n dropConsole: false,\n },\n tools: {},\n env: {\n publicEnvFile: \"config/env/.env.public\",\n envDir: \"config/env\",\n },\n alias: {},\n plugins: [],\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;AAC9B,OAAO,eAAe;;;ACkLf,SAAS,aAAa,QAAgC;AAC3D,SAAO;AACT;AAKO,IAAM,gBAAsC;AAAA,EACjD,SAAS;AAAA,EACT,UAAU;AAAA,EACV,KAAK;AAAA,IACH,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO,CAAC;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IAC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AW;AAC3B;AAKA,eAAsB,eAAe,YAAyC;AAC5E,QAAM,MAAM,QAAQ,UAAU;AAE9B,MAAI,QAAQ,SAAS,QAAQ,QAAQ;AACnC,WAAO,aAAa,UAAU;AAAA,EAChC;AAEA,SAAO,aAAa,UAAU;AAChC;AAKO,SAAS,YACd,YACA,aAAyB,eACH;AACtB,SAAO,UAAU,YAAY,YAAY;AAAA,IACvC,YAAY,CAAC,GAAG,gBAAgB;AAAA,EAClC,CAAC;AACH;AAOA,eAAsB,cAAc,KAGjC;AACD,QAAM,aAAa,eAAe,GAAG;AAErC,MAAI,CAAC,YAAY;AACf,YAAQ,KAAK,qHAAqC;AAClD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,YAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI;AACF,UAAM,aAAa,MAAM,eAAe,UAAU;AAClD,UAAM,SAAS,YAAY,UAAU;AAErC,WAAO,EAAE,QAAQ,WAAW;AAAA,EAC9B,SAAS,OAAO;AACd,YAAQ,MAAM,4DAAe,KAAK;AAClC,UAAM;AAAA,EACR;AACF;AAKO,SAAS,mBAAmB,KAAa;AAC9C,SAAO;AAAA,IACL,YAAY,CAAC,iBAAyB,QAAQ,KAAK,YAAY;AAAA,IAC/D;AAAA,EACF;AACF;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GeneratorContext, b as PluginHooks, Y as YwkfConfig, c as PluginConfig, e as YwkfPlugin } from './schema-CGQSqjRr.js';
2
- export { B as BuildHooks, C as CodeInjection, D as DevServerConfig, E as EnvConfig, f as GeneratedFile, g as GeneratorHooks, H as HtmlConfig, M as MicroFrontendConfig, O as OutputConfig, P as PerformanceConfig, h as PluginContext, R as RouterConfig, i as RouterHooks, j as RuntimeHooks, S as StyleConfig, T as ToolsConfig, d as defaultConfig, a as defineConfig } from './schema-CGQSqjRr.js';
1
+ import { G as GeneratorContext, b as PluginHooks, Y as YwkfConfig, c as PluginConfig, e as YwkfPlugin } from './schema-runIYOB7.js';
2
+ export { B as BuildHooks, C as CodeInjection, D as DevServerConfig, E as EnvConfig, f as GeneratedFile, g as GeneratorHooks, H as HtmlConfig, M as MicroFrontendConfig, O as OutputConfig, P as PerformanceConfig, h as PluginContext, R as RouterConfig, i as RouterHooks, j as RuntimeHooks, S as StyleConfig, T as ToolsConfig, d as defaultConfig, a as defineConfig } from './schema-runIYOB7.js';
3
3
  import { Compiler } from '@rspack/core';
4
4
  export { PluginManager, createPlugin, definePlugin } from './plugin/index.js';
5
5
  export { ConventionalRouteGenerator, ConventionalRoutePlugin, ConventionalRoutePluginOptions, GeneratorOptions, RouteConfig, generateConventionalRoutes } from './router/index.js';
@@ -179,46 +179,31 @@ interface BiomePluginOptions {
179
179
  */
180
180
  scaffold?: boolean;
181
181
  /**
182
- * biome.json 的 formatter 缩进风格
183
- * @default "space"
184
- */
185
- indentStyle?: "space" | "tab";
186
- /**
187
- * JS/TS formatter 引号风格
188
- * @default "double"
189
- */
190
- quoteStyle?: "double" | "single";
191
- /**
192
- * 箭头函数参数括号
193
- * @default "always"
194
- */
195
- arrowParentheses?: "always" | "asNeeded";
196
- /**
197
- * JS/TS 行宽
198
- * @default 100
182
+ * 额外忽略的文件 glob
199
183
  */
200
- lineWidth?: number;
184
+ ignore?: string[];
201
185
  /**
202
- * 是否启用 organizeImports
203
- * @default true
186
+ * 自定义 linter 规则覆盖(浅合并到继承的规则上)
204
187
  */
205
- organizeImports?: boolean;
188
+ rules?: Record<string, Record<string, string>>;
206
189
  /**
207
- * 额外忽略的文件 glob
190
+ * 自定义 formatter 覆盖
208
191
  */
209
- ignore?: string[];
192
+ formatter?: Record<string, unknown>;
210
193
  /**
211
- * 自定义 linter 规则覆盖(浅合并到默认规则上)
194
+ * 自定义 javascript formatter 覆盖
212
195
  */
213
- rules?: Record<string, Record<string, string>>;
196
+ javascript?: Record<string, unknown>;
214
197
  }
215
198
  /**
216
199
  * Biome 代码规范插件
217
200
  *
218
- * 在 setup 阶段自动生成 biome.json,为项目提供统一的
201
+ * 在 setup 阶段自动生成 biome.json,通过 extends 继承
202
+ * @4399ywkf/core 内置的共享配置,为项目提供统一的
219
203
  * Lint / Format / Import Sorting 规范。
220
204
  *
221
- * 默认配置参考 modern.js biome 方案,并适配 React + Ant Design 项目。
205
+ * 用户项目的 biome.json 只需 extends 框架配置,
206
+ * 再按需覆盖少量规则即可。
222
207
  *
223
208
  * @example
224
209
  * ```ts
@@ -234,6 +219,9 @@ interface BiomePluginOptions {
234
219
  declare const biomePlugin: (options?: BiomePluginOptions | undefined) => YwkfPlugin;
235
220
  /**
236
221
  * 生成默认 biome.json 配置内容(纯数据,供 CLI 脚手架使用)
222
+ *
223
+ * 生成的配置通过 extends 继承 @4399ywkf/core/biome 共享配置,
224
+ * 用户只需在此基础上按需覆盖。
237
225
  */
238
226
  declare function getDefaultBiomeConfig(): Record<string, unknown>;
239
227
 
package/dist/index.js CHANGED
@@ -1049,7 +1049,8 @@ var YwkfGenerator = class {
1049
1049
  const generator = new ConventionalRouteGenerator({
1050
1050
  pagesDir,
1051
1051
  outputDir,
1052
- basename: config.router.basename
1052
+ basename: config.router.basename,
1053
+ loading: config.router.loading
1053
1054
  });
1054
1055
  const content = generator.generateCode();
1055
1056
  const routesPath = join3(outputDir, "routes.tsx");
@@ -2544,7 +2545,6 @@ var analyticsPlugin = createPlugin((options = {}) => ({
2544
2545
  // src/plugin/builtin/biome.ts
2545
2546
  import { existsSync as existsSync7, writeFileSync as writeFileSync3 } from "fs";
2546
2547
  import { join as join7 } from "path";
2547
- var DEFAULT_IGNORE = [".vscode/**/*", "node_modules/**/*", "dist/**/*", ".ywkf/**/*"];
2548
2548
  var biomePlugin = createPlugin((options = {}) => ({
2549
2549
  name: "@4399ywkf/plugin-biome",
2550
2550
  version: "1.0.0",
@@ -2552,30 +2552,19 @@ var biomePlugin = createPlugin((options = {}) => ({
2552
2552
  setup(context) {
2553
2553
  const {
2554
2554
  scaffold = true,
2555
- indentStyle = "space",
2556
- quoteStyle = "double",
2557
- arrowParentheses = "always",
2558
- lineWidth = 100,
2559
- organizeImports = true,
2560
2555
  ignore = [],
2561
- rules: customRules = {}
2556
+ rules: customRules,
2557
+ formatter: customFormatter,
2558
+ javascript: customJavascript
2562
2559
  } = options;
2563
2560
  const { cwd, logger } = context;
2564
2561
  if (scaffold) {
2565
2562
  const biomeConfigPath = join7(cwd, "biome.json");
2566
2563
  if (!existsSync7(biomeConfigPath)) {
2567
- const config = buildBiomeConfig({
2568
- indentStyle,
2569
- quoteStyle,
2570
- arrowParentheses,
2571
- lineWidth,
2572
- organizeImports,
2573
- ignore: [...DEFAULT_IGNORE, ...ignore],
2574
- customRules
2575
- });
2564
+ const config = buildBiomeConfig({ ignore, customRules, customFormatter, customJavascript });
2576
2565
  writeFileSync3(biomeConfigPath, `${JSON.stringify(config, null, 2)}
2577
2566
  `, "utf-8");
2578
- logger.info("\u5DF2\u751F\u6210 biome.json");
2567
+ logger.info("\u5DF2\u751F\u6210 biome.json\uFF08\u7EE7\u627F @4399ywkf/core/biome\uFF09");
2579
2568
  }
2580
2569
  }
2581
2570
  const hooks = {
@@ -2588,111 +2577,29 @@ var biomePlugin = createPlugin((options = {}) => ({
2588
2577
  }
2589
2578
  }));
2590
2579
  function buildBiomeConfig(params) {
2591
- const {
2592
- indentStyle,
2593
- quoteStyle,
2594
- arrowParentheses,
2595
- lineWidth,
2596
- organizeImports: enableOrganizeImports,
2597
- ignore,
2598
- customRules
2599
- } = params;
2600
- const defaultRules = {
2601
- recommended: { "": "true" },
2602
- style: {
2603
- useNodejsImportProtocol: "off",
2604
- noNonNullAssertion: "off",
2605
- noUnusedTemplateLiteral: "off",
2606
- noUselessElse: "off",
2607
- useNumberNamespace: "off"
2608
- },
2609
- suspicious: {
2610
- noExplicitAny: "off",
2611
- noConfusingVoidType: "off",
2612
- noImplicitAnyLet: "off",
2613
- noAssignInExpressions: "off",
2614
- noPrototypeBuiltins: "off"
2615
- },
2616
- complexity: {
2617
- noForEach: "off",
2618
- noBannedTypes: "off",
2619
- useArrowFunction: "off"
2620
- },
2621
- correctness: {
2622
- useExhaustiveDependencies: "off"
2623
- },
2624
- a11y: {
2625
- useAltText: "off",
2626
- useKeyWithClickEvents: "off",
2627
- useButtonType: "off",
2628
- noSvgWithoutTitle: "off"
2629
- },
2630
- performance: {
2631
- noDelete: "off"
2632
- },
2633
- security: {
2634
- noDangerouslySetInnerHtml: "off"
2635
- }
2636
- };
2637
- const mergedRules = { recommended: true };
2638
- for (const [category, categoryRules] of Object.entries(defaultRules)) {
2639
- if (category === "recommended") continue;
2640
- const customCategoryRules = customRules[category] || {};
2641
- mergedRules[category] = { ...categoryRules, ...customCategoryRules };
2642
- }
2643
- const includesPatterns = ["**", ...ignore.map((p) => `!${p}`)];
2644
- return {
2580
+ const { ignore, customRules, customFormatter, customJavascript } = params;
2581
+ const config = {
2645
2582
  $schema: "https://biomejs.dev/schemas/2.3.2/schema.json",
2646
- vcs: {
2647
- enabled: true,
2648
- defaultBranch: "main",
2649
- clientKind: "git",
2650
- useIgnoreFile: true
2651
- },
2652
- formatter: {
2653
- enabled: true,
2654
- indentStyle
2655
- },
2656
- css: {
2657
- formatter: {
2658
- quoteStyle: "single"
2659
- }
2660
- },
2661
- javascript: {
2662
- formatter: {
2663
- quoteStyle,
2664
- arrowParentheses,
2665
- jsxQuoteStyle: "double",
2666
- lineWidth
2667
- }
2668
- },
2669
- linter: {
2670
- enabled: true,
2671
- rules: mergedRules
2672
- },
2673
- assist: {
2674
- actions: {
2675
- source: {
2676
- organizeImports: enableOrganizeImports ? "on" : "off"
2677
- }
2678
- }
2679
- },
2680
- files: {
2681
- ignoreUnknown: true,
2682
- includes: includesPatterns
2683
- }
2583
+ extends: ["@4399ywkf/core/biome"]
2684
2584
  };
2585
+ if (customFormatter) {
2586
+ config.formatter = customFormatter;
2587
+ }
2588
+ if (customJavascript) {
2589
+ config.javascript = customJavascript;
2590
+ }
2591
+ if (customRules && Object.keys(customRules).length > 0) {
2592
+ config.linter = { rules: customRules };
2593
+ }
2594
+ if (ignore.length > 0) {
2595
+ config.files = {
2596
+ includes: ["**", ...ignore.map((p) => `!${p}`)]
2597
+ };
2598
+ }
2599
+ return config;
2685
2600
  }
2686
2601
  function getDefaultBiomeConfig() {
2687
- return buildBiomeConfig({
2688
- indentStyle: "space",
2689
- quoteStyle: "double",
2690
- arrowParentheses: "always",
2691
- lineWidth: 100,
2692
- organizeImports: true,
2693
- ignore: DEFAULT_IGNORE,
2694
- customRules: {}
2695
- });
2602
+ return buildBiomeConfig({ ignore: [] });
2696
2603
  }
2697
2604
 
2698
2605
  // src/plugin/builtin/garfish.ts