Registry / devops / targets-webpack-plugin

targets-webpack-plugin

JSON →
library4.0.0jsnpmunverified

Webpack plugin that uses Babel to transpile output bundles for legacy browsers, including dependencies. Version 4.0.0 requires Node >=8. Unlike other solutions (e.g., babel-loader applied per file), it runs transpilation once per asset at the end of compilation, reducing build time. Key differentiator: it handles dependency transpilation automatically and supports custom browser targets via the Browserslist ecosystem.

npm install targets-webpack-plugin
INSTALL
IMPORT
SIG · TARGETS-WEBPACK-PL
T
targets-webpack-plugin
devopsjavascriptv4.0.0
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.

TargetsPlugin
const TargetsPlugin = require('targets-webpack-plugin');
import TargetsPlugin from 'targets-webpack-plugin';
The package does not export a default ES module; CommonJS require is required.

Configures the TargetsPlugin in a Next.js webpack config to transpile production bundles for legacy browsers.

// next.config.js const TargetsPlugin = require('targets-webpack-plugin'); module.exports = { webpack: function (config, { dev }) { if (!dev) { config.plugins.push(new TargetsPlugin({ browsers: ['last 2 versions', 'chrome >= 41'] })); } return config; } };
Debug
Known issues
gotchaPlugin only transpiles in production mode when 'dev' is false; ensure correct conditional.
fix
Check that the plugin is only added when process.env.NODE_ENV === 'production' or similar.
affects: >=1.0.0
gotchaRequires webpack as a peer dependency; missing webpack will cause runtime errors.
fix
Install webpack: npm install webpack --save-dev
affects: >=4.0.0
deprecatedThe 'browsers' option uses Browserslist; older configs may reference 'browserslist' array directly.
fix
Use object with 'browsers' key or rely on browserslist config file.
affects: <4.0.0
Errors
Common errors & fixes
Error: Cannot find module 'targets-webpack-plugin'
Package not installed in node_modules.
fix
Run npm install --save-dev targets-webpack-plugin
TypeError: TargetsPlugin is not a constructor
Using ES module import instead of CommonJS require.
fix
Replace import with: const TargetsPlugin = require('targets-webpack-plugin');
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency required for plugin integration
Agent activity
12 hits · last 30 days
node
11
Resources
targets-webpack-plugin — npm install targets-webpack-plugin · libregistry