Browse Source

tool(组件): typscript structure json 更改

gemercheung 2 years ago
parent
commit
db4ef1a7aa

+ 6 - 0
packages/components/audio/index.ts

@@ -0,0 +1,6 @@
+import { withInstall } from '@kankan/utils';
+import Audio from './src/index.vue';
+
+export const KKAudio = withInstall(Audio);
+
+export default KKAudio;

+ 3 - 3
packages/components/audio/src/index.vue

@@ -16,7 +16,7 @@
   const randoms = ref([1, 0.5, 1, 0.5]);
   const playIng = ref(false);
 
-  let timeout;
+  let timeout: number;
   const rotation = () => {
     if (!playIng.value) return;
     for (let i = 0; i < randoms.value.length; i++) {
@@ -51,6 +51,6 @@
   });
 </script>
 
-<script>
+<!-- <script>
   export default { name: 'UiAudio' };
-</script>
+</script> -->

+ 14 - 0
packages/components/components.d.ts

@@ -0,0 +1,14 @@
+// For this project development
+import '@vue/runtime-core';
+
+declare module '@vue/runtime-core' {
+  // GlobalComponents for Volar
+  export interface GlobalComponents {
+    KKAudio: typeof import('./component/audio');
+  }
+
+  // interface ComponentCustomProperties {
+  // }
+}
+
+export {};

+ 1 - 0
packages/components/index.ts

@@ -0,0 +1 @@
+export * from './audio';

+ 6 - 2
packages/components/package.json

@@ -1,8 +1,10 @@
 {
   "name": "@kankan/components",
   "version": "1.0.0",
-  "main": "dist/index",
-  "types": "dist/index",
+  "main": "index.ts",
+  "module": "index.ts",
+  "unpkg": "index.js",
+  "types": "index.d.ts",
   "files": [
     "dist"
   ],
@@ -18,9 +20,11 @@
     "prepublishOnly": "pnpm run build"
   },
   "peerDependencies": {
+    "@kankan/utils": "workspace:^1.0.0",
     "vue": "^3.2.0"
   },
   "devDependencies": {
+    "@kankan/utils": "workspace:^1.0.0",
     "@rollup/plugin-typescript": "~8.3.4",
     "rimraf": "~3.0.2",
     "rollup": "~2.77.3",

packages/utils/src/dom.ts → packages/utils/dom.ts


+ 1 - 0
packages/utils/index.ts

@@ -0,0 +1 @@
+export * from './vue';

+ 0 - 1
packages/utils/src/index.ts

@@ -1 +0,0 @@
-export * from './vue';

packages/utils/src/vue/index.ts → packages/utils/vue/index.ts


packages/utils/src/vue/install.ts → packages/utils/vue/install.ts


packages/utils/src/vue/typescript.ts → packages/utils/vue/typescript.ts


+ 2 - 0
pnpm-lock.yaml

@@ -59,6 +59,7 @@ importers:
 
   packages/components:
     specifiers:
+      '@kankan/utils': workspace:^1.0.0
       '@rollup/plugin-typescript': ~8.3.4
       rimraf: ~3.0.2
       rollup: ~2.77.3
@@ -69,6 +70,7 @@ importers:
     dependencies:
       vue: 3.2.39
     devDependencies:
+      '@kankan/utils': link:../utils
       '@rollup/plugin-typescript': 8.3.4_z6zeof5eklcd4ck5cj6ien7gzy
       rimraf: 3.0.2
       rollup: 2.77.3

+ 22 - 0
tsconfig.base.json

@@ -0,0 +1,22 @@
+{
+  "compilerOptions": {
+    "outDir": "dist",
+    "target": "es2018",
+    "module": "esnext",
+    "baseUrl": ".",
+    "sourceMap": false,
+    "moduleResolution": "node",
+    "allowJs": false,
+    "strict": true,
+    "noUnusedLocals": true,
+    "resolveJsonModule": true,
+    "allowSyntheticDefaultImports": true,
+    "esModuleInterop": true,
+    "removeComments": false,
+    "rootDir": ".",
+    "types": [],
+    "paths": {
+      "@kankan/*": ["packages/*"]
+    }
+  }
+}

+ 0 - 20
tsconfig.build.json

@@ -1,20 +0,0 @@
-{
-  "compilerOptions": {
-    "module": "esnext",
-    "target": "es2018",
-    "sourceMap": true,
-    "moduleResolution": "node",
-    "declaration": true,
-    "declarationMap": true,
-    "noEmitOnError": true,
-    "skipLibCheck": true,
-    "esModuleInterop": true,
-    "types": [],
-    "rootDir": ".",
-    "noEmit": false
-  },
-  "exclude": ["node_modules", "dist"],
-  "paths": {
-    "@kankan/*": ["packages/*"]
-  }
-}

+ 8 - 10
tsconfig.json

@@ -1,12 +1,10 @@
 {
-  "extends": "./tsconfig.build.json",
-
-  "compilerOptions": {
-    "baseUrl": ".",
-    "paths": {
-      "@nighttrax/components/*": ["packages/components/src/*"],
-      "@nighttrax/*": ["packages/*/src"]
-    },
-    "noEmit": true
-  }
+  "files": [],
+  "references": [
+    { "path": "./tsconfig.web.json" }
+    // { "path": "./tsconfig.play.json" },
+    // { "path": "./tsconfig.node.json" },
+    // { "path": "./tsconfig.vite-config.json" },
+    // { "path": "./tsconfig.vitest.json" }
+  ]
 }

+ 20 - 0
tsconfig.web.json

@@ -0,0 +1,20 @@
+{
+  "extends": "./tsconfig.base.json",
+  "compilerOptions": {
+    "composite": true,
+    "jsx": "preserve",
+    "lib": ["ES2018", "DOM", "DOM.Iterable"],
+    "types": ["unplugin-vue-macros/macros-global"],
+    "skipLibCheck": true
+  },
+  "include": ["packages", "typings/components.d.ts", "typings/env.d.ts"],
+  "exclude": [
+    "node_modules",
+    "**/dist",
+    "**/__tests__/**/*",
+    "**/gulpfile.ts",
+    "**/test-helper",
+    "packages/test-utils",
+    "**/*.md"
+  ]
+}