Registry / devops / webpack-babel-env-deps

webpack-babel-env-deps

JSON →
library1.6.4jsnpmunverified

A webpack helper to identify which npm dependencies need Babel transpilation by comparing their package.json engines and module fields against your project's Node.js targets. Version 1.6.4 is current; stable with minor releases. Key differentiator: automates the tedious manual process of checking each dependency's engine compatibility for transpilation decisions, integrating with @babel/preset-env to avoid over-transpiling or missing required transforms.

npm install webpack-babel-env-deps
INSTALL
IMPORT
SIG · WEBPACK-BABEL-ENV-
W
webpack-babel-env-deps
devopsjavascriptv1.6.4
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.

findDependenciesToTranspile
import { findDependenciesToTranspile } from 'webpack-babel-env-deps'
const findDependenciesToTranspile = require('webpack-babel-env-deps').findDependenciesToTranspile
ESM export; also available as default export
default
import webpackBabelEnvDeps from 'webpack-babel-env-deps'
const webpackBabelEnvDeps = require('webpack-babel-env-deps').default
Default export is the main function; can be used directly.
addPlugins
import { addPlugins } from 'webpack-babel-env-deps'
const addPlugins = require('webpack-babel-env-deps/addPlugins')
Named export for adding Babel plugins conditionally

Shows how to exclude node_modules from Babel transpilation except for packages that require it based on their engines field.

// webpack.config.js const { findDependenciesToTranspile } = require('webpack-babel-env-deps'); module.exports = { // ... module: { rules: [ { test: /\.js$/, exclude: filename => { // Exclude node_modules except those that need transpilation if (filename.indexOf('node_modules') === -1) return false; return !findDependenciesToTranspile({ packageContent: { engines: { node: '>=6' } }, // your project's engines dependencies: ['some-es6-pkg'], // list of dependency names }); }, use: 'babel-loader', }, ], }, };
Debug
Known issues
gotchaNode.js >=6 required, may not work with older Node.js versions
fix
Upgrade Node.js to >=6 or use older version of this package
affects: <1.0.0
deprecatedUse of engines field may cause false positives/negatives if dependencies don't specify engines
fix
Ensure all dependencies have accurate engines field; use module field as fallback
affects: *
gotchaDefault export may be mistaken for named export; import correctly
fix
Use default import or explicitly import named functions
affects: *
gotchaRequires @babel/preset-env as peer dependency at version ^7
fix
Install @babel/preset-env@^7 alongside this package
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module '@babel/preset-env'
Missing peer dependency @babel/preset-env
fix
npm install @babel/preset-env@^7
TypeError: findDependenciesToTranspile is not a function
Importing incorrectly as default instead of named
fix
Use const { findDependenciesToTranspile } = require('webpack-babel-env-deps');
Error: Options 'targets' is deprecated
Using deprecated options from older version of package or @babel/preset-env
fix
Check documentation for current API; use 'packageContent' and 'dependencies' arguments
Upgrade
Version history
1.6.4latest on npm
Audit
Dependencies
@babel/preset-envrequiredpeer dependency required for target comparison and integration
Agent activity
11 hits · last 30 days
node
10
Resources
webpack-babel-env-deps — npm install webpack-babel-env-deps · libregistry