fix(tooling): align Vite+ configuration and upgrade toolchain (#43019)

This commit is contained in:
Stephen Zhou
2026-09-28 02:32:25 +00:00
committed by GitHub
parent 1366cadbb4
commit 11f6a350f1
14 changed files with 397 additions and 315 deletions

View File

@@ -205,9 +205,25 @@ jobs:
- name: Setup web environment
uses: ./.github/actions/setup-web
- name: Restore static check task cache
id: static-check-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: node_modules/.vite/task-cache
key: vite-task-static-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
vite-task-static-v1-${{ runner.os }}-${{ runner.arch }}-
- name: Static check
run: vp run -w check
- name: Save static check task cache
if: success() && github.event_name != 'merge_group'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: node_modules/.vite/task-cache
key: ${{ steps.static-check-cache.outputs.cache-primary-key }}
superlinter:
name: SuperLinter
if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-superlinter) }}

View File

@@ -9,6 +9,8 @@ on:
- package.json
- pnpm-lock.yaml
- pnpm-workspace.yaml
- .github/actions/setup-web/**
- .github/workflows/tool-test-sdks.yaml
concurrency:
group: sdk-tests-${{ github.head_ref || github.run_id }}
@@ -28,15 +30,13 @@ jobs:
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: package.json
cache: ''
cache-dependency-path: 'pnpm-lock.yaml'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Setup web environment
uses: ./.github/actions/setup-web
- name: Test
run: pnpm test
- name: Build and verify package entry points
run: |
pnpm build
node --input-type=module -e "import { access } from 'node:fs/promises'; import 'dify-client'; await access('dist/index.d.ts')"

View File

@@ -65,6 +65,13 @@
"vite-plus": "catalog:",
"vitest": "catalog:"
},
"devEngines": {
"runtime": {
"name": "node",
"version": "24.21.0",
"onFail": "download"
}
},
"engines": {
"node": "^24.20.0"
},

View File

@@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"check": "vp check && vp run lint:eslint",
"check": "vp run check:cached",
"check:fix": "vp run lint:eslint:fix && vp check --fix",
"dev": "concurrently -k -n vinext,proxy \"vp run dify-web#dev:vinext\" \"vp run dify-web#dev:proxy\"",
"knip": "knip --workspace web",

View File

@@ -37,6 +37,13 @@
"vite": "catalog:",
"vite-plus": "catalog:"
},
"devEngines": {
"runtime": {
"name": "node",
"version": "24.21.0",
"onFail": "download"
}
},
"engines": {
"node": "^24.20.0"
}

View File

@@ -1,9 +1,6 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite-plus'
import { defineConfig, lazyPlugins } from 'vite-plus'
import { playwright } from 'vite-plus/test/browser-playwright'
const dirname = path.dirname(fileURLToPath(import.meta.url))
@@ -11,7 +8,10 @@ const configDir = path.join(dirname, '.storybook')
const isCI = !!process.env.CI
export default defineConfig({
plugins: [react()],
plugins: lazyPlugins(async () => {
const { default: react } = await import('@vitejs/plugin-react')
return [react()]
}),
resolve: {
tsconfigPaths: true,
},
@@ -42,7 +42,10 @@ export default defineConfig({
projects: [
{
extends: true,
plugins: [tailwindcss()],
plugins: lazyPlugins(async () => {
const { default: tailwindcss } = await import('@tailwindcss/vite')
return [tailwindcss()]
}),
test: {
name: 'unit',
globals: true,
@@ -58,11 +61,10 @@ export default defineConfig({
},
{
extends: true,
plugins: [
storybookTest({
configDir,
plugins: lazyPlugins(async () => {
const { storybookTest } = await import('@storybook/addon-vitest/vitest-plugin')
return [storybookTest({ configDir })]
}),
],
test: {
name: 'storybook',
},

View File

@@ -22,6 +22,13 @@
"vite": "catalog:",
"vite-plus": "catalog:"
},
"devEngines": {
"runtime": {
"name": "node",
"version": "24.21.0",
"onFail": "download"
}
},
"engines": {
"node": "^24.20.0"
}

594
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -264,9 +264,9 @@ catalog:
use-context-selector: 2.0.0
uuid: 14.0.2
vinext: 1.0.0-beta.10
vite: npm:@voidzero-dev/vite-plus-core@1.0.0-rc.0
vite: npm:@voidzero-dev/vite-plus-core@1.0.0-rc.1
vite-plugin-inspect: 12.0.2
vite-plus: 1.0.0-rc.0
vite-plus: 1.0.0-rc.1
vitest: 5.0.1
vitest-browser-react: 2.3.0
vitest-canvas-mock: 1.2.0

View File

@@ -59,6 +59,13 @@
"vite-plus": "catalog:",
"vitest": "catalog:"
},
"devEngines": {
"runtime": {
"name": "node",
"version": "24.21.0",
"onFail": "download"
}
},
"engines": {
"node": ">=18.0.0"
}

View File

@@ -5,6 +5,7 @@ export default defineConfig({
deps: { resolveDepSubpath: true },
entry: ['src/index.ts'],
format: ['esm'],
fixedExtension: false,
platform: 'node',
dts: true,
clean: true,

View File

@@ -48,6 +48,18 @@ const formatterUnstableInputs = ['web/app/components/develop/template/*.mdx']
export default defineConfig({
lint: lintConfig,
run: {
tasks: {
'check:cached': {
command: ['vp check', 'eslint --concurrency=auto'],
cache: {
env: ['CI', 'NODE_ENV', 'TAILWIND_CANONICAL_CLASSES'],
// Static checks have no artifacts to restore into the working tree.
output: [],
},
},
},
},
staged: {
[lintFiles]: checkFix,
[eslintFiles]: [eslintFix, formatFix],

View File

@@ -1,5 +1,5 @@
import { pinyin } from 'pinyin-pro'
import { describe, expect, it } from 'vitest'
import { describe, expect, it } from 'vite-plus/test'
import { compareProviderLetters, getProviderLetter } from '../utils'
describe('provider letter grouping', () => {

View File

@@ -18,6 +18,17 @@ vp run -w check:fix
CI and local development use the same root `vite.config.ts` configuration.
The root `check` script delegates to the `check:cached` Vite Task. Formatting, linting,
and type checking reuse successful results when their tracked inputs are unchanged.
`CI`, `NODE_ENV`, and `TAILWIND_CANONICAL_CLASSES` are included in the cache key;
check results never restore files into the working tree. Fix commands remain uncached.
To force a fresh check, run `vp run -w --no-cache check`.
The TS Common CI job restores the task cache after dependency installation and saves
it after a successful check. This is separate from the package-manager cache in
`setup-web`. When evaluating CI performance, compare cache transfer time with the
time saved in the Vite Task summary.
Reuse successful checks for the same final changes. Repeat or expand checks only when subsequent edits, failures, or unresolved concerns require it.
To narrow formatting and linting, pass paths directly to Vite+. Type checking remains repository-wide: