canirequire › CommonJS › terser-webpack-plugin
Is terser-webpack-plugin ESM-only? Can you require() it?
Minimizer plugin for webpack
Last verified Sep 9, 2026 against terser-webpack-plugin@5.6.1. JSON
CommonJS CommonJS — require() works on every Node.js version
terser-webpack-plugin ships CommonJS only. require("terser-webpack-plugin") works everywhere. import "terser-webpack-plugin" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
Does terser-webpack-plugin@5.6.1 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("terser-webpack-plugin") from a CommonJS file and import "terser-webpack-plugin" from an ES module.
| Runtime | require("terser-webpack-plugin") | import "terser-webpack-plugin" |
|---|---|---|
| Node.js 18 | ✓ works | ✓ works |
| Node.js 20 | ✓ works | ✓ works |
| Node.js 22 | ✓ works | ✓ works |
| Node.js 24 | ✓ works | ✓ works |
| Node.js 26 | ✓ works | ✓ works |
| Bun 1.4 | ✓ works | ✓ works |
How to import terser-webpack-plugin
ES modules (import)
import terserWebpackPlugin from "terser-webpack-plugin";Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.
CommonJS (require)
const terserWebpackPlugin = require("terser-webpack-plugin");Module format by version
Derived from the type, main and exports fields of every stable release on npm (89 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 2.3.2 – 5.6.1 | CommonJS | Jan 9, 2020 |
Frequently asked
Is terser-webpack-plugin ESM-only?
terser-webpack-plugin@5.6.1 is a CommonJS package. terser-webpack-plugin ships CommonJS only. require("terser-webpack-plugin") works everywhere. import "terser-webpack-plugin" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
Can I import terser-webpack-plugin with ES module syntax?
Yes. import terserWebpackPlugin from "terser-webpack-plugin" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.
Does terser-webpack-plugin work in Bun?
Yes. import "terser-webpack-plugin" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does terser-webpack-plugin ship TypeScript types?
Yes. terser-webpack-plugin bundles its own type declarations; no @types package is needed.
Links
Other commonjs packages
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- file-type 22.0.2ESM-only
- cli-spinners 3.4.0ESM-only
- process 0.11.10CommonJS
- package-json-from-dist 1.0.1Dual
- glob-to-regexp 0.4.1CommonJS
- @hookform/resolvers 5.9.1Dual
- bluebird 3.7.2CommonJS
- @aws-sdk/middleware-recursion-detection 3.972.46CommonJS