{"id":19246,"library":"babel-plugin-webpack-aliases","title":"babel-plugin-webpack-aliases","description":"Babel 6 plugin that resolves webpack resolve.alias during Babel transpilation, useful for testing environments where webpack is not available. Version 1.1.3 (stable, last release 2016). It replaces require/import paths with relative paths based on webpack config aliases. Maintained as a fork of babel-plugin-webpack-alias. No updates since 2016; consider alternatives like module-resolver for newer Babel versions.","status":"deprecated","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/sebinsua/babel-plugin-webpack-aliases","tags":["javascript","babel","webpack","alias","mocha","testing"],"install":[{"cmd":"npm install babel-plugin-webpack-aliases","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-webpack-aliases","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-webpack-aliases","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Optional dependency to locate webpack config file using find-up if findConfig option is set.","package":"find-up","optional":true}],"imports":[{"note":"This is a Babel plugin, not a JavaScript module. It is used via .babelrc or babel.config.js, not imported directly.","wrong":"import babelPluginWebpackAliases from 'babel-plugin-webpack-aliases'","symbol":"plugin","correct":"Add to .babelrc plugins array: ['babel-plugin-webpack-aliases', { config: './webpack.config.js' }]"},{"note":"The plugin is configured in Babel config, not required in application code.","wrong":"require('babel-plugin-webpack-aliases') in code","symbol":"plugin","correct":"In babel.config.js: plugins: [['babel-plugin-webpack-aliases', { config: './webpack.config.js' }]]"},{"note":"When using string shorthand, arguments are passed as an array: [pluginName, options].","wrong":"Incorrect inline plugin syntax without array","symbol":"plugin","correct":"In package.json babel section: \"plugins\": [[\"babel-plugin-webpack-aliases\", { \"config\": \"webpack.config.js\" }]]"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\n    [\"babel-plugin-webpack-aliases\", {\n      \"config\": \"./webpack.config.js\"\n    }]\n  ]\n}\n\n// webpack.config.js\nmodule.exports = {\n  resolve: {\n    alias: {\n      '@components': './src/components',\n      '@utils': './src/utils'\n    }\n  }\n};\n\n// After Babel transpilation:\n// import MyComponent from '@components/MyComponent';\n// becomes:\n// import MyComponent from './src/components/MyComponent';","lang":"javascript","description":"Configure plugin in .babelrc with webpack config path; aliases are resolved to relative paths."},"warnings":[{"fix":"Migrate to babel-plugin-module-resolver for Babel 7+ compat.","message":"Plugin is no longer maintained and only supports Babel 6. Not compatible with Babel 7+.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure webpack config is a plain object. Use require() to load config and verify resolve.alias exists.","message":"Plugin expects webpack config to export an object. If using webpack-merge or other patterns, alias resolution may fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use absolute paths in webpack aliases with path.resolve(__dirname, ...) to avoid confusion.","message":"Alias resolution is relative to the webpack config file location, not the project root.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Flatten complex alias configurations into simple string mappings.","message":"Does not support webpack resolve.alias fields with arrays or nested objects; only simple key-value string mappings.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Explicitly set config path to avoid ambiguity.","message":"If findConfig option is true, plugin uses find-up but does not handle multiple matching configs well.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Check the config option points to the correct webpack config file and that aliases are configured with absolute paths.","cause":"Alias path not correctly resolved because webpack config path is wrong or alias mapping is incorrect.","error":"Module not found: Can't resolve '...' in '...'"},{"fix":"Ensure webpack config exports an object with resolve.alias defined.","cause":"Webpack config does not have a resolve.alias property or config export is invalid.","error":"TypeError: Cannot read property 'alias' of undefined"},{"fix":"Do not import the plugin directly; use it only within Babel configuration.","cause":"Usage of babel-plugin-webpack-aliases outside of Babel config, e.g., as a module import.","error":"Error: Options must be a string, an array, or an object"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}