diff --git a/.gitignore b/.gitignore
index e7fa2a6cb..bbfb1619c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,5 @@ package-lock.json
es
lib
dist
-vetur
**/site-dist
changelog.generated.md
diff --git a/README.md b/README.md
index b8af6f9d4..4843d6ca0 100644
--- a/README.md
+++ b/README.md
@@ -4,14 +4,13 @@
Vant
-Mobile UI Components built on Vue
+Lightweight Mobile UI Components built on Vue
-
@@ -29,6 +28,7 @@
- 🚀 1KB Component average size (min+gzip)
- 🚀 70+ High quality components
+- 🚀 Zero third-party dependencies
- 💪 90%+ Unit test coverage
- 💪 Written in TypeScript
- 📖 Extensive documentation and demos
diff --git a/README.zh-CN.md b/README.zh-CN.md
index bb83e980a..a1e5b4de2 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -11,7 +11,6 @@
-
@@ -33,6 +32,7 @@ Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
- 🚀 性能极佳,组件平均体积小于 1KB(min+gzip)
- 🚀 70+ 个高质量组件,覆盖移动端主流场景
+- 🚀 零外部依赖,不依赖三方 npm 包
- 💪 使用 TypeScript 编写,提供完整的类型定义
- 💪 单元测试覆盖率超过 90%,提供稳定性保障
- 📖 提供丰富的中英文文档和组件示例
diff --git a/packages/create-vant-cli-app/generators/vue3/.gitignore.tpl b/packages/create-vant-cli-app/generators/vue3/.gitignore.tpl
index 45c042e07..ab4ed5005 100644
--- a/packages/create-vant-cli-app/generators/vue3/.gitignore.tpl
+++ b/packages/create-vant-cli-app/generators/vue3/.gitignore.tpl
@@ -15,6 +15,5 @@ test/coverage
es
lib
dist
-vetur
site
changelog.generated.md
diff --git a/packages/vant-cli/README.zh-CN.md b/packages/vant-cli/README.zh-CN.md
index 02b2889c5..cb8f72123 100644
--- a/packages/vant-cli/README.zh-CN.md
+++ b/packages/vant-cli/README.zh-CN.md
@@ -1,9 +1,10 @@
# Vant CLI
-Vant CLI 是一个 Vue 组件库构建工具,通过 Vant CLI 可以快速搭建一套功能完备的 Vue 组件库。
+Vant CLI 是一个基于 Vite 实现的 Vue 组件库构建工具,通过 Vant CLI 可以快速搭建一套功能完备的 Vue 组件库。
### 特性
+- 基于 Vite 实现,享受愉悦的开发体验
- 提供丰富的命令,涵盖从开发测试到构建发布的完整流程
- 基于约定的目录结构,自动生成优雅的文档站点和组件示例
- 内置 ESLint 校验规则,提交代码时自动执行校验
diff --git a/packages/vant-cli/changelog.md b/packages/vant-cli/changelog.md
index 26226fbe6..6239f3c36 100644
--- a/packages/vant-cli/changelog.md
+++ b/packages/vant-cli/changelog.md
@@ -25,6 +25,12 @@
yarn add stylelint@13 @vant/stylelint-config
```
+### 移除 vetur 相关配置
+
+由于 Vue 3 推荐使用 volar 而不是 vetur,因此移除了 vetur 相关的配置文件。
+
+现在会默认生成 WebStorm 所需的 web-types.json 文件到 `lib/web-types.json` 目录下。
+
## v4.0.3
`2022-07-02`
diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json
index cd4bef300..7beb04e38 100644
--- a/packages/vant-cli/package.json
+++ b/packages/vant-cli/package.json
@@ -54,7 +54,6 @@
"@docsearch/js": "^3.0.0",
"@types/jest": "^27.0.3",
"@vant/eslint-config": "^3.3.2",
- "@vant/markdown-vetur": "^2.3.0",
"@vant/touch-emulator": "^1.3.2",
"@vitejs/plugin-vue": "^3.0.1",
"@vitejs/plugin-vue-jsx": "^2.0.0",
diff --git a/packages/vant-cli/src/commands/build.ts b/packages/vant-cli/src/commands/build.ts
index 80b6743bf..d848cb3ce 100644
--- a/packages/vant-cli/src/commands/build.ts
+++ b/packages/vant-cli/src/commands/build.ts
@@ -14,7 +14,7 @@ import { genStyleDepsMap } from '../compiler/gen-style-deps-map.js';
import { genComponentStyle } from '../compiler/gen-component-style.js';
import { SRC_DIR, LIB_DIR, ES_DIR } from '../common/constant.js';
import { genPackageStyle } from '../compiler/gen-package-style.js';
-import { genVeturConfig } from '../compiler/gen-vetur-config.js';
+import { genWebStormTypes } from '../compiler/web-types/index.js';
import {
isDir,
isSfc,
@@ -137,7 +137,7 @@ async function buildPackageStyleEntry() {
async function buildBundledOutputs() {
setModuleEnv('esmodule');
await compileBundles();
- genVeturConfig();
+ genWebStormTypes();
}
const tasks = [
diff --git a/packages/vant-cli/src/commands/clean.ts b/packages/vant-cli/src/commands/clean.ts
index 501fce953..e49e5d9ef 100644
--- a/packages/vant-cli/src/commands/clean.ts
+++ b/packages/vant-cli/src/commands/clean.ts
@@ -3,7 +3,6 @@ import {
ES_DIR,
LIB_DIR,
DIST_DIR,
- VETUR_DIR,
SITE_DIST_DIR,
} from '../common/constant.js';
@@ -14,7 +13,6 @@ export async function clean() {
remove(ES_DIR),
remove(LIB_DIR),
remove(DIST_DIR),
- remove(VETUR_DIR),
remove(SITE_DIST_DIR),
]);
}
diff --git a/packages/vant-cli/src/common/constant.ts b/packages/vant-cli/src/common/constant.ts
index 89034bbb3..7ae07fd78 100644
--- a/packages/vant-cli/src/common/constant.ts
+++ b/packages/vant-cli/src/common/constant.ts
@@ -21,7 +21,6 @@ export const ROOT = findRootDir(CWD);
export const ES_DIR = join(ROOT, 'es');
export const LIB_DIR = join(ROOT, 'lib');
export const DOCS_DIR = join(ROOT, 'docs');
-export const VETUR_DIR = join(ROOT, 'vetur');
export const SITE_DIST_DIR = join(ROOT, 'site-dist');
export const VANT_CONFIG_FILE = join(ROOT, 'vant.config.mjs');
export const PACKAGE_JSON_FILE = join(ROOT, 'package.json');
diff --git a/packages/vant-cli/src/compiler/gen-vetur-config.ts b/packages/vant-cli/src/compiler/gen-vetur-config.ts
deleted file mode 100644
index be9cf312b..000000000
--- a/packages/vant-cli/src/compiler/gen-vetur-config.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import markdownVetur from '@vant/markdown-vetur';
-import {
- SRC_DIR,
- VETUR_DIR,
- getVantConfig,
- getPackageJson,
-} from '../common/constant.js';
-
-// generate vetur tags & attributes
-export function genVeturConfig() {
- const pkgJson = getPackageJson();
- const vantConfig = getVantConfig();
- const options = vantConfig.build?.vetur;
-
- if (options) {
- markdownVetur.parseAndWrite({
- name: vantConfig.name,
- path: SRC_DIR,
- test: /README\.md/,
- version: pkgJson.version,
- outputDir: VETUR_DIR,
- ...options,
- });
- }
-}
diff --git a/packages/vant-markdown-vetur/src/formatter.ts b/packages/vant-cli/src/compiler/web-types/formatter.ts
similarity index 85%
rename from packages/vant-markdown-vetur/src/formatter.ts
rename to packages/vant-cli/src/compiler/web-types/formatter.ts
index 383282207..bf9f8efae 100644
--- a/packages/vant-markdown-vetur/src/formatter.ts
+++ b/packages/vant-cli/src/compiler/web-types/formatter.ts
@@ -1,14 +1,19 @@
/* eslint-disable no-continue */
-import { Articals } from './parser';
-import { formatOptions, formatType, removeVersion, toKebabCase } from './utils';
-import { VueEventArgument, VueTag } from './type';
+import { Articles } from './parser.js';
+import {
+ formatOptions,
+ formatType,
+ removeVersion,
+ toKebabCase,
+} from './utils.js';
+import { VueEventArgument, VueTag } from './type.js';
function formatComponentName(name: string, tagPrefix: string) {
return tagPrefix + toKebabCase(name);
}
/**
- * format arugments of events
+ * format arguments of events
* input = value: { foo: foo or 1, bar: bar or 2 }, value2: { one: 1 and 1, two: 2 and 2 }, foo: bar
* output = [{ name: 'value', type: '{ foo: foo or 1, bar: bar or 2 }' }, { name: 'value2', type: '{ one: 1 and 1, two: 2 and 2 }'}, { name: 'foo', type: 'bar' }]
*/
@@ -73,29 +78,29 @@ function findTag(vueTags: VueTag[], name: string) {
export function formatter(
vueTags: VueTag[],
- articals: Articals,
+ articles: Articles,
tagPrefix = ''
) {
- if (!articals.length) {
+ if (!articles.length) {
return;
}
- const mainTitle = articals[0].content;
+ const mainTitle = articles[0].content;
const defaultName = mainTitle
? formatComponentName(mainTitle.split(' ')[0], tagPrefix)
: '';
- const tables = articals.filter((artical) => artical.type === 'table');
+ const tables = articles.filter((article) => article.type === 'table');
tables.forEach((item) => {
const { table } = item;
- const prevIndex = articals.indexOf(item) - 1;
- const prevArtical = articals[prevIndex];
+ const prevIndex = articles.indexOf(item) - 1;
+ const prevArticle = articles[prevIndex];
- if (!prevArtical || !prevArtical.content || !table || !table.body) {
+ if (!prevArticle || !prevArticle.content || !table || !table.body) {
return;
}
- const tableTitle = prevArtical.content;
+ const tableTitle = prevArticle.content;
if (tableTitle.includes('Props')) {
const name = getNameFromTableTitle(tableTitle, tagPrefix) || defaultName;
diff --git a/packages/vant-cli/src/compiler/web-types/index.ts b/packages/vant-cli/src/compiler/web-types/index.ts
new file mode 100644
index 000000000..74eaf46d8
--- /dev/null
+++ b/packages/vant-cli/src/compiler/web-types/index.ts
@@ -0,0 +1,54 @@
+import glob from 'fast-glob';
+import { join } from 'path';
+import fse from 'fs-extra';
+import { mdParser } from './parser.js';
+import { formatter } from './formatter.js';
+import { genWebTypes } from './web-types.js';
+import { Options, VueTag } from './type.js';
+import { normalizePath } from './utils.js';
+import {
+ SRC_DIR,
+ LIB_DIR,
+ getVantConfig,
+ getPackageJson,
+} from '../../common/constant.js';
+
+async function readMarkdown(options: Options) {
+ const mds = await glob(normalizePath(`${options.path}/**/*.md`));
+ return mds
+ .filter((md) => options.test.test(md))
+ .map((path) => fse.readFileSync(path, 'utf-8'));
+}
+
+export async function parseAndWrite(options: Options) {
+ if (!options.outputDir) {
+ throw new Error('outputDir can not be empty.');
+ }
+
+ const mds = await readMarkdown(options);
+ const vueTags: VueTag[] = [];
+
+ mds.forEach((md) => {
+ const parsedMd = mdParser(md);
+ formatter(vueTags, parsedMd, options.tagPrefix);
+ });
+
+ const webTypes = genWebTypes(vueTags, options);
+ fse.outputFileSync(
+ join(options.outputDir, 'web-types.json'),
+ JSON.stringify(webTypes, null, 2)
+ );
+}
+
+export function genWebStormTypes() {
+ const pkgJson = getPackageJson();
+ const vantConfig = getVantConfig();
+
+ parseAndWrite({
+ name: vantConfig.name,
+ path: SRC_DIR,
+ test: /README\.md/,
+ version: pkgJson.version,
+ outputDir: LIB_DIR,
+ });
+}
diff --git a/packages/vant-markdown-vetur/src/parser.ts b/packages/vant-cli/src/compiler/web-types/parser.ts
similarity index 91%
rename from packages/vant-markdown-vetur/src/parser.ts
rename to packages/vant-cli/src/compiler/web-types/parser.ts
index fb3776873..cfd73705c 100644
--- a/packages/vant-markdown-vetur/src/parser.ts
+++ b/packages/vant-cli/src/compiler/web-types/parser.ts
@@ -9,14 +9,14 @@ type TableContent = {
body: string[][];
};
-export type Artical = {
+export type Article = {
type: string;
content?: string;
table?: TableContent;
level?: number;
};
-export type Articals = Artical[];
+export type Articles = Article[];
function readLine(input: string) {
const end = input.indexOf('\n');
@@ -75,8 +75,8 @@ function tableParse(input: string) {
};
}
-export function mdParser(input: string): Articals {
- const artical = [];
+export function mdParser(input: string): Articles {
+ const article = [];
let start = 0;
const end = input.length;
@@ -85,7 +85,7 @@ export function mdParser(input: string): Articals {
let match;
if ((match = TITLE_REG.exec(target))) {
- artical.push({
+ article.push({
type: 'title',
content: match[2],
level: match[1].length,
@@ -94,7 +94,7 @@ export function mdParser(input: string): Articals {
start += match.index + match[0].length;
} else if ((match = TABLE_REG.exec(target))) {
const { table, usedLength } = tableParse(target.substr(match.index));
- artical.push({
+ article.push({
type: 'table',
table,
});
@@ -105,5 +105,5 @@ export function mdParser(input: string): Articals {
}
}
- return artical;
+ return article;
}
diff --git a/packages/vant-markdown-vetur/src/type.ts b/packages/vant-cli/src/compiler/web-types/type.ts
similarity index 66%
rename from packages/vant-markdown-vetur/src/type.ts
rename to packages/vant-cli/src/compiler/web-types/type.ts
index 108df7e3c..58648efd9 100644
--- a/packages/vant-markdown-vetur/src/type.ts
+++ b/packages/vant-cli/src/compiler/web-types/type.ts
@@ -35,26 +35,6 @@ export type VueTag = {
description?: string;
};
-export type VeturTag = {
- description?: string;
- attributes: string[];
-};
-
-export type VeturTags = Record;
-
-export type VeturAttribute = {
- type: string;
- description: string;
- options?: string[];
-};
-
-export type VeturAttributes = Record;
-
-export type VeturResult = {
- tags: VeturTags;
- attributes: VeturAttributes;
-};
-
export type Options = {
name: string;
path: PathLike;
diff --git a/packages/vant-markdown-vetur/src/utils.ts b/packages/vant-cli/src/compiler/web-types/utils.ts
similarity index 100%
rename from packages/vant-markdown-vetur/src/utils.ts
rename to packages/vant-cli/src/compiler/web-types/utils.ts
diff --git a/packages/vant-markdown-vetur/src/web-types.ts b/packages/vant-cli/src/compiler/web-types/web-types.ts
similarity index 90%
rename from packages/vant-markdown-vetur/src/web-types.ts
rename to packages/vant-cli/src/compiler/web-types/web-types.ts
index 76b46218d..144f24890 100644
--- a/packages/vant-markdown-vetur/src/web-types.ts
+++ b/packages/vant-cli/src/compiler/web-types/web-types.ts
@@ -1,4 +1,4 @@
-import { VueTag, Options } from './type';
+import type { VueTag, Options } from './type.js';
// create web-types.json to provide autocomplete in JetBrains IDEs
export function genWebTypes(tags: VueTag[], options: Options) {
diff --git a/packages/vant-cli/src/config/vite.package.ts b/packages/vant-cli/src/config/vite.package.ts
index 467416e84..a69eb6f84 100644
--- a/packages/vant-cli/src/config/vite.package.ts
+++ b/packages/vant-cli/src/config/vite.package.ts
@@ -14,12 +14,19 @@ export function getViteConfigForPackage({
const { name, build } = getVantConfig();
const entryExtension = build?.extensions?.esm || '.js';
const entry = join(ES_DIR, `index${entryExtension}`);
+ const shouldReplaceEnv = minify || formats?.includes('umd');
return {
root: CWD,
logLevel: 'silent',
+ define: shouldReplaceEnv
+ ? {
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
+ }
+ : undefined,
+
build: {
lib: {
name,
@@ -30,6 +37,7 @@ export function getViteConfigForPackage({
return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`;
},
},
+
// terser has better compression than esbuild
minify: minify ? 'terser' : false,
rollupOptions: {
diff --git a/packages/vant-cli/src/module.d.ts b/packages/vant-cli/src/module.d.ts
index 9919346f4..a623ae1e7 100644
--- a/packages/vant-cli/src/module.d.ts
+++ b/packages/vant-cli/src/module.d.ts
@@ -4,4 +4,3 @@ declare module 'hash-sum';
declare module '@babel/core';
declare module 'release-it';
declare module 'conventional-changelog';
-declare module '@vant/markdown-vetur';
diff --git a/packages/vant-markdown-vetur/LICENSE b/packages/vant-markdown-vetur/LICENSE
deleted file mode 100644
index 26ef2dcc9..000000000
--- a/packages/vant-markdown-vetur/LICENSE
+++ /dev/null
@@ -1,10 +0,0 @@
-MIT License
-
-Copyright (c) Youzan
-Copyright (c) Chen Jiahan and other contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/packages/vant-markdown-vetur/README.md b/packages/vant-markdown-vetur/README.md
deleted file mode 100644
index f759d01e3..000000000
--- a/packages/vant-markdown-vetur/README.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Vant Markdown Vetur
-
-将 .md 文件转换成能描述 vue 组件的 .json 文件,供 WebStorm 和 vscode 的 `vetur` 插件读取,从而可以在 vue 模版语法中拥有自动补全的功能。
-
-## Install
-
-```shell
-# with npm
-npm i @vant/markdown-vetur -D
-
-# with yarn
-yarn add @vant/markdown-vetur -D
-
-# with pnpm
-pnpm add @vant/markdown-vetur -D
-```
-
-## API
-
-#### parseAndWrite
-
-解析目录下所有匹配的文件,并输出为 tags.json 和 attributes.json
-
-```ts
-interface Options {
- // 需要解析的文件夹路径
- path: PathLike;
- // 文件匹配正则
- test: RegExp;
- // 输出目录
- outputDir: string;
- // 递归的目录最大深度
- maxDeep?: number;
- // 解析出来的组件名前缀
- tagPrefix?: string;
-}
-```
diff --git a/packages/vant-markdown-vetur/package.json b/packages/vant-markdown-vetur/package.json
deleted file mode 100644
index 7c8927ca5..000000000
--- a/packages/vant-markdown-vetur/package.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": "@vant/markdown-vetur",
- "version": "2.3.0",
- "description": "simple parse markdown to vue component description for vetur auto-completion",
- "main": "lib/index.js",
- "files": [
- "lib"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "build": "rimraf ./lib && tsc",
- "release": "pnpm build && npm publish",
- "prepare": "pnpm build"
- },
- "publishConfig": {
- "access": "public",
- "registry": "https://registry.npmjs.org/"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/vant-ui/vant.git",
- "directory": "packages/vant-markdown-vetur"
- },
- "bugs": "https://github.com/vant-ui/vant/issues",
- "author": "zhangshuai",
- "license": "MIT",
- "dependencies": {
- "fast-glob": "^3.2.2",
- "fs-extra": "^10.0.0"
- },
- "devDependencies": {
- "@types/fs-extra": "^9.0.13",
- "typescript": "^4.7.4"
- }
-}
diff --git a/packages/vant-markdown-vetur/src/index.ts b/packages/vant-markdown-vetur/src/index.ts
deleted file mode 100644
index 3825010d2..000000000
--- a/packages/vant-markdown-vetur/src/index.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import glob from 'fast-glob';
-import { join } from 'path';
-import { mdParser } from './parser';
-import { formatter } from './formatter';
-import { genWebTypes } from './web-types';
-import { readFileSync, outputFileSync } from 'fs-extra';
-import { Options, VueTag } from './type';
-import { normalizePath } from './utils';
-import { genVeturTags, genVeturAttributes } from './vetur';
-
-async function readMarkdown(options: Options) {
- const mds = await glob(normalizePath(`${options.path}/**/*.md`));
- return mds
- .filter((md) => options.test.test(md))
- .map((path) => readFileSync(path, 'utf-8'));
-}
-
-export async function parseAndWrite(options: Options) {
- if (!options.outputDir) {
- throw new Error('outputDir can not be empty.');
- }
-
- const mds = await readMarkdown(options);
- const vueTags: VueTag[] = [];
-
- mds.forEach((md) => {
- const parsedMd = mdParser(md);
- formatter(vueTags, parsedMd, options.tagPrefix);
- });
-
- const webTypes = genWebTypes(vueTags, options);
- const veturTags = genVeturTags(vueTags);
- const veturAttributes = genVeturAttributes(vueTags);
-
- outputFileSync(
- join(options.outputDir, 'tags.json'),
- JSON.stringify(veturTags, null, 2)
- );
- outputFileSync(
- join(options.outputDir, 'attributes.json'),
- JSON.stringify(veturAttributes, null, 2)
- );
- outputFileSync(
- join(options.outputDir, 'web-types.json'),
- JSON.stringify(webTypes, null, 2)
- );
-}
-
-export default { parseAndWrite };
diff --git a/packages/vant-markdown-vetur/src/vetur.ts b/packages/vant-markdown-vetur/src/vetur.ts
deleted file mode 100644
index 8f6e40392..000000000
--- a/packages/vant-markdown-vetur/src/vetur.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { VueTag, VeturTags, VeturAttributes, VeturAttribute } from './type';
-
-export function genVeturTags(tags: VueTag[]) {
- const veturTags: VeturTags = {};
-
- tags.forEach((tag) => {
- veturTags[tag.name] = {
- attributes: tag.attributes ? tag.attributes.map((item) => item.name) : [],
- };
- });
-
- return veturTags;
-}
-
-export function genVeturAttributes(tags: VueTag[]) {
- const veturAttributes: VeturAttributes = {};
-
- tags.forEach((tag) => {
- if (tag.attributes) {
- tag.attributes.forEach((attr) => {
- const attribute: VeturAttribute = {
- type: attr.value.type,
- description: `${attr.description}, Default: ${attr.default}`,
- };
-
- if (attr.options.length > 0) {
- attribute.options = attr.options;
- }
-
- veturAttributes[`${tag.name}/${attr.name}`] = attribute;
- });
- }
- });
-
- return veturAttributes;
-}
diff --git a/packages/vant-markdown-vetur/tsconfig.json b/packages/vant-markdown-vetur/tsconfig.json
deleted file mode 100644
index 738ecb181..000000000
--- a/packages/vant-markdown-vetur/tsconfig.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "target": "ES2019",
- "outDir": "./lib",
- "module": "commonjs",
- "declaration": true
- },
- "include": ["src/**/*"]
-}
diff --git a/packages/vant-touch-emulator/build.js b/packages/vant-touch-emulator/build.js
new file mode 100644
index 000000000..f28813b81
--- /dev/null
+++ b/packages/vant-touch-emulator/build.js
@@ -0,0 +1,11 @@
+const fs = require('fs');
+const path = require('path');
+
+const srcFile = path.join(__dirname, 'src', 'index.js');
+const distDir = path.join(__dirname, 'dist');
+
+if (!fs.existsSync(distDir)) {
+ fs.mkdirSync(distDir);
+}
+fs.copyFileSync(srcFile, path.join(distDir, 'index.js'));
+fs.copyFileSync(srcFile, path.join(distDir, 'index.mjs'));
diff --git a/packages/vant-touch-emulator/changelog.md b/packages/vant-touch-emulator/changelog.md
index 69d213800..d112a9e04 100644
--- a/packages/vant-touch-emulator/changelog.md
+++ b/packages/vant-touch-emulator/changelog.md
@@ -1,5 +1,11 @@
# Changelog
+### [v1.4.0]
+
+`2022-08-06`
+
+- support `.mjs` extension
+
### [v1.3.1]
`2021-07-06`
diff --git a/packages/vant-touch-emulator/package.json b/packages/vant-touch-emulator/package.json
index e4cc08e51..0c1b6a406 100644
--- a/packages/vant-touch-emulator/package.json
+++ b/packages/vant-touch-emulator/package.json
@@ -1,10 +1,16 @@
{
"name": "@vant/touch-emulator",
- "version": "1.3.2",
+ "version": "1.4.0",
"description": "Vant touch emulator",
- "main": "index.js",
+ "main": "dist/index.js",
+ "module": "dist/index.mjs",
+ "scripts": {
+ "build": "node ./build.js",
+ "prepare": "pnpm build"
+ },
"publishConfig": {
- "access": "public"
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
diff --git a/packages/vant-touch-emulator/index.js b/packages/vant-touch-emulator/src/index.js
similarity index 100%
rename from packages/vant-touch-emulator/index.js
rename to packages/vant-touch-emulator/src/index.js
diff --git a/packages/vant/docs/markdown/home.en-US.md b/packages/vant/docs/markdown/home.en-US.md
index da8020fe8..c4c642869 100644
--- a/packages/vant/docs/markdown/home.en-US.md
+++ b/packages/vant/docs/markdown/home.en-US.md
@@ -2,7 +2,7 @@
Vant
-
Mobile UI Components built on Vue
+
Lightweight Mobile UI Components built on Vue
@@ -10,6 +10,7 @@
- 🚀 1KB Component average size (min+gzip)
- 🚀 70+ High quality components
+- 🚀 Zero third-party dependencies
- 💪 90%+ Unit test coverage
- 💪 Written in TypeScript
- 📖 Extensive documentation and demos
diff --git a/packages/vant/docs/markdown/home.zh-CN.md b/packages/vant/docs/markdown/home.zh-CN.md
index 64db42cfe..392548894 100644
--- a/packages/vant/docs/markdown/home.zh-CN.md
+++ b/packages/vant/docs/markdown/home.zh-CN.md
@@ -16,6 +16,7 @@ Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
- 🚀 性能极佳,组件平均体积小于 1KB(min+gzip)
- 🚀 70+ 个高质量组件,覆盖移动端主流场景
+- 🚀 零外部依赖,不依赖三方 npm 包
- 💪 使用 TypeScript 编写,提供完整的类型定义
- 💪 单元测试覆盖率超过 90%,提供稳定性保障
- 📖 提供丰富的中英文文档和组件示例
diff --git a/packages/vant/package.json b/packages/vant/package.json
index ccf686765..8aca9bd60 100644
--- a/packages/vant/package.json
+++ b/packages/vant/package.json
@@ -13,8 +13,7 @@
},
"files": [
"es",
- "lib",
- "vetur"
+ "lib"
],
"scripts": {
"dev": "vant-cli dev",
@@ -72,9 +71,5 @@
"*.css",
"*.less"
],
- "web-types": "vetur/web-types.json",
- "vetur": {
- "tags": "vetur/tags.json",
- "attributes": "vetur/attributes.json"
- }
+ "web-types": "lib/web-types.json"
}
diff --git a/packages/vant/src/action-sheet/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/action-sheet/test/__snapshots__/demo.spec.ts.snap
index 26711b971..a77722e10 100644
--- a/packages/vant/src/action-sheet/test/__snapshots__/demo.spec.ts.snap
+++ b/packages/vant/src/action-sheet/test/__snapshots__/demo.spec.ts.snap
@@ -67,23 +67,33 @@ exports[`should render demo and match snapshot 1`] = `
-
+
-
+
-
+
-
+
-
+
diff --git a/packages/vant/src/action-sheet/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/action-sheet/test/__snapshots__/index.spec.ts.snap
index 242951ad3..5d177aec2 100644
--- a/packages/vant/src/action-sheet/test/__snapshots__/index.spec.ts.snap
+++ b/packages/vant/src/action-sheet/test/__snapshots__/index.spec.ts.snap
@@ -22,12 +22,17 @@ exports[`should render cancel slot correctly 1`] = `
`;
exports[`should render default slot correctly 1`] = `
-
+
-
-
+
diff --git a/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap
index 3860a6ff7..0d69349fa 100644
--- a/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap
+++ b/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap
@@ -557,14 +557,18 @@ exports[`formatter prop 1`] = `
`;
exports[`popup wrapper 1`] = `
-
+
`;
exports[`popup wrapper 2`] = `
-
+
@@ -572,6 +576,8 @@ exports[`popup wrapper 2`] = `
+
`;
diff --git a/packages/vant/src/coupon-list/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/coupon-list/test/__snapshots__/demo.spec.ts.snap
index 5e7af14fd..a33817db8 100644
--- a/packages/vant/src/coupon-list/test/__snapshots__/demo.spec.ts.snap
+++ b/packages/vant/src/coupon-list/test/__snapshots__/demo.spec.ts.snap
@@ -19,7 +19,9 @@ exports[`should render demo and match snapshot 1`] = `
-
+
diff --git a/packages/vant/src/dialog/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/dialog/test/__snapshots__/demo.spec.ts.snap
index 8db5bc485..3b5f2adfe 100644
--- a/packages/vant/src/dialog/test/__snapshots__/demo.spec.ts.snap
+++ b/packages/vant/src/dialog/test/__snapshots__/demo.spec.ts.snap
@@ -95,9 +95,9 @@ exports[`should render demo and match snapshot 1`] = `
-