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
muslnode 18–226 runs
build_error
glibcnode 18–226 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',
},
],
},
};
Errors
Common errors & fixes
Cannot find module '@babel/preset-env'
Missing peer dependency @babel/preset-env
fixnpm install @babel/preset-env@^7
TypeError: findDependenciesToTranspile is not a function
Importing incorrectly as default instead of named
fixUse const { findDependenciesToTranspile } = require('webpack-babel-env-deps'); Error: Options 'targets' is deprecated
Using deprecated options from older version of package or @babel/preset-env
fixCheck documentation for current API; use 'packageContent' and 'dependencies' arguments
Audit
Dependencies
@babel/preset-envrequiredpeer dependency required for target comparison and integration