Skip to content

Commit b7308f4

Browse files
winixtqlin
andauthored
feat: 升级vite8 (#276)
Co-authored-by: qlin <qlin@webank.com>
1 parent 6868e85 commit b7308f4

74 files changed

Lines changed: 5490 additions & 5418 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cliff.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[changelog]
2+
header = """
3+
# Changelog\n
4+
"""
5+
body = """
6+
{% if version %}\
7+
## [{{ version | trim_start_matches(pat="v") }}](https://github.com/WeBankFinTech/fes.js/compare/{{ previous.version }}...{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }})
8+
{% else %}\
9+
## [Unreleased]
10+
{% endif %}\
11+
{% for group, commits in commits | group_by(attribute="group") %}
12+
### {{ group | upper_first }}
13+
{% for commit in commits %}
14+
* {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/WeBankFinTech/fes.js/commit/{{ commit.id }}))
15+
{% endfor %}
16+
{% endfor %}\n
17+
"""
18+
trim = true
19+
20+
[git]
21+
conventional_commits = true
22+
filter_unconventional = true
23+
split_commits = false
24+
commit_parsers = [
25+
{ message = "^feat", group = "Features" },
26+
{ message = "^fix", group = "Bug Fixes" },
27+
{ message = "^perf", group = "Performance Improvements" },
28+
{ message = "^doc", group = "Documentation" },
29+
{ message = "^style", group = "Styles" },
30+
{ message = "^refactor", group = "Code Refactoring" },
31+
{ message = "^test", group = "Tests" },
32+
{ message = "^chore", group = "Chores" },
33+
{ message = "^revert", group = "Reverts" },
34+
]
35+
filter_commits = false
36+
tag_pattern = "v[0-9].*"
37+
sort_tags = "newest"

package.json

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,28 @@
2828
"docs:build-pages": "BASE=fes.js vitepress build docs",
2929
"test": "fes test",
3030
"lint": "eslint --ignore-pattern='templates'",
31-
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
31+
"changelog": "git-cliff -o CHANGELOG.md",
3232
"hooks:sync": "simple-git-hooks"
3333
},
3434
"dependencies": {
3535
"consola": "^3.4.2",
36-
"conventional-changelog-cli": "^5.0.0",
37-
"execa": "^6.1.0",
36+
"execa": "^9.6.1",
3837
"minimist": "^1.2.6",
3938
"picocolors": "^1.1.1",
4039
"semver": "^7.3.6",
4140
"tsup": "^8.5.0",
42-
"turbo": "^2.5.6"
41+
"turbo": "^2.9.6"
4342
},
4443
"devDependencies": {
45-
"@antfu/eslint-config": "^5.2.2",
46-
"@commitlint/cli": "^18.4.4",
47-
"@commitlint/config-conventional": "^18.4.4",
48-
"chokidar": "^3.5.3",
49-
"commitizen": "^4.3.1",
50-
"cz-conventional-changelog": "^3.3.0",
44+
"@antfu/eslint-config": "^8.2.0",
45+
"@commitlint/cli": "^20.5.0",
46+
"@commitlint/config-conventional": "^20.5.0",
47+
"chokidar": "^5.0.0",
5148
"deepmerge": "^4.2.2",
5249
"eslint": "^9.34.0",
5350
"fs-extra": "^11.3.1",
54-
"lint-staged": "^15.2.0",
51+
"git-cliff": "^2.12.0",
52+
"lint-staged": "^16.4.0",
5553
"simple-git-hooks": "^2.9.0",
5654
"typescript": "^5.9.2",
5755
"vitepress": "1.0.0-alpha.73",
@@ -65,10 +63,5 @@
6563
"*.{js,jsx,vue,ts}": [
6664
"npm run lint"
6765
]
68-
},
69-
"config": {
70-
"commitizen": {
71-
"path": "./node_modules/cz-conventional-changelog"
72-
}
7366
}
7467
}

packages/builder-vite/package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,30 @@
3636
"dependencies": {
3737
"@fesjs/shared": "^4.0.0-beta.0",
3838
"@fesjs/utils": "^4.0.0-beta.0",
39-
"@rollup/pluginutils": "^5.1.0",
40-
"@vitejs/plugin-basic-ssl": "^2.1.0",
41-
"@vitejs/plugin-legacy": "^7.2.1",
42-
"@vitejs/plugin-vue": "^6.0.1",
43-
"@vitejs/plugin-vue-jsx": "^5.1.1",
39+
"@vitejs/plugin-basic-ssl": "^2.3.0",
40+
"@vitejs/plugin-legacy": "^8.0.1",
41+
"@vitejs/plugin-vue": "^6.0.6",
42+
"@vitejs/plugin-vue-jsx": "^5.1.5",
4443
"autoprefixer": "^10.4.21",
4544
"colorette": "^2.0.16",
4645
"connect-history-api-fallback": "^2.0.0",
4746
"consola": "^3.4.2",
4847
"dotenv": "^16.0.0",
4948
"dotenv-expand": "^8.0.2",
50-
"ejs": "^3.1.6",
49+
"ejs": "^5.0.2",
5150
"fast-glob": "^3.2.11",
5251
"fs-extra": "^11.3.1",
5352
"html-minifier-terser": "^7.2.0",
5453
"less": "^4.2.0",
54+
"minimatch": "^10.0.1",
5555
"node-html-parser": "^5.3.3",
56-
"pathe": "^0.2.0",
56+
"pathe": "^2.0.3",
57+
"picocolors": "^1.1.1",
5758
"postcss-flexbugs-fixes": "^5.0.2",
5859
"postcss-safe-parser": "^6.0.0",
59-
"rollup-plugin-visualizer": "^6.0.3",
6060
"terser": "^5.24.0",
61-
"vite": "^7.1.4"
61+
"vite": "^8.0.9",
62+
"vite-bundle-analyzer": "^1.3.7"
6263
},
6364
"typings": "./types.d.ts"
6465
}

packages/builder-vite/src/commands/build/getBuildConfig.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ import postcssFlexbugsFixes from 'postcss-flexbugs-fixes';
77
import postcssSafeParser from 'postcss-safe-parser';
88
import { getInnerCommonConfig } from '../../common/getConfig';
99

10-
function getEsbuildTarget(targets: any): string[] {
11-
const result: string[] = [];
12-
['chrome', 'edge', 'firefox', 'hermes', 'ios', 'node', 'opera', 'rhino', 'safari'].forEach((key) => {
13-
if (targets[key]) {
14-
result.push(`${key}${targets[key]}`);
15-
}
16-
});
17-
return result;
18-
}
19-
2010
export default async (api: IPluginAPI<ViteBuildConfig>): Promise<InlineConfig> => {
2111
const { deepmerge, getTargetsAndBrowsersList } = api.utils;
2212

packages/builder-vite/src/commands/dev/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { IPluginAPI } from '@fesjs/shared';
22
import type { ViteDevServer } from 'vite';
33
import process from 'node:process';
44
import { createServer } from 'vite';
5+
import pc from 'picocolors';
56
import getDevConfig from './getDevConfig';
67

78
interface Args {
@@ -14,7 +15,7 @@ interface Args {
1415
export default (api: IPluginAPI) => {
1516
const {
1617
paths,
17-
utils: { chalk, rimraf },
18+
utils: { rimraf },
1819
} = api;
1920

2021
let server: ViteDevServer | undefined;
@@ -63,7 +64,7 @@ export default (api: IPluginAPI) => {
6364
name: 'restartServer',
6465
fn() {
6566
// eslint-disable-next-line no-console
66-
console.log(chalk.gray('Try to restart dev server...'));
67+
console.log(pc.gray('Try to restart dev server...'));
6768
destroy();
6869
if (typeof process !== 'undefined' && process.send) {
6970
process.send({

packages/builder-vite/src/common/vite-plugin-html.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { ConfigEnv, Plugin, ResolvedConfig, ViteDevServer } from 'vite';
22
import process from 'node:process';
3-
import { createFilter } from '@rollup/pluginutils';
43
import { dim } from 'colorette';
54
import consola from 'consola';
65
import dotenv from 'dotenv';
76
import { expand } from 'dotenv-expand';
8-
import { render } from 'ejs';
7+
import ejs from 'ejs';
98
import fg from 'fast-glob';
109
import fse from 'fs-extra';
1110
import { minify } from 'html-minifier-terser';
11+
import { minimatch } from 'minimatch';
1212
import { parse } from 'node-html-parser';
1313
import path, { dirname, join } from 'pathe';
1414
import { normalizePath } from 'vite';
@@ -119,7 +119,7 @@ function createPlugin(userOptions: UserOptions = {}): Plugin {
119119
if (input) {
120120
return {
121121
build: {
122-
rollupOptions: {
122+
rolldownOptions: {
123123
input,
124124
},
125125
},
@@ -271,7 +271,7 @@ async function renderHtml(html: string, config: any): Promise<string> {
271271
...(env || {}),
272272
...data,
273273
};
274-
let result = await render(html, ejsData, ejsOptions);
274+
let result = await ejs.render(html, ejsData, ejsOptions);
275275
if (entry) {
276276
result = removeEntryScript(result, verbose);
277277
result = result.replace(bodyInjectRE, `<script type="module" src="${normalizePath(`${entry}`)}"></script></body>`);
@@ -292,7 +292,7 @@ function getPage(userOptions: UserOptions, name: string, viteConfig: ResolvedCon
292292
}
293293

294294
function isMpa(viteConfig: ResolvedConfig | undefined): boolean {
295-
const input = viteConfig?.build?.rollupOptions?.input ?? undefined;
295+
const input = viteConfig?.build?.rolldownOptions?.input ?? undefined;
296296
return typeof input !== 'string' && Object.keys(input || {}).length > 1;
297297
}
298298

@@ -352,7 +352,7 @@ function createRewire(reg: string, page: Page, baseUrl: string, proxyUrlKeys: st
352352
};
353353
}
354354

355-
const htmlFilter = createFilter(['**/*.html']);
355+
const htmlFilter = (id: string) => minimatch(id, '**/*.html');
356356

357357
function getOptions(_minify: boolean) {
358358
return {

packages/builder-vite/src/features/viteAnalyze.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { IPluginAPI } from '@fesjs/shared';
22
import process from 'node:process';
3-
import { visualizer } from 'rollup-plugin-visualizer';
3+
import { analyzer } from 'vite-bundle-analyzer';
44

55
export default (api: IPluginAPI<{ viteAnalyze: Record<string, any> }>) => {
66
api.describe({
@@ -16,11 +16,10 @@ export default (api: IPluginAPI<{ viteAnalyze: Record<string, any> }>) => {
1616

1717
api.modifyBundleConfig((memo: any) => {
1818
memo.plugins.push(
19-
visualizer({
20-
filename: './.cache/visualizer/stats.html',
21-
open: true,
22-
gzipSize: true,
23-
brotliSize: true,
19+
analyzer({
20+
analyzerMode: 'static',
21+
fileName: './.cache/visualizer/stats',
22+
openAnalyzer: true,
2423
...api.config.viteAnalyze,
2524
}),
2625
);

packages/builder-webpack/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@babel/preset-typescript": "^7.27.1",
4545
"@fesjs/shared": "^4.0.0-beta.0",
4646
"@fesjs/utils": "^4.0.0-beta.0",
47-
"@vue/babel-plugin-jsx": "^1.5.0",
47+
"@vue/babel-plugin-jsx": "^2.0.1",
4848
"ajv": "^8.12.0",
4949
"autoprefixer": "^10.4.14",
5050
"babel-loader": "^10.0.0",
@@ -54,13 +54,15 @@
5454
"copy-webpack-plugin": "^11.0.0",
5555
"css-loader": "^6.7.3",
5656
"css-minimizer-webpack-plugin": "^5.0.0",
57+
"es-toolkit": "^1.46.0",
5758
"fs-extra": "^11.3.1",
5859
"get-folder-size": "^5.0.0",
5960
"html-webpack-plugin": "^5.5.0",
6061
"html-webpack-tags-plugin": "^3.0.2",
6162
"less": "^4.1.3",
6263
"less-loader": "^11.1.0",
6364
"mini-css-extract-plugin": "^2.9.4",
65+
"picocolors": "^1.1.1",
6466
"postcss": "^8.4.33",
6567
"postcss-flexbugs-fixes": "^5.0.2",
6668
"postcss-loader": "^7.1.0",

packages/builder-webpack/src/plugins/commands/dev/devServer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { WebpackBuildConfig } from '../../../shared';
2-
import { chalk } from '@fesjs/utils';
2+
import pc from 'picocolors';
33
import webpack from 'webpack';
44
import WebpackDevServer from 'webpack-dev-server';
55

@@ -68,13 +68,13 @@ export function startDevServer({ webpackConfig, host, port, proxy, https, before
6868
const server = new WebpackDevServer(options, compiler);
6969
if (options.host === '0.0.0.0') {
7070
// eslint-disable-next-line no-console
71-
console.log(chalk.green(' ➜ Local: '), chalk.cyan(`${options.server}://127.0.0.1:${options.port}`));
71+
console.log(pc.green(' ➜ Local: '), pc.cyan(`${options.server}://127.0.0.1:${options.port}`));
7272
// eslint-disable-next-line no-console
73-
console.log(chalk.gray(' ➜ Network: '), chalk.gray(`${options.server}://${options.host}:${options.port}`));
73+
console.log(pc.gray(' ➜ Network: '), pc.gray(`${options.server}://${options.host}:${options.port}`));
7474
}
7575
else {
7676
// eslint-disable-next-line no-console
77-
console.log(chalk.green(' ➜ :Local: '), chalk.cyan(`${options.server}://${options.host}:${options.port}`));
77+
console.log(pc.green(' ➜ :Local: '), pc.cyan(`${options.server}://${options.host}:${options.port}`));
7878
}
7979
server.startCallback((err) => {
8080
if (err) {

packages/builder-webpack/src/plugins/commands/dev/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from 'node:path';
55
import process from 'node:process';
66
import { removeSync } from 'fs-extra/esm';
77
import getFolderSize from 'get-folder-size';
8+
import pc from 'picocolors';
89
import { cleanTmpPathExceptCache, getBundleAndConfigs } from '../../common/buildDevUtils';
910
import connectHistoryMiddleware from './connectHistoryMiddleware';
1011
import { startDevServer } from './devServer';
@@ -29,7 +30,7 @@ async function handleCacheClean(cwd: string) {
2930
export default (api: IPluginAPI<WebpackBuildConfig>) => {
3031
const {
3132
paths,
32-
utils: { chalk, getPort, getHostName, changePort, logger },
33+
utils: { getPort, getHostName, changePort, logger },
3334
} = api;
3435

3536
let port: number;
@@ -112,7 +113,7 @@ export default (api: IPluginAPI<WebpackBuildConfig>) => {
112113
api.registerMethod({
113114
name: 'restartServer',
114115
fn() {
115-
logger.info(chalk.gray('Try to restart dev server...'));
116+
logger.info(pc.gray('Try to restart dev server...'));
116117
destroy();
117118
process.send?.({
118119
type: 'RESTART',

0 commit comments

Comments
 (0)