{"id":19441,"library":"deep-scope-analyser","title":"Webpack Deep Scope Analysis Plugin","description":"Webpack plugin (npm package deep-scope-analyser v1.7.0, low activity) that improves tree-shaking by performing deep scope analysis to eliminate unused imports and exports. Designed for webpack 4.14.0+ and Node.js 8+. It solves webpack issue #6264 by analyzing variable scopes to determine which imports can be safely removed, beyond what webpack's built-in tree-shaking achieves. The plugin works only with ES module syntax (import/export) and requires the PURE annotation for side-effect marking. Originally named webpack-deep-scope-plugin (v1.5.x), renamed to deep-scope-analyser in v1.6.0 for standalone use. Maintained by a GSoC 2018 student, but has seen no updates since 2019. Differentiators: deeper analysis than standard tree-shaking; but limited to webpack 4 and ESM-only, with potential compatibility issues.","status":"maintenance","version":"1.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/vincentdchan/webpack-deep-scope-analysis-plugin","tags":["javascript","typescript"],"install":[{"cmd":"npm install deep-scope-analyser","lang":"bash","label":"npm"},{"cmd":"yarn add deep-scope-analyser","lang":"bash","label":"yarn"},{"cmd":"pnpm add deep-scope-analyser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency: the plugin integrates as a webpack plugin, requiring webpack >=4.14.0.","package":"webpack","optional":false}],"imports":[{"note":"Default export; the package ships TypeScript definitions.","wrong":"import { WebpackDeepScopeAnalysisPlugin } from 'webpack-deep-scope-plugin';","symbol":"default","correct":"import WebpackDeepScopeAnalysisPlugin from 'webpack-deep-scope-plugin';"},{"note":"CommonJS require must explicitly access .default because the package uses ESM-style default export.","wrong":"const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin');","symbol":"default","correct":"const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin').default;"},{"note":"Alternative package name deep-scope-analyser also works; same default import pattern.","wrong":"import { default as WebpackDeepScopeAnalysisPlugin } from 'deep-scope-analyser';","symbol":"default","correct":"import WebpackDeepScopeAnalysisPlugin from 'deep-scope-analyser';"}],"quickstart":{"code":"// webpack.config.js\nconst WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin').default;\n\nmodule.exports = {\n  mode: 'production',\n  entry: './src/index.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'bundle.js'\n  },\n  plugins: [\n    new WebpackDeepScopeAnalysisPlugin()\n  ]\n};","lang":"javascript","description":"Adds deep scope analysis plugin to a webpack 4 production config to improve tree-shaking."},"warnings":[{"fix":"Use package deep-scope-analyser or continue using webpack-deep-scope-plugin (v1.5.4) for older webpack.","message":"Renamed from webpack-deep-scope-plugin (v1.5.x) to deep-scope-analyser (v1.6.0). Existing import paths break.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Consider alternatives like webpack's built-in sideEffects flag or optimization.usedExports for webpack 5+.","message":"Package has not been updated since 2019; may be incompatible with webpack 5 and modern Node.js (>=14).","severity":"deprecated","affected_versions":">=1.7.0"},{"fix":"Ensure your code uses native ES modules; avoid using @babel/plugin-transform-modules-commonjs.","message":"The plugin only works with ES module syntax (import/export). If Babel or TypeScript transpile to CommonJS (require/module.exports), the analysis fails silently.","severity":"gotcha","affected_versions":"all"},{"fix":"Use const Plugin = require('webpack-deep-scope-plugin').default;","message":"CommonJS require('webpack-deep-scope-plugin') returns an empty object; must use .default property.","severity":"gotcha","affected_versions":">=1.6.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install deep-scope-analyser (or pin version to 1.5.4) and update import to deep-scope-analyser.","cause":"Package was renamed to deep-scope-analyser in v1.6.0.","error":"Module not found: Error: Can't resolve 'webpack-deep-scope-plugin'"},{"fix":"const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin').default;","cause":"Using CommonJS require without .default property.","error":"TypeError: webpackDeepScopeAnalysisPlugin is not a constructor"},{"fix":"npm install webpack@4 --save-dev","cause":"Missing webpack peer dependency.","error":"Error: Cannot find module 'webpack'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}