Skip to content

Commit c2188cc

Browse files
committed
chore: tweaks
1 parent 3bf2698 commit c2188cc

8 files changed

Lines changed: 56 additions & 64 deletions

File tree

packages/bundler-helper/src/addCustomElement.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import { getBundlerName } from './getBundlerName.js'
2020
* // Add elements matching a pattern
2121
* addCustomElement(bundlerOptions, app, /^my-/)
2222
*
23-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
24-
* @param app - VuePress Node App / VuePress Node 应用
25-
* @param customElement - Tags recognized as custom element / 识别为自定义元素的标签
23+
* @param bundlerOptions - VuePress Bundler config
24+
* @param app - VuePress Node App
25+
* @param customElement - Tags recognized as custom element
2626
*/
2727
export const addCustomElement = (
2828
bundlerOptions: unknown,
@@ -72,8 +72,8 @@ export const addCustomElement = (
7272
const { isCustomElement } = webpackBundlerConfig.vue.compilerOptions
7373

7474
/**
75-
* @param tag - The tag name to check / 要检查的标签名称
76-
* @returns Whether the tag is a custom element / 是否为自定义元素
75+
* @param tag - The tag name to check
76+
* @returns Whether the tag is a custom element
7777
* @see https://vue-loader.vuejs.org/options.html#compileroptions
7878
*/
7979
webpackBundlerConfig.vue.compilerOptions.isCustomElement = (

packages/bundler-helper/src/customizeDevServer.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ export interface DevServerOptions {
3030
/**
3131
* Handle specific path when running VuePress Dev Server
3232
*
33-
* 在运行 VuePress 开发服务器时处理特定路径
33+
* @example
34+
* // handle `/api/` path
35+
* useCustomDevServer(bundlerOptions, app, {
36+
* path: '/api/',
37+
* response: async () => {
38+
* const data = await prepareYourData();
39+
* return JSON.stringify({ message: 'Hello from custom dev server!' })
40+
* },
41+
* errMsg: 'Unexpected api error',
42+
* })
3443
*
35-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
36-
* @param app - VuePress Node App / VuePress Node 应用
37-
* @param options - Dev server options / 开发服务器选项
44+
* @param bundlerOptions - VuePress Bundler config
45+
* @param app - VuePress Node App
46+
* @param options - Dev server options
3847
*/
3948
export const customizeDevServer = (
4049
bundlerOptions: unknown,
@@ -90,9 +99,9 @@ export const customizeDevServer = (
9099
const { devServerSetupMiddlewares } = webpackBundlerOptions
91100

92101
/**
93-
* @param middlewares - Existing middlewares / 现有中间件
94-
* @param server - Webpack Dev Server instance / Webpack 开发服务器实例
95-
* @returns Updated middlewares / 更新后的中间件
102+
* @param middlewares - Existing middlewares
103+
* @param server - Webpack Dev Server instance
104+
* @returns Updated middlewares
96105
* @see https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares
97106
*/
98107
webpackBundlerOptions.devServerSetupMiddlewares = (

packages/bundler-helper/src/getBundlerName.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import type { App } from '@vuepress/core'
22

33
/**
4-
* Get current bundler name
5-
*
6-
* 获取当前打包器名称
4+
* Get short bundler name
75
*
86
* @example
97
* // With @vuepress/bundler-vite
108
* getBundlerName(app) // 'vite'
119
* // With @vuepress/bundler-webpack
1210
* getBundlerName(app) // 'webpack'
1311
*
14-
* @param app - VuePress Node App / VuePress Node 应用
15-
* @returns The bundler name / 打包器名称
12+
* @param app - VuePress Node App
13+
* @returns Short bundler name
1614
*/
1715
export const getBundlerName = (app: App): string => {
1816
const { name } = app.options.bundler

packages/bundler-helper/src/vite/mergeViteConfig.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,10 @@ const mergeConfigRecursively = (
276276
/**
277277
* Merge Vite configurations
278278
*
279-
* 合并 Vite 配置
280-
*
281-
* @param defaults - Default configuration / 默认配置
282-
* @param overrides - Override configuration / 覆盖配置
283-
* @param isRoot - Whether it's root level merge / 是否为根级别合并
284-
* @returns Merged configuration / 合并后的配置
279+
* @param defaults - Default configuration
280+
* @param overrides - Override configuration
281+
* @param isRoot - Whether it's root level merge
282+
* @returns Merged configuration
285283
*/
286284
export const mergeViteConfig = (
287285
defaults: Record<string, any>,

packages/bundler-helper/src/vite/viteHelper.ts

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ const runningPackageManger = getRunningPackageManager()
1111
/**
1212
* Add Vite config
1313
*
14-
* 添加 Vite 配置
15-
*
16-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
17-
* @param app - VuePress Node App / VuePress Node 应用
18-
* @param config - Vite config / Vite 配置
14+
* @param bundlerOptions - VuePress Bundler config
15+
* @param app - VuePress Node App
16+
* @param config - Vite config
1917
*/
2018
export const addViteConfig = (
2119
bundlerOptions: unknown,
@@ -35,12 +33,10 @@ export const addViteConfig = (
3533
/**
3634
* Add modules to Vite `optimizeDeps.include` list
3735
*
38-
* 将模块添加到 Vite `optimizeDeps.include` 列表
39-
*
40-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
41-
* @param app - VuePress Node App / VuePress Node 应用
42-
* @param module - Module name(s) to include / 要包含的模块名称
43-
* @param isDirectDep - Whether the module is a direct dependency / 模块是否是直接依赖
36+
* @param bundlerOptions - VuePress Bundler config
37+
* @param app - VuePress Node App
38+
* @param module - Module name(s) to include
39+
* @param isDirectDep - Whether the module is a direct dependency
4440
*/
4541
export const addViteOptimizeDepsInclude = (
4642
bundlerOptions: unknown,
@@ -68,11 +64,9 @@ export const addViteOptimizeDepsInclude = (
6864
/**
6965
* Add modules to Vite `optimizeDeps.exclude` list
7066
*
71-
* 将模块添加到 Vite `optimizeDeps.exclude` 列表
72-
*
73-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
74-
* @param app - VuePress Node App / VuePress Node 应用
75-
* @param module - Module name(s) to exclude / 要排除的模块名称
67+
* @param bundlerOptions - VuePress Bundler config
68+
* @param app - VuePress Node App
69+
* @param module - Module name(s) to exclude
7670
*/
7771
export const addViteOptimizeDepsExclude = (
7872
bundlerOptions: unknown,
@@ -89,11 +83,9 @@ export const addViteOptimizeDepsExclude = (
8983
/**
9084
* Add modules to Vite `optimizeDeps.needsInterop` list
9185
*
92-
* 将模块添加到 Vite `optimizeDeps.needsInterop` 列表
93-
*
94-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
95-
* @param app - VuePress Node App / VuePress Node 应用
96-
* @param module - Module name(s) that needs interop / 需要互操作的模块名称
86+
* @param bundlerOptions - VuePress Bundler config
87+
* @param app - VuePress Node App
88+
* @param module - Module name(s) that needs interop
9789
*/
9890
export const addViteOptimizeDepsNeedsInterop = (
9991
bundlerOptions: unknown,
@@ -110,11 +102,9 @@ export const addViteOptimizeDepsNeedsInterop = (
110102
/**
111103
* Add modules to Vite `ssr.external` list
112104
*
113-
* 将模块添加到 Vite `ssr.external` 列表
114-
*
115-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
116-
* @param app - VuePress Node App / VuePress Node 应用
117-
* @param module - Module name(s) to externalize / 要外部化的模块名称
105+
* @param bundlerOptions - VuePress Bundler config
106+
* @param app - VuePress Node App
107+
* @param module - Module name(s) to externalize
118108
*/
119109
export const addViteSsrExternal = (
120110
bundlerOptions: unknown,
@@ -131,11 +121,9 @@ export const addViteSsrExternal = (
131121
/**
132122
* Add modules to Vite `ssr.noExternal` list
133123
*
134-
* 将模块添加到 Vite `ssr.noExternal` 列表
135-
*
136-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
137-
* @param app - VuePress Node App / VuePress Node 应用
138-
* @param module - Module name(s) to not externalize / 不要外部化的模块名称
124+
* @param bundlerOptions - VuePress Bundler config
125+
* @param app - VuePress Node App
126+
* @param module - Module name(s) to not externalize
139127
*/
140128
export const addViteSsrNoExternal = (
141129
bundlerOptions: unknown,

packages/bundler-helper/src/webpack/chainWebpack.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import { getBundlerName } from '../getBundlerName.js'
99
/**
1010
* Chain webpack
1111
*
12-
* 链式配置 webpack
13-
*
14-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
15-
* @param app - VuePress Node App / VuePress Node 应用
16-
* @param chain - Chain function / 链式配置函数
12+
* @param bundlerOptions - VuePress Bundler config
13+
* @param app - VuePress Node App
14+
* @param chain - Chain function
1715
*/
1816
export const chainWebpack = (
1917
bundlerOptions: unknown,

packages/bundler-helper/src/webpack/configWebpack.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import { getBundlerName } from '../getBundlerName.js'
99
/**
1010
* Configure webpack options
1111
*
12-
* 配置 webpack 选项
13-
*
14-
* @param bundlerOptions - VuePress Bundler config / VuePress 打包器配置
15-
* @param app - VuePress Node App / VuePress Node 应用
16-
* @param configureWebpack - Function to configure webpack / 配置 webpack 的函数
12+
* @param bundlerOptions - VuePress Bundler config
13+
* @param app - VuePress Node App
14+
* @param configureWebpack - Function to configure webpack
1715
*/
1816
export const configWebpack = (
1917
bundlerOptions: unknown,

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)