feat!: publish per-component ESM entries as @timi/tdesign-mobile

This commit is contained in:
Timi
2026-11-23 20:28:05 +08:00
parent 7349bb3429
commit 3f4c98fbf3
44 changed files with 137 additions and 81 deletions
+2 -2
View File
@@ -72,8 +72,8 @@ jobs:
- name: Ensure version not published - name: Ensure version not published
if: ${{ steps.version.outputs.publish == 'true' }} if: ${{ steps.version.outputs.publish == 'true' }}
run: | run: |
if npm view "timi-tdesign-mobile@${{ steps.version.outputs.version }}" version > /dev/null 2>&1; then if npm view "@timi/tdesign-mobile@${{ steps.version.outputs.version }}" version > /dev/null 2>&1; then
echo "FAIL: timi-tdesign-mobile@${{ steps.version.outputs.version }} 已存在于 nexus,请提升 package.json 版本" echo "FAIL: @timi/tdesign-mobile@${{ steps.version.outputs.version }} 已存在于 nexus,请提升 package.json 版本"
exit 1 exit 1
fi fi
echo "OK: 版本未占用" echo "OK: 版本未占用"
+4 -4
View File
@@ -1,12 +1,12 @@
# timi-tdesign-mobile # @timi/tdesign-mobile
Vue 3 移动端通用组件库,依赖 `timi-web` 提供基础组件和编辑器能力。 Vue 3 移动端通用组件库,依赖 `@timi/web` 提供基础组件和编辑器能力。
本包不依赖 `timi-web-api`。业务项目可以只安装本包使用通用组件;需要业务接口、领域类型或用户状态时,再单独安装 `timi-web-api`。 本包不绑定业务 API 包。业务项目可以只安装本包使用通用组件;业务接口、领域类型和用户状态由应用层自行提供。
## 文章和通知组件 ## 文章和通知组件
`ArticleEditor`、`ArticleView`、`NotifyEditor`、`NotifyView` 只约束对象的最小字段。`Article`、`Attachment` 和 `NotifyDetail` 支持携带业务自定义字段,不要求对象来自 `timi-web-api`。 `ArticleEditor`、`ArticleView`、`NotifyEditor`、`NotifyView` 只约束对象的最小字段。`Article`、`Attachment` 和 `NotifyDetail` 支持携带业务自定义字段,不要求对象来自特定 API 包。
上传和附件地址由业务项目通过回调注入: 上传和附件地址由业务项目通过回调注入:
+3
View File
@@ -22,8 +22,10 @@ declare module 'vue' {
BottomPopup: typeof import('./src/components/bottom-popup/index.vue')['default'] BottomPopup: typeof import('./src/components/bottom-popup/index.vue')['default']
CardContainer: typeof import('./src/components/card-container/index.vue')['default'] CardContainer: typeof import('./src/components/card-container/index.vue')['default']
CodeEditor: typeof import('./src/components/code-editor/index.vue')['default'] CodeEditor: typeof import('./src/components/code-editor/index.vue')['default']
DropdownFilter: typeof import('./src/components/dropdown-filter/index.vue')['default']
DurationPicker: typeof import('./src/components/duration-picker/index.vue')['default'] DurationPicker: typeof import('./src/components/duration-picker/index.vue')['default']
EditorSearch: typeof import('./src/components/editor-search/index.vue')['default'] EditorSearch: typeof import('./src/components/editor-search/index.vue')['default']
Item: typeof import('./src/components/timeline/item.vue')['default']
MasterDetail: typeof import('./src/components/master-detail/index.vue')['default'] MasterDetail: typeof import('./src/components/master-detail/index.vue')['default']
MasterDetailPage: typeof import('./src/components/master-detail-page/index.vue')['default'] MasterDetailPage: typeof import('./src/components/master-detail-page/index.vue')['default']
NotifyEditor: typeof import('./src/components/notify-editor/index.vue')['default'] NotifyEditor: typeof import('./src/components/notify-editor/index.vue')['default']
@@ -44,6 +46,7 @@ declare module 'vue' {
TIcon: typeof import('tdesign-mobile-vue')['Icon'] TIcon: typeof import('tdesign-mobile-vue')['Icon']
TImage: typeof import('tdesign-mobile-vue')['Image'] TImage: typeof import('tdesign-mobile-vue')['Image']
TImageViewer: typeof import('tdesign-mobile-vue')['ImageViewer'] TImageViewer: typeof import('tdesign-mobile-vue')['ImageViewer']
Timeline: typeof import('./src/components/timeline/index.vue')['default']
TInput: typeof import('tdesign-mobile-vue')['Input'] TInput: typeof import('tdesign-mobile-vue')['Input']
TiptapCodeBlockButton: typeof import('./src/components/tiptap-editor/TiptapCodeBlockButton.vue')['default'] TiptapCodeBlockButton: typeof import('./src/components/tiptap-editor/TiptapCodeBlockButton.vue')['default']
TiptapEditor: typeof import('./src/components/tiptap-editor/index.vue')['default'] TiptapEditor: typeof import('./src/components/tiptap-editor/index.vue')['default']
+26 -7
View File
@@ -1,11 +1,15 @@
{ {
"name": "timi-tdesign-mobile", "name": "@timi/tdesign-mobile",
"main": "./dist/timi-tdesign-mobile.umd.js", "type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"module": "./dist/timi-tdesign-mobile.mjs", "module": "./dist/index.js",
"style": "./dist/timi-tdesign-mobile.css", "style": "./dist/timi-tdesign-mobile.css",
"sideEffects": [
"**/*.css"
],
"private": false, "private": false,
"version": "1.5.0", "version": "2.0.0",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev": "pnpm run -C docs dev", "dev": "pnpm run -C docs dev",
@@ -25,8 +29,23 @@
"exports": { "exports": {
".": { ".": {
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"import": "./dist/timi-tdesign-mobile.mjs", "import": "./dist/index.js"
"require": "./dist/timi-tdesign-mobile.umd.js" },
"./components": {
"types": "./dist/components/index.d.ts",
"import": "./dist/components/index.js"
},
"./components/*": {
"types": "./dist/components/*/index.d.ts",
"import": "./dist/components/*/index.js"
},
"./directives": {
"types": "./dist/directives/index.d.ts",
"import": "./dist/directives/index.js"
},
"./utils/message": {
"types": "./dist/utils/message.d.ts",
"import": "./dist/utils/message.js"
}, },
"./style.css": "./dist/timi-tdesign-mobile.css", "./style.css": "./dist/timi-tdesign-mobile.css",
"./src/*": "./src/*" "./src/*": "./src/*"
@@ -36,7 +55,7 @@
}, },
"dependencies": { "dependencies": {
"tdesign-mobile-vue": "^1.17.1", "tdesign-mobile-vue": "^1.17.1",
"timi-web": "^1.0.2" "@timi/web": "^2.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"vue": "^3.5.0", "vue": "^3.5.0",
+1 -1
View File
@@ -84,7 +84,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { nextTick, useTemplateRef } from "vue"; import { nextTick, useTemplateRef } from "vue";
import { MarkdownView } from "timi-web"; import { MarkdownView } from "@timi/web/components/markdown-view";
import AiChatThinking from "./AiChatThinking.vue"; import AiChatThinking from "./AiChatThinking.vue";
import type { import type {
AiChatMessage, AiChatMessage,
+1 -1
View File
@@ -1,4 +1,4 @@
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
import AiChatComposerView from "./AiChatComposer.vue"; import AiChatComposerView from "./AiChatComposer.vue";
import AiChatMessageListView from "./AiChatMessageList.vue"; import AiChatMessageListView from "./AiChatMessageList.vue";
import AiChatPanelView from "./AiChatPanel.vue"; import AiChatPanelView from "./AiChatPanel.vue";
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const AppShell = WebToolkit.withInstall(view); export const AppShell = WebToolkit.withInstall(view);
export default AppShell; export default AppShell;
+1 -1
View File
@@ -3,7 +3,7 @@ import {
TEMP_FILE_ID_ATTR, TEMP_FILE_ID_ATTR,
isLocalMediaId, isLocalMediaId,
normalizeContent normalizeContent
} from "timi-web/editor"; } from "@timi/web/editor";
import type { ArticleContentType, Attachment } from "./types"; import type { ArticleContentType, Attachment } from "./types";
/** 文章内容中附件和临时文件的标识前缀。 */ /** 文章内容中附件和临时文件的标识前缀。 */
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
import type { Article } from "./types"; import type { Article } from "./types";
export type { export type {
+2 -2
View File
@@ -25,7 +25,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Article, ArticleContentType, Attachment, UploadResult } from "./types"; import type { Article, ArticleContentType, Attachment, UploadResult } from "./types";
import { MarkdownEditor } from "timi-web"; import { MarkdownEditor } from "@timi/web/components/markdown-editor";
import { TiptapEditor } from "../tiptap-editor"; import { TiptapEditor } from "../tiptap-editor";
import type { TiptapEditorExpose } from "../tiptap-editor"; import type { TiptapEditorExpose } from "../tiptap-editor";
import { import {
@@ -41,7 +41,7 @@ import {
ATTACHMENT_ID_ATTR, ATTACHMENT_ID_ATTR,
TEMP_FILE_ID_ATTR, TEMP_FILE_ID_ATTR,
normalizeContent normalizeContent
} from "timi-web/editor"; } from "@timi/web/editor";
defineOptions({ defineOptions({
name: "ArticleEditor" name: "ArticleEditor"
+1 -1
View File
@@ -1,4 +1,4 @@
import type { UploadResult as EditorUploadResult } from "timi-web/editor"; import type { UploadResult as EditorUploadResult } from "@timi/web/editor";
/** 文章编辑器支持的正文类型。 */ /** 文章编辑器支持的正文类型。 */
export type ArticleContentType = "TEXT" | "MARKDOWN" | "TIP_TAP"; export type ArticleContentType = "TEXT" | "MARKDOWN" | "TIP_TAP";
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const ArticleView = WebToolkit.withInstall(view); export const ArticleView = WebToolkit.withInstall(view);
export default ArticleView; export default ArticleView;
+2 -2
View File
@@ -14,14 +14,14 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Article, Attachment } from "../article-editor/types"; import type { Article, Attachment } from "../article-editor/types";
import { MarkdownView } from "timi-web"; import { MarkdownView } from "@timi/web/components/markdown-view";
import { TiptapView } from "../tiptap-view"; import { TiptapView } from "../tiptap-view";
import { import {
getAttachmentIdFromSrc, getAttachmentIdFromSrc,
normalizeArticleContentType, normalizeArticleContentType,
normalizeRawArticleContent normalizeRawArticleContent
} from "../article-editor/content"; } from "../article-editor/content";
import { ATTACHMENT_ID_ATTR, normalizeContent } from "timi-web/editor"; import { ATTACHMENT_ID_ATTR, normalizeContent } from "@timi/web/editor";
defineOptions({ defineOptions({
name: "ArticleView" name: "ArticleView"
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export type { export type {
AttachmentSelectorItem, AttachmentSelectorItem,
+1 -1
View File
@@ -63,7 +63,7 @@ import type {
AttachmentSelectorViewerItem AttachmentSelectorViewerItem
} from "./types"; } from "./types";
import { getMediaKind, getMediaPreviewURL } from "./utils"; import { getMediaKind, getMediaPreviewURL } from "./utils";
import { CenterTips } from "timi-web"; import { CenterTips } from "@timi/web/components/center-tips";
defineOptions({ defineOptions({
name: "AttachmentSelector", name: "AttachmentSelector",
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const BottomPopup = WebToolkit.withInstall(view); export const BottomPopup = WebToolkit.withInstall(view);
export default BottomPopup; export default BottomPopup;
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const CardContainer = WebToolkit.withInstall(view); export const CardContainer = WebToolkit.withInstall(view);
export default CardContainer; export default CardContainer;
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
import "./style.less"; import "./style.less";
export type CodeEditorScrollState = { export type CodeEditorScrollState = {
+2 -2
View File
@@ -65,8 +65,8 @@ import {
replaceMatchText, replaceMatchText,
type TextSearchMatch, type TextSearchMatch,
type TextSearchOptions type TextSearchOptions
} from "timi-web/editor"; } from "@timi/web/editor";
import { highlightCode, resolveCodeEditorKeydown, resolvePrismLanguage } from "timi-web/editor"; import { highlightCode, resolveCodeEditorKeydown, resolvePrismLanguage } from "@timi/web/editor";
defineOptions({ defineOptions({
name: "CodeEditor" name: "CodeEditor"
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const DropdownFilter = WebToolkit.withInstall(view); export const DropdownFilter = WebToolkit.withInstall(view);
export default DropdownFilter; export default DropdownFilter;
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const DurationPicker = WebToolkit.withInstall(view); export const DurationPicker = WebToolkit.withInstall(view);
export default DurationPicker; export default DurationPicker;
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const MasterDetailPage = WebToolkit.withInstall(view); export const MasterDetailPage = WebToolkit.withInstall(view);
export default MasterDetailPage; export default MasterDetailPage;
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const MasterDetail = WebToolkit.withInstall(view); export const MasterDetail = WebToolkit.withInstall(view);
export default MasterDetail; export default MasterDetail;
+1 -1
View File
@@ -31,7 +31,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, type StyleValue } from "vue"; import { computed, type StyleValue } from "vue";
import { CenterTips } from "timi-web"; import { CenterTips } from "@timi/web/components/center-tips";
import { useLayout } from "../../composables/use-layout"; import { useLayout } from "../../composables/use-layout";
import type { MasterDetailProps } from "./type"; import type { MasterDetailProps } from "./type";
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
import type { NotifyDetail } from "./types"; import type { NotifyDetail } from "./types";
export type { NotifyContentType, NotifyDetail } from "./types"; export type { NotifyContentType, NotifyDetail } from "./types";
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const NotifyView = WebToolkit.withInstall(view); export const NotifyView = WebToolkit.withInstall(view);
export default NotifyView; export default NotifyView;
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export type { export type {
PageTransitionBackground, PageTransitionBackground,
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const PaneTransition = WebToolkit.withInstall(view); export const PaneTransition = WebToolkit.withInstall(view);
export default PaneTransition; export default PaneTransition;
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const RootLayout = WebToolkit.withInstall(view); export const RootLayout = WebToolkit.withInstall(view);
export default RootLayout; export default RootLayout;
+1 -1
View File
@@ -6,7 +6,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { Copyright } from "timi-web"; import { Copyright } from "@timi/web/components/copyright";
defineOptions({ defineOptions({
name: "RootLayout" name: "RootLayout"
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export type { export type {
SpaceAlign, SpaceAlign,
+1 -1
View File
@@ -1,4 +1,4 @@
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
import timeline from "./index.vue"; import timeline from "./index.vue";
import item from "./item.vue"; import item from "./item.vue";
@@ -21,8 +21,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { PickerValue } from "tdesign-mobile-vue"; import type { PickerValue } from "tdesign-mobile-vue";
import { supportedCodeLanguages } from "timi-web/editor"; import { supportedCodeLanguages } from "@timi/web/editor";
import type { TiptapEditorInstance } from "timi-web/editor"; import type { TiptapEditorInstance } from "@timi/web/editor";
defineOptions({ defineOptions({
name: "TiptapCodeBlockButton" name: "TiptapCodeBlockButton"
@@ -60,7 +60,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { showPlatformMessage } from "../message"; import { showPlatformMessage } from "../message";
import type { TiptapEditorInstance } from "timi-web/editor"; import type { TiptapEditorInstance } from "@timi/web/editor";
import BottomPopup from "../bottom-popup/index.vue"; import BottomPopup from "../bottom-popup/index.vue";
defineOptions({ defineOptions({
@@ -35,7 +35,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { TiptapEditorInstance } from "timi-web/editor"; import type { TiptapEditorInstance } from "@timi/web/editor";
import BottomPopup from "../bottom-popup/index.vue"; import BottomPopup from "../bottom-popup/index.vue";
defineOptions({ defineOptions({
@@ -90,7 +90,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { showPlatformMessage } from "../message"; import { showPlatformMessage } from "../message";
import type { TiptapEditorInstance, UploadResult } from "timi-web/editor"; import type { TiptapEditorInstance, UploadResult } from "@timi/web/editor";
import BottomPopup from "../bottom-popup/index.vue"; import BottomPopup from "../bottom-popup/index.vue";
defineOptions({ defineOptions({
@@ -61,8 +61,8 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { TABLE_PICKER_SIZE } from "timi-web/editor"; import { TABLE_PICKER_SIZE } from "@timi/web/editor";
import type { TiptapEditorInstance } from "timi-web/editor"; import type { TiptapEditorInstance } from "@timi/web/editor";
import BottomPopup from "../bottom-popup/index.vue"; import BottomPopup from "../bottom-popup/index.vue";
defineOptions({ defineOptions({
@@ -151,8 +151,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ColorObject } from "tdesign-mobile-vue"; import type { ColorObject } from "tdesign-mobile-vue";
import type { AlignType, UploadResult, TiptapEditorInstance } from "timi-web/editor"; import type { AlignType, UploadResult, TiptapEditorInstance } from "@timi/web/editor";
import { headingMeta } from "timi-web/editor"; import { headingMeta } from "@timi/web/editor";
import TiptapCodeBlockButton from "./TiptapCodeBlockButton.vue"; import TiptapCodeBlockButton from "./TiptapCodeBlockButton.vue";
import TiptapIframeButton from "./TiptapIframeButton.vue"; import TiptapIframeButton from "./TiptapIframeButton.vue";
import TiptapLinkButton from "./TiptapLinkButton.vue"; import TiptapLinkButton from "./TiptapLinkButton.vue";
+3 -3
View File
@@ -1,8 +1,8 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
import type { TiptapEditorInstance } from "timi-web/editor"; import type { TiptapEditorInstance } from "@timi/web/editor";
export * from "timi-web/editor"; export * from "@timi/web/editor";
export type TiptapEditorExpose = { export type TiptapEditorExpose = {
submit: () => Promise<string>; submit: () => Promise<string>;
getPendingMediaCount: () => number; getPendingMediaCount: () => number;
+5 -5
View File
@@ -58,18 +58,18 @@ import {
buildSearchRegex, buildSearchRegex,
replaceMatchText, replaceMatchText,
type TextSearchOptions type TextSearchOptions
} from "timi-web/editor"; } from "@timi/web/editor";
import { Toolkit } from "timi-web"; import { Toolkit } from "@timi/web/utils";
import type { PendingMediaItem, UploadMediaType, UploadResult } from "timi-web/editor"; import type { PendingMediaItem, UploadMediaType, UploadResult } from "@timi/web/editor";
import TiptapToolbar from "./TiptapToolbar.vue"; import TiptapToolbar from "./TiptapToolbar.vue";
import { useTiptapEditor } from "timi-web/editor"; import { useTiptapEditor } from "@timi/web/editor";
import { import {
ATTACHMENT_ID_ATTR, ATTACHMENT_ID_ATTR,
LOCAL_MEDIA_ID_PREFIX, LOCAL_MEDIA_ID_PREFIX,
TEMP_FILE_ID_ATTR, TEMP_FILE_ID_ATTR,
isLocalMediaId, isLocalMediaId,
normalizeContent normalizeContent
} from "timi-web/editor"; } from "@timi/web/editor";
defineOptions({ defineOptions({
name: "TiptapEditor" name: "TiptapEditor"
+1 -1
View File
@@ -1,5 +1,5 @@
import view from "./index.vue"; import view from "./index.vue";
import { WebToolkit } from "timi-web"; import { WebToolkit } from "@timi/web/utils";
export const TiptapView = WebToolkit.withInstall(view); export const TiptapView = WebToolkit.withInstall(view);
export default TiptapView; export default TiptapView;
+1 -1
View File
@@ -10,7 +10,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { normalizeContent, useTiptapView } from "timi-web/editor"; import { normalizeContent, useTiptapView } from "@timi/web/editor";
defineOptions({ defineOptions({
name: "TiptapView" name: "TiptapView"
-1
View File
@@ -2,7 +2,6 @@ import "./assets/style/tdesign-custom.less";
import "./assets/style/entrance-transition.less"; import "./assets/style/entrance-transition.less";
import "./assets/style/page-layout.less"; import "./assets/style/page-layout.less";
import "./components/tiptap-content.less"; import "./components/tiptap-content.less";
import "timi-web/style.css";
export * from "./components"; export * from "./components";
export * from "./directives"; export * from "./directives";
+52 -17
View File
@@ -1,3 +1,4 @@
import { existsSync, readdirSync, statSync } from "fs";
import { resolve } from "path"; import { resolve } from "path";
import { Alias, defineConfig } from "vite"; import { Alias, defineConfig } from "vite";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
@@ -8,11 +9,44 @@ import dts from "vite-plugin-dts";
const alias: Alias[] = [ const alias: Alias[] = [
{ {
find: /^timi-tdesign-mobile(\/(es|lib))?$/, find: /^@timi\/tdesign-mobile(\/(es|lib))?$/,
replacement: resolve(__dirname, "./src/index.ts") replacement: resolve(__dirname, "./src/index.ts")
} }
]; ];
/**
* 递归收集组件入口,组件目录下存在 index.ts 时即视为一个可独立导出的组件
*/
function collectComponentEntries(
dir: string,
prefix: string,
entries: Record<string, string>
) {
for (const name of readdirSync(dir)) {
const fullPath = resolve(dir, name);
if (!statSync(fullPath).isDirectory()) {
continue;
}
const entry = resolve(fullPath, "index.ts");
if (existsSync(entry)) {
entries[`${prefix}/${name}/index`] = entry;
}
collectComponentEntries(fullPath, `${prefix}/${name}`, entries);
}
}
const entries: Record<string, string> = {
index: resolve(__dirname, "./src/index.ts"),
"components/index": resolve(__dirname, "./src/components/index.ts"),
"directives/index": resolve(__dirname, "./src/directives/index.ts"),
"utils/message": resolve(__dirname, "./src/utils/message.ts")
};
collectComponentEntries(
resolve(__dirname, "./src/components"),
"components",
entries
);
export default defineConfig({ export default defineConfig({
server: { server: {
port: 3004, port: 3004,
@@ -24,33 +58,34 @@ export default defineConfig({
build: { build: {
outDir: "dist", outDir: "dist",
lib: { lib: {
entry: resolve(__dirname, "./src/index.ts"), entry: entries,
name: "TimiTDesignMobile", formats: ["es"],
fileName: "timi-tdesign-mobile" fileName: (_format, entryName) => `${entryName}.js`,
cssFileName: "timi-tdesign-mobile"
}, },
rollupOptions: { rollupOptions: {
external: [ external: (id) =>
"vue", id === "vue" ||
"vue-router", id === "vue-router" ||
"timi-web", id === "@timi/web" ||
"tdesign-mobile-vue" id.startsWith("@timi/web/") ||
], id === "tdesign-mobile-vue" ||
id.startsWith("tdesign-mobile-vue/"),
output: { output: {
globals: { chunkFileNames: "chunks/[name]-[hash].js"
vue: "Vue",
"timi-web": "TimiWeb"
}
} }
}, },
minify: "terser" cssCodeSplit: false,
minify: "terser",
target: "es2017"
}, },
plugins: [ plugins: [
vue({ vue({
include: [/\.vue$/, /\.md$/] include: [/\.vue$/, /\.md$/]
}), }),
dts({ dts({
pathsToAliases: false, entryRoot: "src",
aliasesExclude: [/^timi-web\/editor$/] pathsToAliases: false
}), }),
AutoImport({ AutoImport({
imports: [ imports: [