{"id":19020,"library":"babel-plugin-alias-config","title":"babel-plugin-alias-config","description":"A Babel 7 plugin (v0.1.0, latest) that resolves import/require aliases using webpack resolve alias configs from various file formats (alias.config.js, webpack.config.js, jsconfig.json, tsconfig.json). Supports auto-discovery, dynamic imports, and path extension options. Current version is early-stage with limited adoption. Differentiates from similar plugins (e.g., babel-plugin-module-resolver) by reusing existing webpack alias configurations.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/gxlmyacc/babel-plugin-alias-config","tags":["javascript","babel","webpack","alias"],"install":[{"cmd":"npm install babel-plugin-alias-config","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-alias-config","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-alias-config","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for Babel 7 plugin API","package":"@babel/core","optional":false}],"imports":[{"note":"Plugin name must include 'babel-plugin-' prefix in Babel config array","wrong":"plugins: ['alias-config']","symbol":"babel-plugin-alias-config","correct":"plugins: ['babel-plugin-alias-config']"},{"note":"Options must be in nested array format per Babel convention","wrong":"plugins: ['babel-plugin-alias-config', { config: './webpack.config.js' }]","symbol":"Babel plugin options object","correct":"plugins: [['babel-plugin-alias-config', { config: './webpack.config.js' }]]"},{"note":"Plugin exports a single function (default export); no named exports available","wrong":"import { aliasConfig } from 'babel-plugin-alias-config';","symbol":"default export (no named exports)","correct":"const plugin = require('babel-plugin-alias-config');"}],"quickstart":{"code":"// 1. Install\n// npm install --save-dev babel-plugin-alias-config\n\n// 2. Create alias config: alias.config.js\nconst path = require('path');\nmodule.exports = {\n  alias: {\n    '@': path.resolve(__dirname, 'src'),\n    '@components': path.resolve(__dirname, 'src/components'),\n  },\n  extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],\n};\n\n// 3. Configure Babel: .babelrc\n{\n  \"plugins\": [\n    [\"babel-plugin-alias-config\", {\n      \"config\": \"./alias.config.js\"\n    }]\n  ]\n}\n\n// 4. Use alias in code\nimport Button from '@components/Button'; // resolves to src/components/Button\nconsole.log(Button);\n","lang":"javascript","description":"Shows installation, alias config, Babel setup, and usage of the plugin to resolve '@' and '@components' aliases."},"warnings":[{"fix":"Upgrade to Babel 7 or use babel-plugin-module-resolver for Babel 6 compatibility.","message":"Plugin only supports Babel 7; will fail with Babel 6.","severity":"breaking","affected_versions":"0.x.x"},{"fix":"Set findConfig: false and specify exact config path to avoid accidental overwrites.","message":"findConfig: true searches upward from the compiled file, which may pick unintended config files in monorepos or shared directories.","severity":"gotcha","affected_versions":"0.x.x"},{"fix":"Set noOutputExtension: true for extensionless imports if target environment resolves extensions.","message":"noOutputExtension: false (default) adds file extension to resolved imports, which may break dynamic imports that omit extensions.","severity":"gotcha","affected_versions":"0.x.x"},{"fix":"Monitor GitHub for future updates.","message":"No known deprecation warnings yet; package is early stage.","severity":"deprecated","affected_versions":"0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev @babel/core","cause":"@babel/core not installed as dependency or peer dependency","error":"Error: Cannot find module '@babel/core'"},{"fix":"Ensure options are inside a nested array: 'plugins': [['babel-plugin-alias-config', { ... }]]","cause":"Babel config file syntax error due to incorrect plugin array nesting","error":"SyntaxError: Unexpected token, expected ',' (12:5) in .babelrc"},{"fix":"Check alias.config.js or specify config path: 'config': './alias.config.js'","cause":"Alias not defined in config or config not found by plugin","error":"Can't resolve '@utils/helper' in file.js"},{"fix":"Create a valid alias config file or set 'config' option to correct path","cause":"Default config file path is './webpack.config.js'; if it doesn't exist, plugin throws","error":"ENOENT: no such file or directory, open '.../webpack.config.js'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}