{"id":20741,"library":"webpack-deep-scope-plugin","title":"webpack-deep-scope-plugin","description":"A webpack plugin that improves tree-shaking by performing deep scope analysis to eliminate unused imports related to unused exports. Version 1.6.2 requires webpack ^4.14.0 and Node.js 8+. It solves webpack issue #6264 by analyzing variable scopes and removing dead code more aggressively than standard tree-shaking. Uses TypeScript and includes a custom version of escope. Alternative to webpack's built-in sideEffects flag but only works with ES module syntax (import/export).","status":"active","version":"1.6.2","language":"javascript","source_language":"en","source_url":"https://github.com/vincentdchan/webpack-deep-scope-analysis-plugin","tags":["javascript"],"install":[{"cmd":"npm install webpack-deep-scope-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-deep-scope-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-deep-scope-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export; requires .default in CommonJS require.","wrong":"const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin')","symbol":"WebpackDeepScopeAnalysisPlugin","correct":"import WebpackDeepScopeAnalysisPlugin from 'webpack-deep-scope-plugin'"},{"note":"CommonJS require must access .default property.","wrong":"const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin')","symbol":"default","correct":"const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin').default"},{"note":"Destructured require also works.","wrong":null,"symbol":"WebpackDeepScopeAnalysisPlugin","correct":"const { default: WebpackDeepScopeAnalysisPlugin } = require('webpack-deep-scope-plugin')"}],"quickstart":{"code":"// webpack.config.js\nconst WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin').default;\n\nmodule.exports = {\n  // ... other config\n  optimization: {\n    usedExports: true, // required for tree-shaking\n  },\n  plugins: [\n    new WebpackDeepScopeAnalysisPlugin(),\n  ],\n};","lang":"javascript","description":"Shows how to add the plugin to webpack config with CommonJS require and usedExports optimization."},"warnings":[{"fix":"Ensure your code uses ES modules; avoid Babel transforming to CommonJS unless targeting Node.","message":"Plugin only works with import/export syntax, not CommonJS requires or transpiled to module.exports.","severity":"gotcha","affected_versions":"all"},{"fix":"Update references if directly using deep-scope-analyser; plugin API remains same.","message":"Version 1.6.0 renamed the core package to deep-scope-analyser; API unchanged.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Use webpack 4.x or find alternative for webpack 5 (e.g., webpack's built-in sideEffects flag).","message":"Requires webpack ^4.14.0; not compatible with webpack 5.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using webpack 5's built-in tree-shaking or sideEffects in package.json.","message":"Plugin may not be actively maintained; last release 1.6.2 in 2019.","severity":"deprecated","affected_versions":">=1.6.2"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Import via require('webpack-deep-scope-plugin').default","cause":"Forgetting to use .default when requiring with CommonJS.","error":"TypeError: WebpackDeepScopeAnalysisPlugin is not a constructor"},{"fix":"Run npm install deep-scope-analyser","cause":"Missing dependency after npm install (peer dep not auto-installed).","error":"Error: Module not found: Error: Can't resolve 'deep-scope-analyser'"},{"fix":"Ignore the warning if tree-shaking works; or try using webpack 4.43+ which may reduce warnings.","cause":"Plugin uses dynamic require patterns that webpack 4 warns about.","error":"WARNING in ./node_modules/webpack-deep-scope-plugin/dist/index.js Critical dependency: the request of a dependency is an expression"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}