Registry / devops / webpack-deep-scope-plugin

webpack-deep-scope-plugin

JSON →
library1.6.2jsnpmunverified

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).

npm install webpack-deep-scope-plugin
INSTALL
IMPORT
SIG · WEBPACK-DEEP-SCOPE
W
webpack-deep-scope-plugin
devopsjavascriptv1.6.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebpackDeepScopeAnalysisPlugin
import WebpackDeepScopeAnalysisPlugin from 'webpack-deep-scope-plugin'
const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin')
Default export; requires .default in CommonJS require.
default
const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin').default
const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin')
CommonJS require must access .default property.
WebpackDeepScopeAnalysisPlugin
const { default: WebpackDeepScopeAnalysisPlugin } = require('webpack-deep-scope-plugin')
Destructured require also works.

Shows how to add the plugin to webpack config with CommonJS require and usedExports optimization.

// webpack.config.js const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin').default; module.exports = { // ... other config optimization: { usedExports: true, // required for tree-shaking }, plugins: [ new WebpackDeepScopeAnalysisPlugin(), ], };
Debug
Known issues
gotchaPlugin only works with import/export syntax, not CommonJS requires or transpiled to module.exports.
fix
Ensure your code uses ES modules; avoid Babel transforming to CommonJS unless targeting Node.
affects: all
breakingVersion 1.6.0 renamed the core package to deep-scope-analyser; API unchanged.
fix
Update references if directly using deep-scope-analyser; plugin API remains same.
affects: >=1.6.0
gotchaRequires webpack ^4.14.0; not compatible with webpack 5.
fix
Use webpack 4.x or find alternative for webpack 5 (e.g., webpack's built-in sideEffects flag).
affects: >=1.0.0
deprecatedPlugin may not be actively maintained; last release 1.6.2 in 2019.
fix
Consider using webpack 5's built-in tree-shaking or sideEffects in package.json.
affects: >=1.6.2
Errors
Common errors & fixes
TypeError: WebpackDeepScopeAnalysisPlugin is not a constructor
Forgetting to use .default when requiring with CommonJS.
fix
Import via require('webpack-deep-scope-plugin').default
Error: Module not found: Error: Can't resolve 'deep-scope-analyser'
Missing dependency after npm install (peer dep not auto-installed).
fix
Run npm install deep-scope-analyser
WARNING in ./node_modules/webpack-deep-scope-plugin/dist/index.js Critical dependency: the request of a dependency is an expression
Plugin uses dynamic require patterns that webpack 4 warns about.
fix
Ignore the warning if tree-shaking works; or try using webpack 4.43+ which may reduce warnings.
Upgrade
Version history
1.6.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
webpack-deep-scope-plugin — npm install webpack-deep-scope-plugin · libregistry