{"id":20739,"library":"webpack-deduplication-plugin","title":"Webpack Deduplication Plugin","description":"Webpack plugin that deduplicates transitive dependencies in yarn and webpack-based projects. Version 0.0.8 (stable, low release cadence) by Atlassian Labs. Uses content-based caching via yarn.lock to avoid duplicate modules. Differentiator: targeted at monorepo or complex dependency trees where multiple versions of the same package are bundled, reducing bundle size. Compared to alternatives like DedupePlugin, this plugin persists cache across builds and integrates tightly with yarn workspace resolution. Currently in early development; lacking documentation and tests.","status":"active","version":"0.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/atlassian-labs/webpack-deduplication-plugin","tags":["javascript","Webpack","Webpack plugin","typescript"],"install":[{"cmd":"npm install webpack-deduplication-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-deduplication-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-deduplication-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to auto-detect project root if not provided","package":"app-root-path","optional":true}],"imports":[{"note":"Package exports a named export, not a default. CommonJS require with named destructuring works too: const { WebpackDeduplicationPlugin } = require('...')","wrong":"const WebpackDeduplicationPlugin = require('webpack-deduplication-plugin').default","symbol":"WebpackDeduplicationPlugin","correct":"import { WebpackDeduplicationPlugin } from 'webpack-deduplication-plugin'"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\nconst { WebpackDeduplicationPlugin } = require('webpack-deduplication-plugin');\n\nconst cacheDirPath = path.resolve(__dirname, '.cache/webpack-deduplication');\nconst rootPath = path.resolve(__dirname, '.');\n\nmodule.exports = {\n  context: __dirname,\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new WebpackDeduplicationPlugin({\n      cacheDir: cacheDirPath,\n      rootPath: rootPath,\n    }),\n  ],\n};","lang":"javascript","description":"Shows how to configure and use WebpackDeduplicationPlugin in webpack.config.js with cacheDir and rootPath."},"warnings":[{"fix":"Test thoroughly in your project; contribute fixes if issues arise.","message":"Plugin is experimental; may not handle all edge cases in dependency deduplication.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Manually delete cacheDir when yarn.lock changes or dependencies update.","message":"cacheDir is not cleaned automatically; stale cache may cause incorrect deduplication after dependency changes.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use only with webpack 4+; check compatibility with your webpack version.","message":"Plugin requires webpack 4 or 5; not tested with other bundlers.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure plugin is added to plugins array after other plugins that modify compiler context, or set rootPath explicitly.","cause":"WebpackDeduplicationPlugin expects a webpack compiler object with context; misconfigured plugin order.","error":"TypeError: Cannot read property 'context' of undefined"},{"fix":"Provide correct rootPath or ensure a yarn.lock file exists at the root; plugin currently only supports yarn.","cause":"Plugin cannot find yarn.lock because rootPath is incorrect or project uses npm/pnpm.","error":"Error: ENOENT: no such file or directory, open '.../yarn.lock'"},{"fix":"Install app-root-path as a dev dependency or provide rootPath explicitly.","cause":"app-root-path is an optional dependency; if missing and rootPath not provided, plugin throws.","error":"Module not found: Error: Can't resolve 'app-root-path'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}