@@ -16,9 +16,20 @@ export interface Options {
1616 * disable show package size can improve build speed because we get package size by api of https://bundlephobia.com/
1717 */
1818 showPkgSize ?: boolean ;
19+ /**
20+ * useful in ci check
21+ */
1922 throwErrorWhenDuplicated ?: boolean ;
20- whiteList ?: Record < string , string [ ] > ;
21- customErrorMessage ?: ( issuePackages : Map < string , string [ ] > ) => string ;
23+ /**
24+ * @example
25+ * ```javascript
26+ * {
27+ * axios: ['0.17.4', '1.4.0']
28+ * }
29+ * ```
30+ */
31+ whitelist ?: Record < string , string [ ] > ;
32+ customErrorMessage ?: ( issuePackagesMap : Map < string , string [ ] > ) => string ;
2233 logLevel ?: 'debug' | 'error' ;
2334}
2435
@@ -48,11 +59,12 @@ function colorizeSize(kb: number) {
4859
4960export default createUnplugin < Options | undefined > ( ( options ) => {
5061 const name = 'unplugin-detect-duplicated-deps' ;
62+
5163 let isVitePlugin = false ;
5264 const {
5365 showPkgSize = true ,
5466 throwErrorWhenDuplicated = false ,
55- whiteList = { } ,
67+ whitelist : whiteList = { } ,
5668 customErrorMessage,
5769 logLevel = 'debug' ,
5870 } = options ?? { } ;
@@ -215,7 +227,7 @@ export default createUnplugin<Options | undefined>((options) => {
215227 }
216228 }
217229 }
218- const issueString = [ ...issuePackagesMap . entries ( ) ]
230+ const duplicatedDepsList = [ ...issuePackagesMap . entries ( ) ]
219231 . map ( ( [ packageName , _versions ] ) => {
220232 const versions = _versions . map ( ( version ) => `v${ version } ` ) . join ( ', ' ) ;
221233 return ` - ${ packageName } : ${ versions } ` ;
@@ -226,7 +238,7 @@ export default createUnplugin<Options | undefined>((options) => {
226238 throw new Error (
227239 customErrorMessage
228240 ? customErrorMessage ( issuePackagesMap )
229- : `You can add following duplicated deps to whiteList to pass the check :\n${ issueString } ` ,
241+ : `You can add following duplicated deps to whitelist option to suppress this error :\n${ duplicatedDepsList } ` ,
230242 ) ;
231243 }
232244 }
0 commit comments