Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unplugin-detect-duplicated-deps

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-detect-duplicated-deps - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

dist/chunk-4DZBLFMG.js

4

dist/index.js
import {
src_default
} from "./chunk-7HPYUO62.js";
import "./chunk-PIYLEHMN.js";
} from "./chunk-H5CAYXHC.js";
import "./chunk-4DZBLFMG.js";
export {
src_default as default
};

@@ -0,1 +1,22 @@

/**
* ```plaintext
* {
* 'axios' => Map(2) {
* '1.4.0' => Map(1) {
* 'node_modules/.pnpm/axios@1.4.0/node_modules/axios' => Set(1) ['tests/fixtures/mono/packages/pkg2/index.js']
* },
* '0.27.2' => Map(1) {
* 'node_modules/.pnpm/axios@0.27.2/node_modules/axios' => Set(1) ['tests/fixtures/mono/packages/pkg1/index.js']
* }
* },
* '@yutengjing/foo' => Map(1) {
* '1.0.3' => Map(2) {
* 'node_modules/.pnpm/@yutengjing+foo@1.0.3_vue@2.6.14/node_modules/@yutengjing/foo' => Set(1) ['tests/fixtures/mono/packages/pkg1/index.js'],
* 'node_modules/.pnpm/@yutengjing+foo@1.0.3_vue@2.7.16/node_modules/@yutengjing/foo' => Set(1) ['tests/fixtures/mono/packages/pkg2/index.js']
* }
* }
* }
* ```
*/
type PackagesInfo = Map<string, Map<string, Map<string, Set<string>>>>;
interface Options {

@@ -34,23 +55,6 @@ /**

* Custom the error message when exists duplicated deps
*
* @example
*
* ```txt
* packageToVersionsMap structure:
*
* Map(2) {
* '@pixi/utils' => Map(2) {
* '7.0.0' => Set(1) { 'tests/fixtures/mono/packages/pkg2/index.js' },
* '7.2.4' => Set(1) { 'tests/fixtures/mono/packages/pkg1/index.js' }
* },
* 'axios' => Map(2) {
* '0.27.2' => Set(1) { 'tests/fixtures/mono/packages/pkg2/index.js' },
* '1.4.0' => Set(1) { 'tests/fixtures/mono/packages/pkg1/index.js' }
* }
* }
* ```
*/
customErrorMessage?: (packageToVersionsMap: Map<string, Map<string, Set<string>>>) => string;
customErrorMessage?: (packageToVersionsMap: PackagesInfo) => string;
}
export type { Options };
export type { Options, PackagesInfo };

@@ -1,6 +0,6 @@

import * as unplugin from 'unplugin';
import * as rollup from 'rollup';
import { Options } from './options.js';
declare const _default: (options?: Options | undefined) => unplugin.RollupPlugin<any> | unplugin.RollupPlugin<any>[];
declare const _default: (options?: Options | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
export { _default as default };
import {
src_default
} from "./chunk-7HPYUO62.js";
import "./chunk-PIYLEHMN.js";
} from "./chunk-H5CAYXHC.js";
import "./chunk-4DZBLFMG.js";

@@ -6,0 +6,0 @@ // src/rollup.ts

declare function memoizeAsync<F extends (...params: any[]) => Promise<any>>(f: F, getCacheKey?: (...args: Parameters<F>) => string): ((...params: Parameters<F>) => Promise<Awaited<ReturnType<F>>>) & {
destroy: () => void;
};
declare function colorizeSize(kb: number): string;
declare function getPkgSize(name: string, version: string): Promise<number>;
declare function colorizeSize(kb: number, bracket?: boolean): string;
declare const getWorkspaceRootFolder: (() => Promise<string | null>) & {
destroy: () => void;
};
declare const relativeToWorkspace: (path: string) => Promise<string>;
declare const getPkgSize: ((name: string, version: string) => Promise<number>) & {
destroy: () => void;
};
interface PkgInfo {
name: string;
version: string;
directory: string;
}
declare const packagePathRegex: RegExp;
declare const getPackageInfo: ((id: string, deep: boolean, importer?: string | undefined) => Promise<PkgInfo | null>) & {
destroy: () => void;
};
declare const formatImporter: ((importer: string, deep: boolean) => Promise<string>) & {
destroy: () => void;
};
export { colorizeSize, getPkgSize, memoizeAsync };
export { colorizeSize, formatImporter, getPackageInfo, getPkgSize, getWorkspaceRootFolder, memoizeAsync, packagePathRegex, relativeToWorkspace };
import {
colorizeSize,
formatImporter,
getPackageInfo,
getPkgSize,
memoizeAsync
} from "./chunk-PIYLEHMN.js";
getWorkspaceRootFolder,
memoizeAsync,
packagePathRegex,
relativeToWorkspace
} from "./chunk-4DZBLFMG.js";
export {
colorizeSize,
formatImporter,
getPackageInfo,
getPkgSize,
memoizeAsync
getWorkspaceRootFolder,
memoizeAsync,
packagePathRegex,
relativeToWorkspace
};

@@ -1,6 +0,6 @@

import * as vite from 'vite';
import * as unplugin from 'unplugin';
import { Options } from './options.js';
declare const _default: (options?: Options | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
declare const _default: (options?: Options | undefined) => unplugin.VitePlugin<any> | unplugin.VitePlugin<any>[];
export { _default as default };
import {
src_default
} from "./chunk-7HPYUO62.js";
import "./chunk-PIYLEHMN.js";
} from "./chunk-H5CAYXHC.js";
import "./chunk-4DZBLFMG.js";

@@ -6,0 +6,0 @@ // src/vite.ts

import {
src_default
} from "./chunk-7HPYUO62.js";
import "./chunk-PIYLEHMN.js";
} from "./chunk-H5CAYXHC.js";
import "./chunk-4DZBLFMG.js";

@@ -6,0 +6,0 @@ // src/webpack.ts

{
"name": "unplugin-detect-duplicated-deps",
"version": "1.1.1",
"version": "2.0.0",
"description": "Detect duplicate packaged dependencies",

@@ -85,3 +85,3 @@ "keywords": [

"semver": "^7.6.0",
"unplugin": "^1.10.0",
"unplugin": "^1.10.1",
"workspace-root": "^3.2.0"

@@ -91,6 +91,6 @@ },

"@types/cardinal": "^2.1.1",
"@types/node": "^18.19.26",
"@types/node": "^18.19.28",
"@types/semver": "^7.5.8",
"@yutengjing/eslint-config-typescript": "^0.6.0",
"@yutengjing/prettier-config": "^1.1.2",
"@yutengjing/eslint-config-typescript": "^0.7.0",
"@yutengjing/prettier-config": "^1.2.0",
"@yutengjing/release": "^0.2.0",

@@ -103,3 +103,2 @@ "eslint": "^8.57.0",

"typescript": "^5.4.3",
"vite": "^5.2.2",
"vitest": "^1.4.0"

@@ -106,0 +105,0 @@ },

@@ -59,3 +59,2 @@ # unplugin-detect-duplicated-deps

};
export default config;
```

@@ -66,2 +65,20 @@

## Use as build checker
```ts
export default defineConfig({
plugins: [
UnpluginDetectDuplicatedDeps({
// will exit build process if duplicated deps found
throwErrorWhenDuplicated: true,
// ignore specific duplicated deps
ignore: {
axios: ['0.27.2'],
vue: ['*'],
},
}),
],
});
```
## Use in commonjs environment

@@ -71,3 +88,3 @@

## Related Projects
## Thanks

@@ -78,5 +95,12 @@ - [duplicate-package-checker-webpack-plugin](https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin)

- [bundlephobia](https://bundlephobia.com/) provide the api to get package size
- [vercel](https://vercel.com/) host documentation
## Recommend Readings
- [Rsdoctor | Duplicate Dependency Problem](https://rsdoctor.dev/blog/topic/duplicate-pkg-problem)
- [Pnpm | How peers are resolved](https://pnpm.io/how-peers-are-resolved)
- [如何解决项目依赖重复打包问题](https://yutengjing.com/posts/%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%E9%A1%B9%E7%9B%AE%E4%BE%9D%E8%B5%96%E9%87%8D%E5%A4%8D%E6%89%93%E5%8C%85%E9%97%AE%E9%A2%98/)
## License
[MIT](./LICENSE) License © 2023-PRESENT [YuTengjing](https://github.com/tjx666)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc