Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
perf: expose type VitePluginOptions, fix #19
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed May 25, 2021
1 parent 26052b5 commit 013dc29
Show file tree
Hide file tree
Showing 6 changed files with 375 additions and 296 deletions.
12 changes: 6 additions & 6 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
"build": "vite build "
},
"dependencies": {
"ant-design-vue": "^2.1.2",
"element-plus": "^1.0.2-beta.40",
"vant": "^3.0.14",
"ant-design-vue": "^2.1.6",
"element-plus": "^1.0.2-beta.44",
"vant": "^3.0.17",
"vue": "^3.0.11"
},
"devDependencies": {
"@types/rollup": "^0.54.0",
"@vitejs/plugin-vue": "^1.2.1",
"@vitejs/plugin-vue-jsx": "^1.1.3",
"@vitejs/plugin-vue": "^1.2.2",
"@vitejs/plugin-vue-jsx": "^1.1.4",
"@vue/compiler-sfc": "^3.0.11",
"cross-env": "^7.0.3",
"less": "^4.1.1",
"typescript": "^4.2.4",
"vite": "^2.2.1",
"vite": "^2.3.4",
"vite-plugin-style-import": "^0.7.6"
}
}
128 changes: 72 additions & 56 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@
dependencies:
rollup "*"

"@vant/icons@^1.5.3":
version "1.5.3"
resolved "https://registry.npmjs.org/@vant/icons/-/icons-1.5.3.tgz#b7779f67bf608d417a82452fbede406dfa46b439"
integrity sha512-OQaJqAWN6quHicWje4buknX9zcDo3UDy3X4nrk/ldnr9Fj8Str4nMtQbMbIrCMtmjQdP2ei769uuY508dudrjA==
"@vant/icons@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@vant/icons/-/icons-1.6.0.tgz#3db7eb7f963f51a2a08676720d5af9c4c3512feb"
integrity sha512-4Hvq4tl4grCOJLZ0e8ZaivBV8xOcmTPmTT8BDkTrEIKqnDowRFDdsXxcHECzWmbmMx+CYGdngvd2Cq8YR9DfKA==

"@vant/lazyload@^1.1.1":
version "1.1.1"
resolved "https://registry.npmjs.org/@vant/lazyload/-/lazyload-1.1.1.tgz#9eafcf85cdd750463a552a07cf18e5c620c6ccef"
integrity sha512-ejMxgeWP0GBAuzwaC0RG131JKI4SKSpu9kxNR/wyWdOZmkrAR7HZO0GciGG2illgKvs11gPtepik8X/k9iWIXw==
"@vant/lazyload@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@vant/lazyload/-/lazyload-1.2.0.tgz#62e9779bd7844ad8f71c2ca2bf852e6147c7a86d"
integrity sha512-QsqNm8nNat4z9TdrTI4YkDXZXgg3dbGhHf7tC4mhel+gJ0u2WZcoMYKWkzQXvO+vo395cByT5iUE5a72360B2Q==

"@vant/popperjs@^1.1.0":
version "1.1.0"
Expand All @@ -359,26 +359,27 @@
dependencies:
"@popperjs/core" "^2.9.2"

"@vant/use@^1.1.1":
"@vant/use@^1.1.2":
version "1.1.2"
resolved "https://registry.npmjs.org/@vant/use/-/use-1.1.2.tgz#d35265e05df88a47b04196a308efb5e89e44ca10"
resolved "https://registry.yarnpkg.com/@vant/use/-/use-1.1.2.tgz#d35265e05df88a47b04196a308efb5e89e44ca10"
integrity sha512-s4YO6zqJ3NlGeAZ104exb0c/KvlXB908pOhWhCyhfedVBn1eBnKH401ildK0sttazmq0CH8jme6mnw2ZzZvutw==

"@vitejs/plugin-vue-jsx@^1.1.3":
version "1.1.3"
resolved "https://registry.npmjs.org/@vitejs/plugin-vue-jsx/-/plugin-vue-jsx-1.1.3.tgz#426c68f8a367a603acb82fca6e2b12506ba9fc8e"
integrity sha512-R9wsuNDEKTDG5oXJaFictrw9E5uokniGzi6tvyO5Od02tE4TnOPfgY2BeHKB4f4ldgiZRMhdUhNEsgjoWnct6A==
"@vitejs/plugin-vue-jsx@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue-jsx/-/plugin-vue-jsx-1.1.4.tgz#3af194202f9ed38a7384f7a7c72f5b66ce863859"
integrity sha512-QomJwH9oF5Ixl000fLK4TjKE4gwnxpArZdcHs6ANrtgsXwxyoib8msz9tNgiP2TiBfg7VdShbaUBYMvm0gPGsA==
dependencies:
"@babel/core" "^7.12.10"
"@babel/plugin-syntax-import-meta" "^7.10.4"
"@babel/plugin-transform-typescript" "^7.12.1"
"@rollup/pluginutils" "^4.1.0"
"@vue/babel-plugin-jsx" "^1.0.3"
hash-sum "^2.0.0"

"@vitejs/plugin-vue@^1.2.1":
version "1.2.1"
resolved "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-1.2.1.tgz#6de49436fc346f829a56676066428e3f011522ac"
integrity sha512-TG+LbEUNwfFrx1VyN+iq+PsiGd9MT16hUdJY+BnMXj3MrLAF8m3VYUspTDM3aXoh48YDmAkMjG4gWFRg3lbG5A==
"@vitejs/plugin-vue@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-1.2.2.tgz#b0038fc11b9099f4cd01fcbf0ee419adda417b52"
integrity sha512-5BI2WFfs/Z0pAV4S/IQf1oH3bmFYlL5ATMBHgTt1Lf7hAnfpNd5oUAAs6hZPfk3QhvyUQgtk0rJBlabwNFcBJQ==

"@vue/babel-helper-vue-transform-on@^1.0.2":
version "1.0.2"
Expand Down Expand Up @@ -533,10 +534,10 @@ ansi-styles@^3.2.1:
dependencies:
color-convert "^1.9.0"

ant-design-vue@^2.1.2:
version "2.1.2"
resolved "https://registry.npmjs.org/ant-design-vue/-/ant-design-vue-2.1.2.tgz#2065d7e63199c0c584919458af57b6a0b597f677"
integrity sha512-gDG0wauGVt4LE63behrJaIcq4BB+dgs+dpj9jz17IgKr2MPYSEeKetU/x9Kk8d58cGonz4Ulncg7fBZJ7EljsQ==
ant-design-vue@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/ant-design-vue/-/ant-design-vue-2.1.6.tgz#c51cdc858e1b1b8b569f5435eb487f53a3f1745e"
integrity sha512-qICxb6Y4f7QuSuh/jbLhZA9SkUBnP9xYfy/E6yD7+1fg04aAzmRK8oLv8ETuGTrROVdSVeic9v/NS2BXEuuARg==
dependencies:
"@ant-design-vue/use" "^0.0.1-0"
"@ant-design/icons-vue" "^6.0.0"
Expand All @@ -546,7 +547,7 @@ ant-design-vue@^2.1.2:
async-validator "^3.3.0"
dom-align "^1.10.4"
dom-scroll-into-view "^2.0.0"
is-mobile "^2.2.1"
lodash "^4.17.21"
lodash-es "^4.17.15"
moment "^2.27.0"
omit.js "^2.0.0"
Expand Down Expand Up @@ -642,6 +643,11 @@ colorette@^1.2.1:
resolved "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b"
integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==

colorette@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==

compute-scroll-into-view@^1.0.16:
version "1.0.16"
resolved "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-1.0.16.tgz#5b7bf4f7127ea2c19b750353d7ce6776a90ee088"
Expand Down Expand Up @@ -752,10 +758,10 @@ dot-case@^3.0.4:
no-case "^3.0.4"
tslib "^2.0.3"

element-plus@^1.0.2-beta.40:
version "1.0.2-beta.40"
resolved "https://registry.npmjs.org/element-plus/-/element-plus-1.0.2-beta.40.tgz#30fc9b161496ae587fab86235c80b728ea43d909"
integrity sha512-8S7JbBpJLUa3ggexuKuKeyrTo451gMDHa/BKJVFiHSyexcHPgnHQwHf2nIoZvY1w6FzmZPdBdZ3NoDLXu51SIw==
element-plus@^1.0.2-beta.44:
version "1.0.2-beta.44"
resolved "https://registry.yarnpkg.com/element-plus/-/element-plus-1.0.2-beta.44.tgz#7aff122e6181088223027adb65a4a8321e1ef4e9"
integrity sha512-PmGfOnV/66LPGSsSbaesiTnmrcQ5PnoZLr2eKRv2/lJ06xUc0AiSBiktGrds0mETgC1O/mRHswXk/Se6aJtpKQ==
dependencies:
"@popperjs/core" "^2.4.4"
"@types/lodash" "^4.14.161"
Expand Down Expand Up @@ -783,10 +789,10 @@ es-module-lexer@^0.4.0:
resolved "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.4.0.tgz#21f4181cc8b7eee06855f1c59e6087c7bc4f77b0"
integrity sha512-iuEGihqqhKWFgh72Q/Jtch7V2t/ft8w8IPP2aEN8ArYKO+IWyo6hsi96hCdgyeEDQIV3InhYQ9BlwUFPGXrbEQ==

esbuild@^0.9.3:
version "0.9.6"
resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.9.6.tgz#2cae519e7ce2328ecf57ae738090d07ce7245850"
integrity sha512-F6vASxU0wT/Davt9aj2qtDwDNSkQxh9VbyO56M7PDWD+D/Vgq/rmUDGDQo7te76W5auauVojjnQr/wTu3vpaUA==
esbuild@^0.11.23:
version "0.11.23"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.11.23.tgz#c42534f632e165120671d64db67883634333b4b8"
integrity sha512-iaiZZ9vUF5wJV8ob1tl+5aJTrwDczlvGP0JoMmnpC2B0ppiMCu8n8gmy5ZTGl5bcG081XBVn+U+jP+mPFm5T5Q==

escape-string-regexp@^1.0.5:
version "1.0.5"
Expand Down Expand Up @@ -894,11 +900,6 @@ is-core-module@^2.1.0:
dependencies:
has "^1.0.3"

is-mobile@^2.2.1:
version "2.2.2"
resolved "https://registry.npmjs.org/is-mobile/-/is-mobile-2.2.2.tgz#f6c9c5d50ee01254ce05e739bdd835f1ed4e9954"
integrity sha512-wW/SXnYJkTjs++tVK5b6kVITZpAZPtUrt9SF80vvxGiF/Oywal+COk1jlRkiVq15RFNEQKQY31TkV24/1T5cVg==

[email protected]:
version "3.0.1"
resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b"
Expand Down Expand Up @@ -979,6 +980,11 @@ lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20:
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

loose-envify@^1.0.0:
version "1.4.0"
resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
Expand Down Expand Up @@ -1057,6 +1063,11 @@ nanoid@^3.1.20:
resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788"
integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==

nanoid@^3.1.23:
version "3.1.23"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81"
integrity sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==

nanopop@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/nanopop/-/nanopop-2.1.0.tgz#23476513cee2405888afd2e8a4b54066b70b9e60"
Expand Down Expand Up @@ -1204,14 +1215,14 @@ postcss@^8.1.10:
nanoid "^3.1.20"
source-map "^0.6.1"

postcss@^8.2.1:
version "8.2.4"
resolved "https://registry.npmjs.org/postcss/-/postcss-8.2.4.tgz#20a98a39cf303d15129c2865a9ec37eda0031d04"
integrity sha512-kRFftRoExRVXZlwUuay9iC824qmXPcQQVzAjbCCgjpXnkdMCJYBu2gTwAaFBzv8ewND6O8xFb3aELmEkh9zTzg==
postcss@^8.2.10:
version "8.3.0"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.0.tgz#b1a713f6172ca427e3f05ef1303de8b65683325f"
integrity sha512-+ogXpdAjWGa+fdYY5BQ96V/6tAo+TdSSIMP5huJBIygdWwKtVoB5JWZ7yUd4xZ8r+8Kvvx4nyg/PQ071H4UtcQ==
dependencies:
colorette "^1.2.1"
nanoid "^3.1.20"
source-map "^0.6.1"
colorette "^1.2.2"
nanoid "^3.1.23"
source-map-js "^0.6.2"

prr@~1.0.1:
version "1.0.1"
Expand Down Expand Up @@ -1311,6 +1322,11 @@ snake-case@^3.0.4:
dot-case "^3.0.4"
tslib "^2.0.3"

source-map-js@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e"
integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug==

source-map@^0.5.0:
version "0.5.7"
resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
Expand Down Expand Up @@ -1387,15 +1403,15 @@ util-deprecate@^1.0.2:
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=

vant@^3.0.14:
version "3.0.14"
resolved "https://registry.npmjs.org/vant/-/vant-3.0.14.tgz#a6f22a682b41dcddf774868e7797c169dc04df5a"
integrity sha512-95cPPGebkRpJbxWSLijtw6AwCO2K+PoWO1/itSg9npiLQSKc2g9n+Z5cumYOrpvhn2WmIzeDWNt6+gFxDh1W5Q==
vant@^3.0.17:
version "3.0.17"
resolved "https://registry.yarnpkg.com/vant/-/vant-3.0.17.tgz#c8466a1fe24966dd67aff4fbff7ecdd43129e7bc"
integrity sha512-KhNhQhej2sXu1Juu2Nu/Kvetx9k8SCTIfVJD9RC4ZLBCyHi8rOTpMk8N/6unPShC6ZEPNbPa/F4x2d8zvve05A==
dependencies:
"@vant/icons" "^1.5.3"
"@vant/lazyload" "^1.1.1"
"@vant/icons" "^1.6.0"
"@vant/lazyload" "^1.2.0"
"@vant/popperjs" "^1.1.0"
"@vant/use" "^1.1.1"
"@vant/use" "^1.1.2"

vite-plugin-style-import@^0.7.6:
version "0.7.6"
Expand All @@ -1408,13 +1424,13 @@ vite-plugin-style-import@^0.7.6:
es-module-lexer "^0.4.0"
magic-string "^0.25.7"

vite@^2.2.1:
version "2.2.1"
resolved "https://registry.npmjs.org/vite/-/vite-2.2.1.tgz#90c481f69371f32867d86a6a623bb064b876ad3d"
integrity sha512-KIqK90EoJJpuqE86Y9DSkZjFNGgsyZX/4I1xENIitLRd3hgRtOlIGCJYrNnBD9/eqipz0OroAiIj9/R1JcOdFA==
vite@^2.3.4:
version "2.3.4"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.3.4.tgz#370118e0334725b898ff754ea43d5db4c5e120e3"
integrity sha512-7orxrF65+Q5n/sMCnO91S8OS0gkPJ7g+y3bLlc7CPCXVswK8to1T8YycCk9SZh+AcIc0TuN6YajWTBFS5atMNA==
dependencies:
esbuild "^0.9.3"
postcss "^8.2.1"
esbuild "^0.11.23"
postcss "^8.2.10"
resolve "^1.19.0"
rollup "^2.38.5"
optionalDependencies:
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@
"vite": ">=2.0.0"
},
"devDependencies": {
"@commitlint/cli": "^12.1.1",
"@commitlint/config-conventional": "^12.1.1",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@types/debug": "^4.1.5",
"@types/es-module-lexer": "^0.3.0",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.41",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"commitizen": "^4.2.3",
"@types/jest": "^26.0.23",
"@types/node": "^14.17.1",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"commitizen": "^4.2.4",
"conventional-changelog-cli": "^2.1.1",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-jest": "^24.3.5",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^24.3.6",
"husky": "^5.2.0",
"ini": "^2.0.0",
"jest": "^26.6.3",
"lint-staged": "^10.5.4",
"pinst": "^2.1.6",
"prettier": "^2.2.1",
"prettier": "^2.3.0",
"pretty-quick": "^3.1.0",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.5",
"tsup": "^4.9.1",
"ts-jest": "^26.5.6",
"tsup": "^4.11.1",
"typescript": "^4.2.4",
"vite": "^2.2.1"
"vite": "^2.3.4"
}
}
11 changes: 4 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import type { Plugin } from 'vite';
import type { ExternalOption } from 'rollup';

import type {
ChangeCaseType,
VitePluginComponentImport,
LibraryNameChangeCase,
Lib,
} from './types';
import type { ChangeCaseType, VitePluginOptions, LibraryNameChangeCase, Lib } from './types';

import { createFilter } from '@rollup/pluginutils';
import * as changeCase from 'change-case';
Expand All @@ -29,7 +24,9 @@ const asRE = /\s+as\s+\w+,?/g;
const isFn = (value: any): value is (...args: any[]) => any =>
value != null && Object.prototype.toString.call(value) === '[object Function]';

export default (options: VitePluginComponentImport): Plugin => {
export * from './types';

export default (options: VitePluginOptions): Plugin => {
const {
include = ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx'],
exclude = 'node_modules/**',
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface Lib {
libraryNameChangeCase?: LibraryNameChangeCase;
}

export interface VitePluginComponentImport {
export interface VitePluginOptions {
include?: RegOptions;
exclude?: RegOptions;
/**
Expand Down
Loading

0 comments on commit 013dc29

Please sign in to comment.