canirequire

canirequireCommonJS › 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.

Latest
5.6.1 (May 27, 2026)
Module format
CommonJS
Last CommonJS version
5.6.1
TypeScript types
Bundled
Node engines
>= 10.13.0
Weekly downloads
40.0M
License
MIT

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.

Runtimerequire("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).

VersionsFormatFirst published
2.3.2 – 5.6.1CommonJSJan 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

Similar popularity