diff --git a/.eslintrc.js b/.eslintrc.js index 442b7ef..3b0f5bc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,18 +1,14 @@ module.exports = { root: true, - globals: { - defineProps: 'readonly', - defineEmits: 'readonly', - defineExpose: 'readonly', - withDefaults: 'readonly', - }, env: { es6: true, browser: true, node: true, }, extends: [ + 'eslint:recommended', 'plugin:vue/vue3-recommended', + 'plugin:markdown/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', ], @@ -25,6 +21,11 @@ module.exports = { jsx: true, }, }, + settings: { + 'import/resolver': { + node: { extensions: ['.js', '.mjs', '.ts', '.d.ts', '.tsx'] }, + }, + }, plugins: ['vue'], rules: { 'prettier/prettier': 'error', diff --git a/build/rollup.config.dts.ts b/build/rollup.config.dts.ts index 0039753..f3bb26a 100644 --- a/build/rollup.config.dts.ts +++ b/build/rollup.config.dts.ts @@ -5,6 +5,7 @@ import vue from 'rollup-plugin-vue' // 处理vue文件 import { resolve } from 'path' const input = resolve(__dirname, '../packages') // 入口文件 const output = resolve(__dirname, '../lib') // 输出文件 + const config = [ { input: `${input}/index.ts`, @@ -17,13 +18,16 @@ const config = [ nodeResolve(), vue({ target: 'browser', - // css: false, exposeFilename: false, }), typescript({ useTsconfigDeclarationDir: false, + tsconfig: "./tsconfig.web.json", tsconfigOverride: { - include: ['packages/**/*'], + compilerOptions: { + composite: false, + declaration: true, + }, exclude: ['node_modules', 'examples', 'mobile', 'tests'], }, abortOnError: false, diff --git a/build/rollup.config.ts b/build/rollup.config.ts index e74e5af..8d0043a 100644 --- a/build/rollup.config.ts +++ b/build/rollup.config.ts @@ -25,8 +25,10 @@ function getAllDirbyFilename(dir, outDir = null) { nodeResolve(), vue(), typescript({ + tsconfig: "./tsconfig.web.json", tsconfigOverride: { compilerOptions: { + composite:false, declaration: false, }, exclude: ['node_modules', 'examples', 'mobile', 'tests'], diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 065c3a3..2672489 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -61,17 +61,6 @@ const config: UserConfig = { // // md.use(demoBlockPlugin) // }, }, - vue: { - template: { - ssr: true, - compilerOptions: { - directiveTransforms: { - props: [], - needRuntime: true, - }, - }, - }, - }, }; export default config; diff --git a/effect/package.json b/effect/package.json index 97c59a4..64add6d 100644 --- a/effect/package.json +++ b/effect/package.json @@ -1,16 +1,16 @@ { - "name": "effect", - "version": "0.0.0", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview" - }, - "dependencies": { - "vue": "^3.2.33" - }, - "devDependencies": { - "@vitejs/plugin-vue": "^2.3.3", - "vite": "^2.9.9" - } + "name": "effect", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "vue": "^3.2.37" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^3.0.3", + "vite": "^3.0.7" + } } diff --git a/effect/src/App.vue b/effect/src/App.vue index 9d38b13..74b9fbf 100644 --- a/effect/src/App.vue +++ b/effect/src/App.vue @@ -1,36 +1,36 @@ - - - + + diff --git a/effect/src/main.ts b/effect/src/main.ts index 01433bc..684d042 100644 --- a/effect/src/main.ts +++ b/effect/src/main.ts @@ -1,4 +1,4 @@ -import { createApp } from 'vue' -import App from './App.vue' +import { createApp } from 'vue'; +import App from './App.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/effect/tsconfig.json b/effect/tsconfig.json deleted file mode 100644 index 7938aed..0000000 --- a/effect/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "allowJs": true, - "module": "esnext", - "lib": ["esnext", "dom"], - "types": ["../typings/vue-shim"], - "resolveJsonModule": true, - "moduleResolution": "node", - "baseUrl": "." - }, - "include": ["**/*"] -} diff --git a/effect/vite.config.ts b/effect/vite.config.ts index 158c356..ab4e002 100644 --- a/effect/vite.config.ts +++ b/effect/vite.config.ts @@ -1,13 +1,26 @@ -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [vue()], - server: { - // 服务器主机名,如果允许外部访问,可设置为"0.0.0.0" - host: '0.0.0.0', - // 服务器端口号 - port: 3001, - }, -}) + plugins: [vue()], + server: { + // 服务器主机名,如果允许外部访问,可设置为"0.0.0.0" + host: '0.0.0.0', + // 服务器端口号 + port: 3001, + }, + resolve: { + alias: [ + { + find: '@lib', + replacement: `${path.resolve(__dirname, '../lib')}/`, + }, + { + find: '@xsComponents', + replacement: `${path.resolve(__dirname, '../packages')}/`, + }, + ], + }, +}); diff --git a/package.json b/package.json index 99ae3f9..056ad27 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,13 @@ { - "name": "xiaosi-vue3-components", + "name": "xs-components", "version": "1.0.2", "files": [ "lib" ], + "repository": { + "type": "git", + "url": "git://github.com:jsxiaosi/xiaosiCommitLib.git" + }, "main": "./lib/index.js", "module": "./lib/index.esm.js", "types": "./lib/index.d.ts", @@ -94,12 +98,14 @@ "stylelint-order": "^5.0.0", "stylelint-scss": "^4.3.0", "typescript": "^4.7.4", + "unplugin-vue-define-options": "^0.9.1", "vite": "^3.0.7", "vite-plugin-inspect": "^0.6.0", "vitepress": "^1.0.0-alpha.4" }, "dependencies": { "@vueuse/core": "^9.1.0", + "eslint-plugin-markdown": "^3.0.0", "markdown-it": "^13.0.1", "markdown-it-container": "^3.0.0", "prism-theme-vars": "^0.2.4", diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..d9b7d6b --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,26 @@ +{ + // https://www.tslang.cn/docs/handbook/compiler-options.html + "compilerOptions": { + "target": "es2018", + "module": "esnext", + "moduleResolution": "node", + "removeComments": true, + "noLib": false, + "declaration": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true, + "strictFunctionTypes": false, + "jsx": "preserve", + "baseUrl": ".", + "sourceMap": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "experimentalDecorators": true, + "paths": { + "@xsComponents/*": ["../packages/"] + } + } +} diff --git a/tsconfig.effect.json b/tsconfig.effect.json new file mode 100644 index 0000000..02b1dc6 --- /dev/null +++ b/tsconfig.effect.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.web.json", + "compilerOptions": { + "allowJs": false, + "baseUrl": "./effect", // 解析非相对模块的基础地址,默认是当前目录 + "lib": ["ESNext", "DOM"], + "paths": { + "@xsComponents/*": ["../packages/*"], + "@lib/*": ["../lib/*"] + } + }, + "include": ["packages", "effect/", "typings/vue-shim.d.ts"], + "exclude": ["build", "lib"] +} diff --git a/tsconfig.json b/tsconfig.json index d345ad7..2d059ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,31 +1,55 @@ { - // https://www.tslang.cn/docs/handbook/compiler-options.html - "compilerOptions": { - "target": "es2018", - "module": "esnext", - "moduleResolution": "node", - "removeComments": true, - "noLib": false, - "declaration": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true, - "strictFunctionTypes": false, - "jsx": "preserve", - "baseUrl": ".", - "sourceMap": true, - "esModuleInterop": true, - "resolveJsonModule": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "experimentalDecorators": true, - "types": ["vite/client"], - "typeRoots": ["./node_modules/@types/", "./typings"], - "lib": ["esnext", "dom"], - "paths": { - "@xsComponents/*": ["../packages/"] - } - }, - "include": ["./**/*"], - "exclude": ["node_modules", "dist", "*.js", "discard"] + "files": [], + "references": [{ "path": "./tsconfig.web.json" }, { "path": "./tsconfig.effect.json" }] } + +// { +// // https://www.tslang.cn/docs/handbook/compiler-options.html +// "compilerOptions": { +// "target": "es2018", +// "module": "esnext", +// "moduleResolution": "node", +// "removeComments": true, +// "noLib": false, +// "declaration": true, +// "strict": true, +// "forceConsistentCasingInFileNames": true, +// "allowSyntheticDefaultImports": true, +// "strictFunctionTypes": false, +// "jsx": "preserve", +// "baseUrl": ".", +// "sourceMap": true, +// "esModuleInterop": true, +// "resolveJsonModule": true, +// "noUnusedLocals": true, +// "noUnusedParameters": true, +// "experimentalDecorators": true, +// "types": [ +// "vite/client" +// ], +// "typeRoots": [ +// "./node_modules/@types/", +// "typings" +// ], +// "lib": [ +// "esnext", +// "dom" +// ], +// "paths": { +// "@xsComponents/*": [ +// "../packages/" +// ] +// } +// }, +// "include": [ +// "packages/*", +// "effect/*", +// "./" +// ], +// "exclude": [ +// "node_modules", +// "dist", +// "*.js", +// "discard" +// ] +// } diff --git a/tsconfig.web.json b/tsconfig.web.json new file mode 100644 index 0000000..15400a6 --- /dev/null +++ b/tsconfig.web.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "composite": true, + "jsx": "preserve", + "lib": ["ESNext", "Dom"], + "types": ["unplugin-vue-define-options"], + "skipLibCheck": true + }, + "include": ["packages", "typings/vue-shim.d.ts"], + "exclude": ["node_modules", "dist", "*.js", "lib", "build"] +} diff --git a/typings/global.d.ts b/typings/global.d.ts index 3886d96..342aed2 100644 --- a/typings/global.d.ts +++ b/typings/global.d.ts @@ -1 +1 @@ -declare type Recordable = Record +declare type Recordable = Record;