{"record":{"id":"920a667dfc09a287","repo":"evanw/esbuild","slug":"invalid-package-name-in-alias-old","errorCode":null,"errorMessage":"Invalid package name in alias: ${old}","messagePattern":"Invalid package name in alias: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/shared/common.ts","lineNumber":316,"sourceCode":"  if (splitting) flags.push('--splitting')\n  if (preserveSymlinks) flags.push('--preserve-symlinks')\n  if (metafile) flags.push(`--metafile`)\n  if (outfile) flags.push(`--outfile=${outfile}`)\n  if (outdir) flags.push(`--outdir=${outdir}`)\n  if (outbase) flags.push(`--outbase=${outbase}`)\n  if (tsconfig) flags.push(`--tsconfig=${tsconfig}`)\n  if (packages) flags.push(`--packages=${packages}`)\n  if (resolveExtensions) flags.push(`--resolve-extensions=${validateAndJoinStringArray(resolveExtensions, 'resolve extension')}`)\n  if (publicPath) flags.push(`--public-path=${publicPath}`)\n  if (entryNames) flags.push(`--entry-names=${entryNames}`)\n  if (chunkNames) flags.push(`--chunk-names=${chunkNames}`)\n  if (assetNames) flags.push(`--asset-names=${assetNames}`)\n  if (mainFields) flags.push(`--main-fields=${validateAndJoinStringArray(mainFields, 'main field')}`)\n  if (conditions) flags.push(`--conditions=${validateAndJoinStringArray(conditions, 'condition')}`)\n  if (external) for (let name of external) flags.push(`--external:${validateStringValue(name, 'external')}`)\n  if (alias) {\n    for (let old in alias) {\n      if (old.indexOf('=') >= 0) throw new Error(`Invalid package name in alias: ${old}`)\n      flags.push(`--alias:${old}=${validateStringValue(alias[old], 'alias', old)}`)\n    }\n  }\n  if (banner) {\n    for (let type in banner) {\n      if (type.indexOf('=') >= 0) throw new Error(`Invalid banner file type: ${type}`)\n      flags.push(`--banner:${type}=${validateStringValue(banner[type], 'banner', type)}`)\n    }\n  }\n  if (footer) {\n    for (let type in footer) {\n      if (type.indexOf('=') >= 0) throw new Error(`Invalid footer file type: ${type}`)\n      flags.push(`--footer:${type}=${validateStringValue(footer[type], 'footer', type)}`)\n    }\n  }\n  if (inject) for (let path of inject) flags.push(`--inject:${validateStringValue(path, 'inject')}`)\n  if (loader) {\n    for (let ext in loader) {","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/lib/shared/common.ts#L298-L334","documentation":"The `alias` option is serialized as `--alias:OLD=NEW`. An '=' inside the OLD package name breaks parsing, so esbuild rejects such alias keys at lib/shared/common.ts:316.","triggerScenarios":"Passing `alias: { 'pkg=subpath': 'other' }` or any alias key (old package name) containing '='.","commonSituations":"Trying to alias a subpath import using '=' in the key instead of esbuild's subpath rules; templated alias names that embed '='.","solutions":["Remove '=' from the alias key (use the bare package/package-path name).","For subpath aliasing, use a plugin or alias the base package and re-export."],"exampleFix":"// before\nawait build({ entryPoints: ['app.ts'], alias: { 'lib=util': 'shim' } })\n\n// after\nawait build({ entryPoints: ['app.ts'], alias: { 'lib': 'shim' } })","handlingStrategy":"validation","validationCode":"function assertAliasKeys(map) {\n  for (const k of Object.keys(map ?? {})) {\n    if (k.includes('=')) throw new Error(`alias key must not contain '=': ${k}`)\n  }\n}\nassertAliasKeys(options.alias)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep alias keys as plain package names or package/subpath.","Use a plugin for complex subpath rewriting rather than '='-laden keys.","Validate generated alias keys before building."],"tags":["config","validation","alias"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}