fix: Upgrade unbuild to resolve console warning issues and also deal with post-upgrade compatibility issues (#4009)

pull/48/MERGE
Vben 2024-08-02 22:18:46 +08:00 committed by GitHub
parent e544119aa3
commit 530159140c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
48 changed files with 382 additions and 743 deletions

14
.github/CODEOWNERS vendored
View File

@ -1,7 +1,13 @@
# default onwer
* anncwb@126.com
* anncwb vince292007
# vben core onwer
/packages/@core/ anncwb@126.com
/internal/ anncwb@126.com
/scripts/ anncwb@126.com
/.github/ anncwb vince292007
/.vscode/ anncwb vince292007
/packages/@core/ anncwb vince292007
/internal/ anncwb vince292007
/scripts/ anncwb vince292007
# vben team onwer
apps/ vbenjs/team-v5
docs/ vbenjs/team-v5

View File

@ -14,8 +14,8 @@ body:
label: Version
description: What version of our software are you running?
options:
- Vben Admin Pro
- Vben Admin
- Vben Admin V5
- Vben Admin V2
default: 0
validations:
required: true

View File

@ -24,6 +24,7 @@ jobs:
shell: bash
run: |
sed -i "s#VITE_COMPRESS\s*=.*#VITE_COMPRESS = gzip#g" ./apps/web-antd/.env.production
sed -i "s#VITE_PWA\s*=.*#VITE_PWA = true#g" ./apps/web-antd/.env.production
cat ./apps/web-antd/.env.production
- name: Install pnpm

View File

@ -1 +1,20 @@
export { default } from '@vben/lint-staged-config';
export default {
'*.{js,jsx,ts,tsx}': [
'prettier --cache --ignore-unknown --write',
'eslint --cache --fix',
],
'*.{scss,less,styl,html,vue,css}': [
'prettier --cache --ignore-unknown --write',
'stylelint --fix --allow-empty-input',
],
'*.md': ['prettier --cache --ignore-unknown --write'],
'*.vue': [
'prettier --write',
'eslint --cache --fix',
'stylelint --fix --allow-empty-input',
],
'{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': [
'prettier --cache --write--parser json',
],
'package.json': ['prettier --cache --write'],
};

1
.npmrc
View File

@ -3,7 +3,6 @@ public-hoist-pattern[]=husky
public-hoist-pattern[]=eslint
public-hoist-pattern[]=prettier
public-hoist-pattern[]=prettier-plugin-tailwindcss
public-hoist-pattern[]=lint-staged
public-hoist-pattern[]=stylelint
public-hoist-pattern[]=*postcss*
public-hoist-pattern[]=@commitlint/*

View File

@ -21,7 +21,7 @@ RUN echo "Builder Success 🎉"
FROM nginx:stable-alpine as production
RUN echo "types { application/javascript js mjs; }" > /etc/nginx/conf.d/mjs.conf
COPY --from=builder /app/apps/antd-view/dist /usr/share/nginx/html
COPY --from=builder /app/apps/web-antd/dist /usr/share/nginx/html
COPY ./deploy/nginx.conf /etc/nginx/nginx.conf

View File

@ -25,7 +25,7 @@ function warning() {
}
function success() {
ElMessage.success(
"'Cause you walked hand in hand With another man in my place",
'Cause you walked hand in hand With another man in my place',
);
}

View File

@ -40,6 +40,7 @@
"nocheck",
"prefixs",
"vitepress",
"antdv",
"ependencies",
"vite",
"echarts",

View File

@ -1,7 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ['src/index'],
});

View File

@ -1,5 +1,3 @@
import type { UserConfig } from 'cz-git';
import { execSync } from 'node:child_process';
import { getPackagesSync } from '@vben/node-utils';
@ -27,7 +25,10 @@ const scopeComplete = execSync('git status --porcelain || true')
?.match(/src%%((\w|-)*)/)?.[1]
?.replace(/s$/, '');
const userConfig: UserConfig = {
/**
* @type {import('cz-git').UserConfig}
*/
const userConfig = {
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
prompt: {
@ -106,7 +107,7 @@ const userConfig: UserConfig = {
'function-rules/scope-enum': [
2, // level: error
'always',
(parsed: { scope: string }) => {
(parsed) => {
if (!parsed.scope || allowedScopes.includes(parsed.scope)) {
return [true];
}

View File

@ -11,20 +11,15 @@
},
"license": "MIT",
"type": "module",
"scripts": {
"stub": "pnpm unbuild --stub"
},
"files": [
"dist"
],
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"main": "./index.mjs",
"module": "./index.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
"import": "./index.mjs",
"default": "./index.mjs"
}
},
"dependencies": {

View File

@ -1,6 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@vben/tsconfig/node.json",
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@ -1,9 +1,11 @@
import type { Linter } from 'eslint';
export async function comments(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function comments(): Promise<Linter.Config[]> {
const [pluginComments] = await Promise.all([
// @ts-expect-error - no types
import('eslint-plugin-eslint-comments'),
interopDefault(import('eslint-plugin-eslint-comments')),
] as const);
return [

View File

@ -1,6 +1,6 @@
import type { Linter } from 'eslint';
export async function disableds(): Promise<Linter.FlatConfig[]> {
export async function disableds(): Promise<Linter.Config[]> {
return [
{
files: ['**/__tests__/**/*.?([cm])[jt]s?(x)'],

View File

@ -1,6 +1,6 @@
import type { Linter } from 'eslint';
export async function ignores(): Promise<Linter.FlatConfig[]> {
export async function ignores(): Promise<Linter.Config[]> {
return [
{
ignores: [

View File

@ -6,7 +6,7 @@ import js from '@eslint/js';
import pluginUnusedImports from 'eslint-plugin-unused-imports';
import globals from 'globals';
export async function javascript(): Promise<Linter.FlatConfig[]> {
export async function javascript(): Promise<Linter.Config[]> {
return [
{
languageOptions: {

View File

@ -1,14 +1,15 @@
import type { Linter } from 'eslint';
export async function jsdoc(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function jsdoc(): Promise<Linter.Config[]> {
const [pluginJsdoc] = await Promise.all([
import('eslint-plugin-jsdoc'),
interopDefault(import('eslint-plugin-jsdoc')),
] as const);
return [
{
plugins: {
// @ts-expect-error - no types
jsdoc: pluginJsdoc,
},
rules: {

View File

@ -1,9 +1,11 @@
import type { Linter } from 'eslint';
export async function jsonc(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function jsonc(): Promise<Linter.Config[]> {
const [pluginJsonc, parserJsonc] = await Promise.all([
import('eslint-plugin-jsonc'),
import('jsonc-eslint-parser'),
interopDefault(import('eslint-plugin-jsonc')),
interopDefault(import('jsonc-eslint-parser')),
] as const);
return [

View File

@ -1,7 +1,9 @@
import type { Linter } from 'eslint';
export async function node(): Promise<Linter.FlatConfig[]> {
const [pluginNode] = await Promise.all([import('eslint-plugin-n')] as const);
import { interopDefault } from '../util';
export async function node(): Promise<Linter.Config[]> {
const pluginNode = await interopDefault(import('eslint-plugin-n'));
return [
{

View File

@ -2,7 +2,7 @@ import type { Linter } from 'eslint';
import perfectionistPlugin from 'eslint-plugin-perfectionist';
export async function perfectionist(): Promise<Linter.FlatConfig[]> {
export async function perfectionist(): Promise<Linter.Config[]> {
return [
perfectionistPlugin.configs['recommended-natural'],
{

View File

@ -1,8 +1,10 @@
import type { Linter } from 'eslint';
export async function prettier(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function prettier(): Promise<Linter.Config[]> {
const [pluginPrettier] = await Promise.all([
import('eslint-plugin-prettier'),
interopDefault(import('eslint-plugin-prettier')),
] as const);
return [
{

View File

@ -1,8 +1,10 @@
import type { Linter } from 'eslint';
export async function regexp(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function regexp(): Promise<Linter.Config[]> {
const [pluginRegexp] = await Promise.all([
import('eslint-plugin-regexp'),
interopDefault(import('eslint-plugin-regexp')),
] as const);
return [

View File

@ -1,10 +1,12 @@
import type { Linter } from 'eslint';
export async function test(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function test(): Promise<Linter.Config[]> {
const [pluginTest, pluginNoOnlyTests] = await Promise.all([
import('eslint-plugin-vitest'),
interopDefault(import('eslint-plugin-vitest')),
// @ts-expect-error - no types
import('eslint-plugin-no-only-tests'),
interopDefault(import('eslint-plugin-no-only-tests')),
] as const);
return [

View File

@ -1,9 +1,11 @@
import type { Linter } from 'eslint';
export async function turbo(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function turbo(): Promise<Linter.Config[]> {
const [pluginTurbo] = await Promise.all([
// @ts-expect-error - no types
import('eslint-config-turbo'),
interopDefault(import('eslint-config-turbo')),
] as const);
return [

View File

@ -1,10 +1,12 @@
import type { Linter } from 'eslint';
export async function typescript(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function typescript(): Promise<Linter.Config[]> {
const [pluginTs, parserTs] = await Promise.all([
import('@typescript-eslint/eslint-plugin'),
interopDefault(import('@typescript-eslint/eslint-plugin')),
// @ts-expect-error missing types
import('@typescript-eslint/parser'),
interopDefault(import('@typescript-eslint/parser')),
] as const);
return [

View File

@ -1,9 +1,10 @@
import type { Linter } from 'eslint';
export async function unicorn(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function unicorn(): Promise<Linter.Config[]> {
const [pluginUnicorn] = await Promise.all([
// @ts-expect-error - missing types
import('eslint-plugin-unicorn'),
interopDefault(import('eslint-plugin-unicorn')),
] as const);
return [

View File

@ -1,12 +1,14 @@
import type { Linter } from 'eslint';
export async function vue(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';
export async function vue(): Promise<Linter.Config[]> {
const [pluginVue, parserVue, parserTs] = await Promise.all([
// @ts-expect-error missing types
import('eslint-plugin-vue'),
import('vue-eslint-parser'),
interopDefault(import('eslint-plugin-vue')),
interopDefault(import('vue-eslint-parser')),
// @ts-expect-error missing types
import('@typescript-eslint/parser'),
interopDefault(import('@typescript-eslint/parser')),
] as const);
return [

View File

@ -0,0 +1,8 @@
export type Awaitable<T> = Promise<T> | T;
export async function interopDefault<T>(
m: Awaitable<T>,
): Promise<T extends { default: infer U } ? U : T> {
const resolved = await m;
return (resolved as any).default || resolved;
}

View File

@ -1,7 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ['src/index'],
});

View File

@ -1,33 +0,0 @@
{
"name": "@vben/lint-staged-config",
"version": "5.0.0",
"private": true,
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
"directory": "internal/lint-configs/lint-staged-config"
},
"license": "MIT",
"type": "module",
"scripts": {
"stub": "pnpm unbuild --stub"
},
"files": [
"dist"
],
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
}
},
"dependencies": {
"lint-staged": "^15.2.7"
}
}

View File

@ -1,20 +0,0 @@
export default {
'*.{js,jsx,ts,tsx}': [
'prettier --cache --ignore-unknown --write',
'eslint --cache --fix',
],
'*.{scss,less,styl,html,vue,css}': [
'prettier --cache --ignore-unknown --write',
'stylelint --fix --allow-empty-input',
],
'*.md': ['prettier --cache --ignore-unknown --write'],
'*.vue': [
'prettier --write',
'eslint --cache --fix',
'stylelint --fix --allow-empty-input',
],
'{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': [
'prettier --cache --write--parser json',
],
'package.json': ['prettier --cache --write'],
};

View File

@ -1,6 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@vben/tsconfig/node.json",
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@ -1,7 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ['src/index'],
});

View File

@ -11,20 +11,14 @@
},
"license": "MIT",
"type": "module",
"scripts": {
"stub": "pnpm unbuild --stub"
},
"files": [
"dist"
],
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"main": "./index.mjs",
"module": "./index.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
"default": "./index.mjs"
}
},
"dependencies": {

View File

@ -1,6 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@vben/tsconfig/node.json",
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@ -1,7 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ['src/index'],
});

View File

@ -11,20 +11,15 @@
},
"license": "MIT",
"type": "module",
"scripts": {
"stub": "pnpm unbuild --stub"
},
"files": [
"dist"
],
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"main": "./index.mjs",
"module": "./index.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
"import": "./index.mjs",
"default": "./index.mjs"
}
},
"dependencies": {

View File

@ -1,6 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@vben/tsconfig/node.json",
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@ -11,7 +11,9 @@ export type { Package } from '@manypkg/get-packages';
export { default as colors } from 'chalk';
export { consola } from 'consola';
export * from 'execa';
export { default as fs } from 'fs-extra';
export * as fs from 'fs-extra';
export { nanoid } from 'nanoid';
export { type PackageJson, readPackageJSON } from 'pkg-types';
export { rimraf } from 'rimraf';

View File

@ -1,5 +1,6 @@
import plugin from 'tailwindcss/plugin.js';
import * as plugin from 'tailwindcss/plugin.js';
// @ts-expect-error Parameter 'addUtilities' implicitly has an 'any' type.
const enterAnimationPlugin = plugin(({ addUtilities }) => {
const maxChild = 5;
const utilities: Record<string, any> = {};

View File

@ -4,7 +4,7 @@ import { join } from 'node:path';
import { fs } from '@vben/node-utils';
import dotenv from 'dotenv';
import * as dotenv from 'dotenv';
/**
*

View File

@ -62,7 +62,6 @@
"@types/node": "^22.0.2",
"@vben/commitlint-config": "workspace:*",
"@vben/eslint-config": "workspace:*",
"@vben/lint-staged-config": "workspace:*",
"@vben/prettier-config": "workspace:*",
"@vben/stylelint-config": "workspace:*",
"@vben/tailwind-config": "workspace:*",
@ -77,11 +76,12 @@
"husky": "^9.1.4",
"is-ci": "^3.0.1",
"jsdom": "^24.1.1",
"lint-staged": "^15.2.7",
"rimraf": "^6.0.1",
"tailwindcss": "^3.4.7",
"turbo": "^2.0.11",
"typescript": "^5.5.4",
"unbuild": "^2.0.0",
"unbuild": "^3.0.0-rc.7",
"vite": "^5.3.5",
"vitest": "^2.0.5",
"vue-tsc": "^2.0.29"

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,9 @@ async function runLint({ format }: LintCommandOptions) {
await execaCommand(`stylelint "**/*.{vue,css,less.scss}" --cache --fix`, {
stdio: 'inherit',
});
await execaCommand(`eslint . --cache --fix`, {
stdio: 'inherit',
});
// await execaCommand(`eslint . --cache --fix`, {
// stdio: 'inherit',
// });
await execaCommand(`prettier . --write --cache --log-level warn`, {
stdio: 'inherit',
});

View File

@ -37,11 +37,6 @@
"cache": false,
"persistent": true
},
"@vben/backend#dev": {
"outputs": [],
"cache": false,
"persistent": true
},
"typecheck": {
"outputs": []
}

View File

@ -28,10 +28,6 @@
"name": "@vben/eslint-config",
"path": "internal/lint-configs/eslint-config",
},
{
"name": "@vben/lint-staged-config",
"path": "internal/lint-configs/lint-staged-config",
},
{
"name": "@vben/prettier-config",
"path": "internal/lint-configs/prettier-config",