chore: complete Vite+ migration (#8258)

* chore: complete Vite+ migration

* chore: refine Vite+ migration
This commit is contained in:
MK (fengmk2)
2026-08-26 17:00:48 +08:00
committed by GitHub
parent 6ebe147e31
commit 3aab4cccbc
18 changed files with 520 additions and 1260 deletions
@@ -1,25 +1,9 @@
name: Restore dependencies
description: Download cached pnpm store artifact and restore dependencies offline
inputs:
artifact-name:
description: Name of the artifact containing the pnpm store
default: node-dependencies
required: false
description: Install dependencies from the cached package manager data
runs:
using: composite
steps:
- name: Download dependency artifacts
uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact-name }}
path: /tmp/node-dependencies
- name: Restore pnpm store
shell: bash
run: tar -xzf /tmp/node-dependencies/pnpm-store.tar.gz
- name: Restore dependencies
shell: bash
run: pnpm install --offline --frozen-lockfile --strict-peer-dependencies
run: vp install --offline --frozen-lockfile -- --strict-peer-dependencies
+4 -20
View File
@@ -1,35 +1,19 @@
name: Setup Vite+ and pnpm environment
description: Install Vite+ (vp) and pnpm, setup Node.js, and optionally configure the pnpm store
name: Setup Vite+ environment
description: Install Vite+ and set up Node.js and dependency caching
inputs:
node-version:
description: Node.js version
required: true
pnpm-version:
description: pnpm version
required: true
store-dir:
description: Relative pnpm store directory within the workspace. Empty uses the default pnpm store.
default: ''
required: false
cache:
description: Whether to use setup-vp's dependency caching (pass literal string `'true'` to enable)
description: Whether to cache package manager data
default: 'false'
required: false
runs:
using: composite
steps:
- uses: pnpm/action-setup@v5
with:
version: ${{ inputs.pnpm-version }}
- name: Configure pnpm store
if: inputs.store-dir != ''
shell: bash
run: pnpm config set store-dir ${{ github.workspace }}/${{ inputs.store-dir }}
- uses: voidzero-dev/setup-vp@v1.17.0
- uses: voidzero-dev/setup-vp@v1.18.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.cache == 'true' && 'true' || 'false' }}
+2 -3
View File
@@ -76,11 +76,10 @@ Scripts are cached by Vite Task (`run.cache.scripts` is enabled in `vite.config.
## Linting & formatting
- oxlint runs with sensible defaults (no config file required).
- oxfmt config is at **`.oxfmtrc.json`**.
- Lint and format settings are in `vite.config.mts`.
- Vite+ hooks (`vp staged`) run automatically on commits.
Use `vp run lint` / `vp run format`, not the built-in `vp lint` / `vp format`. The built-ins scan every `vite.config.ts` in the repo (including the per-package pack configs) as their own config and fail to load them. The repo scripts call the standalone `oxlint` / `oxfmt` binaries directly, which avoid that.
Use `vp run lint` / `vp run format`, or the equivalent `pnpm run` commands.
Run manually:
+9 -27
View File
@@ -2,8 +2,7 @@ name: Verify
env:
NODE_VERSION: 24
PNPM_VERSION: 11.2.2
PNPM_STORE_DIR: .pnpm-store
VP_GIT_HOOKS: 0
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -33,22 +32,10 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
store-dir: ${{ env.PNPM_STORE_DIR }}
cache: 'true'
- name: Install dependencies
run: pnpm install --frozen-lockfile --strict-peer-dependencies
- name: Pack dependency artifacts
run: tar -czf /tmp/pnpm-store.tar.gz ${{ env.PNPM_STORE_DIR }}
- name: Upload dependency artifacts
uses: actions/upload-artifact@v7
with:
name: node-dependencies
path: /tmp/pnpm-store.tar.gz
retention-days: 1
run: vp install --frozen-lockfile -- --strict-peer-dependencies
build-packages:
name: Build packages
@@ -62,8 +49,7 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
store-dir: ${{ env.PNPM_STORE_DIR }}
cache: 'true'
- uses: ./.github/actions/restore-dependencies
@@ -85,13 +71,12 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
store-dir: ${{ env.PNPM_STORE_DIR }}
cache: 'true'
- uses: ./.github/actions/restore-dependencies
- name: Run linting and formatting checks
run: vp run lint
run: vp check
run-unit-tests:
name: Run unit tests
@@ -105,13 +90,12 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
store-dir: ${{ env.PNPM_STORE_DIR }}
cache: 'true'
- uses: ./.github/actions/restore-dependencies
- name: Run unit tests
run: vp run test:unit
run: vp test
run-e2e-tests:
name: Run e2e tests (shard ${{ matrix.shard }}/${{ matrix.total }})
@@ -130,8 +114,7 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
store-dir: ${{ env.PNPM_STORE_DIR }}
cache: 'true'
- uses: ./.github/actions/restore-dependencies
@@ -161,8 +144,7 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
store-dir: ${{ env.PNPM_STORE_DIR }}
cache: 'true'
- uses: ./.github/actions/restore-dependencies
+3 -5
View File
@@ -2,7 +2,7 @@ name: Publish
env:
NODE_VERSION: 24
PNPM_VERSION: 11.2.2
VP_GIT_HOOKS: 0
on:
push:
@@ -49,11 +49,10 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
cache: 'true'
- name: Install dependencies
run: pnpm install --frozen-lockfile --strict-peer-dependencies
run: vp install --frozen-lockfile -- --strict-peer-dependencies
- name: Run build
run: vp run build && vp run build:demos
@@ -90,14 +89,13 @@ jobs:
- uses: ./.github/actions/setup-env
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
cache: 'true'
- name: Update npm for trusted publishing
run: npm install -g npm@11.6.2
- name: Install dependencies
run: pnpm install --frozen-lockfile --strict-peer-dependencies
run: vp install --frozen-lockfile -- --strict-peer-dependencies
- name: Download package dist artifacts
uses: actions/download-artifact@v8
-7
View File
@@ -1,7 +0,0 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": ["CHANGELOG.md"],
"semi": false,
"singleQuote": true,
"arrowParens": "avoid"
}
+1 -1
View File
@@ -53,7 +53,6 @@
"@vitejs/plugin-react": "6.0.5",
"@vitejs/plugin-vue": "6.0.8",
"autoprefixer": "^10.4.20",
"esbuild": "0.28.1",
"iframe-resizer": "^4.4.5",
"postcss": "^8.5.23",
"postcss-import": "^15.1.0",
@@ -64,6 +63,7 @@
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"uuid": "^14.0.0",
"vite": "catalog:",
"vite-plus": "catalog:",
"vue": "^3.5.13",
"vue-router": "^4.5.0"
+4 -4
View File
@@ -6,10 +6,10 @@
"module": "nodenext",
"moduleResolution": "nodenext",
"paths": {
"@tiptap/pm/*": ["./packages/pm/*/index.ts"],
"@tiptap/static-renderer/pm/*": ["./packages/static-renderer/src/pm/*"],
"@tiptap/static-renderer/json/*": ["./packages/static-renderer/src/json/*"],
"@tiptap/*": ["./packages/*/src/index.ts", "./packages-deprecated/*/src/index.ts"]
"@tiptap/pm/*": ["../packages/pm/*/index.ts"],
"@tiptap/static-renderer/pm/*": ["../packages/static-renderer/src/pm/*"],
"@tiptap/static-renderer/json/*": ["../packages/static-renderer/src/json/*"],
"@tiptap/*": ["../packages/*/src/index.ts", "../packages-deprecated/*/src/index.ts"]
}
},
"include": [
+17 -13
View File
@@ -11,12 +11,14 @@ const getPackageDependencies = () => {
const paths: Array<{ find: string; replacement: any }> = []
function collectPackageInformation(path: string) {
fg.sync(`../${path}/*`, { onlyDirectories: true })
.map(name => name.replace(`../${path}/`, ''))
const packagesPath = resolve(import.meta.dirname, '..', path)
fg.sync(`${packagesPath}/*`, { onlyDirectories: true })
.map(name => basename(name))
.forEach(name => {
if (name === 'pm') {
fg.sync(`../${path}/${name}/*`, { onlyDirectories: true }).forEach(subName => {
const subPkgName = subName.replace(`../${path}/${name}/`, '')
fg.sync(`${packagesPath}/${name}/*`, { onlyDirectories: true }).forEach(subName => {
const subPkgName = basename(subName)
if (subPkgName === 'dist' || subPkgName === 'node_modules') {
return
@@ -24,7 +26,7 @@ const getPackageDependencies = () => {
paths.push({
find: `@tiptap/${name}/${subPkgName}`,
replacement: resolve(`../${path}/${name}/${subPkgName}/index.ts`),
replacement: resolve(packagesPath, name, subPkgName, 'index.ts'),
})
})
} else if (
@@ -36,22 +38,22 @@ const getPackageDependencies = () => {
name === 'vue-2' ||
name === 'vue-3'
) {
fg.sync(`../${path}/${name}/src/*`, { onlyDirectories: true }).forEach(subName => {
const subPkgName = subName.replace(`../${path}/${name}/src/`, '')
fg.sync(`${packagesPath}/${name}/src/*`, { onlyDirectories: true }).forEach(subName => {
const subPkgName = basename(subName)
paths.push({
find: `@tiptap/${name}/${subPkgName}`,
replacement: resolve(`../${path}/${name}/src/${subPkgName}/index.ts`),
replacement: resolve(packagesPath, name, 'src', subPkgName, 'index.ts'),
})
})
paths.push({
find: `@tiptap/${name}`,
replacement: resolve(`../${path}/${name}/src/index.ts`),
replacement: resolve(packagesPath, name, 'src/index.ts'),
})
} else {
paths.push({
find: `@tiptap/${name}`,
replacement: resolve(`../${path}/${name}/src/index.ts`),
replacement: resolve(packagesPath, name, 'src/index.ts'),
})
}
})
@@ -63,18 +65,18 @@ const getPackageDependencies = () => {
// Handle the JSX runtime alias
paths.unshift({
find: '@tiptap/core/jsx-runtime',
replacement: resolve('../packages/core/src/jsx-runtime.ts'),
replacement: resolve(import.meta.dirname, '../packages/core/src/jsx-runtime.ts'),
})
paths.unshift({
find: '@tiptap/core/jsx-dev-runtime',
replacement: resolve('../packages/core/src/jsx-runtime.ts'),
replacement: resolve(import.meta.dirname, '../packages/core/src/jsx-runtime.ts'),
})
return paths
}
const dedupeDeps = fs
.readFileSync('./dedupeDeps.txt')
.readFileSync(resolve(import.meta.dirname, 'dedupeDeps.txt'))
.toString()
.replace(/\r\n/g, '\n')
.split('\n')
@@ -91,6 +93,8 @@ export default defineConfig({
build: {
rolldownOptions: {
input: fg.sync('./**/index.html', {
absolute: true,
cwd: import.meta.dirname,
ignore: ['dist', 'node_modules'],
}),
},
+8 -10
View File
@@ -8,12 +8,12 @@
"cz": "cz",
"start": "vp run --filter ./demos start",
"dev": "vp run start",
"check": "vp run format && vp run lint",
"check:fix": "vp run format:fix && vp run lint:fix",
"format": "oxfmt --check",
"format:fix": "oxfmt",
"lint": "oxlint",
"lint:fix": "oxlint --fix",
"check": "vp check",
"check:fix": "vp check --fix",
"format": "vp fmt --check",
"format:fix": "vp fmt",
"lint": "vp lint",
"lint:fix": "vp lint --fix",
"lint:staged": "vp staged",
"fallow": "fallow",
"fallow:audit": "fallow audit",
@@ -38,11 +38,11 @@
"clean:packages": "rm -rf ./packages/*/dist && rm -rf ./packages/pm/*/dist && rm -rf ./packages-deprecated/*/dist",
"clean:packs": "rm -rf ./packages/*/*.tgz && rm -rf ./packages-deprecated/*/*.tgz",
"make:demo": "sh ./scripts/make-demo.sh",
"reset": "vp run clean:packages && vp run clean:packs && rm -rf ./**/.cache && rm -rf ./**/node_modules && rm -rf ./package-lock.json && pnpm install",
"reset": "vp run clean:packages && vp run clean:packs && rm -rf ./**/.cache && rm -rf ./**/node_modules && rm -rf ./package-lock.json && vp install",
"prepare": "vp config --no-agent",
"changeset": "changeset",
"changelog": "node ./scripts/aggregate-changeset.js",
"version": "vp run changelog && vp run changeset -- version && pnpm install --no-frozen-lockfile",
"version": "vp run changelog && vp run changeset -- version && vp install --no-frozen-lockfile",
"publish:markdown": "vp run build && vp exec changeset publish --tag markdown",
"version:markdown": "vp run changeset version --snapshot markdown"
},
@@ -69,8 +69,6 @@
"http-server": "14.1.1",
"lowlight": "^3.3.0",
"minimist": "^1.2.8",
"oxfmt": "^0.51.0",
"oxlint": "^1.66.0",
"pkg-pr-new": "0.0.66",
"react": "^19.0.0",
"tinyglobby": "0.2.10",
@@ -3,7 +3,7 @@
import { Editor } from '@tiptap/core'
import { Collaboration } from '@tiptap/extension-collaboration'
import StarterKit from '@tiptap/starter-kit'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
import * as Y from 'yjs'
import { AiInsertReveal } from '../src/streaming-reveal.js'
+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest'
import { describe, expect, it } from 'vite-plus/test'
import { Fragment, h, jsx, jsxs } from '../src/jsx-runtime.js'
+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest'
import { describe, expect, it } from 'vite-plus/test'
import { Editor } from '../Editor.js'
import { Extension } from '../Extension.js'
import StarterKit from '@tiptap/starter-kit'
+1 -1
View File
@@ -20,7 +20,7 @@ export default defineConfig({
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
],
webServer: {
command: 'pnpm -C demos run start:e2e',
command: 'vp -C demos run start:e2e',
url: 'http://127.0.0.1:4080',
reuseExistingServer: !process.env.CI,
timeout: 120000,
+438 -1129
View File
File diff suppressed because it is too large Load Diff
+6 -10
View File
@@ -3,10 +3,8 @@ packages:
- 'packages-deprecated/*'
- 'demos'
catalog:
# vite is a vendored fork (vite-plus-core). Keep the peerDependencyRules
# allowedVersions below in lockstep when upgrading plugins.
vite: 'npm:@voidzero-dev/vite-plus-core@0.2.7'
vite-plus: '0.2.7'
vite: npm:@voidzero-dev/vite-plus-core@0.3.0
vite-plus: 0.3.0
allowBuilds:
'@parcel/watcher': true
esbuild: true
@@ -27,13 +25,11 @@ overrides:
'sass>immutable': '5.1.5'
'tinyglobby>picomatch': '4.0.4'
'vitest>picomatch': '4.0.4'
vite@*: 'catalog:'
peerDependencyRules:
allowedVersions:
'@sveltejs/vite-plugin-svelte@7.2.0>vite': '0.2.7'
'@vitejs/plugin-react@6.0.5>vite': '0.2.7'
'@vitejs/plugin-vue@6.0.8>vite': '0.2.7'
'@vitest/mocker@4.1.10>vite': '0.2.7'
'vitest@4.1.10>vite': '0.2.7'
'vitefu@1.1.3>vite': '0.2.7'
vite: '*'
allowAny:
- vite
patchedDependencies:
'@changesets/assemble-release-plan@6.0.10': 'patches/@changesets__assemble-release-plan@6.0.10.patch'
+4 -5
View File
@@ -12,15 +12,14 @@
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"sourceMap": true,
"baseUrl": ".",
"rootDir": ".",
"allowJs": true,
"checkJs": false,
"paths": {
"@tiptap/static-renderer/pm/*": ["packages/static-renderer/src/pm/*"],
"@tiptap/static-renderer/json/*": ["packages/static-renderer/src/json/*"],
"@tiptap/pm/*": ["packages/pm/*/index.ts"],
"@tiptap/*": ["packages/*/src/index.ts", "packages-deprecated/*/src/index.ts"]
"@tiptap/static-renderer/pm/*": ["./packages/static-renderer/src/pm/*"],
"@tiptap/static-renderer/json/*": ["./packages/static-renderer/src/json/*"],
"@tiptap/pm/*": ["./packages/pm/*/index.ts"],
"@tiptap/*": ["./packages/*/src/index.ts", "./packages-deprecated/*/src/index.ts"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
+18 -4
View File
@@ -68,6 +68,18 @@ const getPackageAliases = () => {
}
export default defineConfig({
fmt: {
ignorePatterns: ['CHANGELOG.md'],
semi: false,
singleQuote: true,
arrowParens: 'avoid',
},
lint: {
jsPlugins: [{ name: 'vite-plus', specifier: 'vite-plus/oxlint-plugin' }],
rules: { 'vite-plus/prefer-vite-plus-imports': 'error' },
// Enable after the existing workspace type errors are resolved.
// options: { typeAware: true, typeCheck: true },
},
run: {
// Cache package.json scripts (build, lint, test, ...). Persistent
// scripts like `dev` never exit, so they are never cached.
@@ -88,7 +100,7 @@ export default defineConfig({
const fileList = filteredFiles.join(' ')
return [`oxfmt ${fileList}`, `oxlint --fix --quiet --no-error-on-unmatched-pattern ${fileList}`]
return [`vp check --fix ${fileList}`]
},
resolve: {
alias: [
@@ -106,8 +118,10 @@ export default defineConfig({
})),
],
},
esbuild: {
jsx: 'automatic',
jsxImportSource: 'react',
oxc: {
jsx: {
runtime: 'automatic',
importSource: 'react',
},
},
})