Registry / devops / babel-plugin-webpack-alias-7

babel-plugin-webpack-alias-7

JSON →
library0.1.1jsnpmunverified

Babel 7 plugin that resolves webpack resolve aliases during Babel transpilation. Version 0.1.1, last updated in 2019, with no recent releases. It replaces require paths defined in webpack alias configuration, useful for unit testing environments where webpack is not used. Compared to the original Babel 6 version, it uses a simpler config option without lodash templates. The package is in early development and seeking feedback.

npm install babel-plugin-webpack-alias-7
INSTALL
IMPORT
SIG · BABEL-PLUGIN-WEBPA
B
babel-plugin-webpack-alias-7
devopsjavascriptv0.1.1
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.

default
// No import needed; add to .babelrc plugins array as 'babel-plugin-webpack-alias-7'
import babelPluginWebpackAlias7 from 'babel-plugin-webpack-alias-7'
This is a Babel plugin, not a JavaScript module. It is configured via .babelrc or babel.config.js, not imported directly.
N/A (plugin usage)
plugins: [ ['babel-plugin-webpack-alias-7', { config: './webpack.config.js' }] ]
plugins: [ 'babel-plugin-webpack-alias' ]
Do not use the Babel 6 version of the plugin name. Use 'babel-plugin-webpack-alias-7' with options object.
N/A (CommonJS)
require('babel-plugin-webpack-alias-7')
require('babel-plugin-webpack-alias')
CommonJS require works in Node.js for Babel config files. Ensure correct package name.

Shows how to configure the plugin and use webpack aliases in Babel.

// .babelrc { "plugins": [ ["babel-plugin-webpack-alias-7", { "config": "./webpack.config.js" }] ] } // webpack.config.js var path = require('path'); module.exports = { resolve: { alias: { '@libs': path.join(__dirname, '/myLibs/') } } }; // source.js const myLib = require('@libs/myLib'); // transpiles to: const myLib = require('/myLibs/myLib');
Debug
Known issues
gotchaPlugin is in early development and may have limited functionality compared to the Babel 6 version.
fix
Review the readme for changes; consider using the original Babel 6 plugin if more features are needed.
affects: >=0.1.0
gotchaThe plugin requires a webpack config file; if not specified, it looks for webpack.config.js or webpack.config.babel.js in the root.
fix
Ensure a webpack config file exists or provide the config option explicitly.
affects: >=0.1.0
deprecatedThe 'findConfig' and 'noOutputExtension' options have been removed without replacement.
fix
Do not rely on these options; they are not available in this version.
affects: >=0.1.0
breakingThe config option no longer uses lodash templates, which may break configurations relying on that behavior.
fix
Remove lodash templates from the config path; use a static string path.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Could not find plugin 'babel-plugin-webpack-alias-7'
Plugin not installed or package name misspelled
fix
Run 'npm install --save-dev babel-plugin-webpack-alias-7' and ensure the package name is correct in .babelrc
Error: Cannot find module 'webpack'
webpack is not installed, but the plugin requires it to parse the webpack config
fix
Run 'npm install --save-dev webpack' or ensure webpack is a dependency
Error: The 'findConfig' option is not supported
Using option from Babel 6 version that was removed in this plugin
fix
Remove 'findConfig' option; see documentation for current options
ReferenceError: __dirname is not defined
Using ES modules and __dirname is not available in ESM context
fix
Use import.meta.url and fileURLToPath to get equivalent of __dirname
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
@babel/corerequiredpeer dependency required for Babel plugin functionality
Agent activity
6 hits · last 30 days
node
6
Resources
babel-plugin-webpack-alias-7 — npm install babel-plugin-webpack-alias-7 · libregistry