Skip to content

Generating index file breaks on special characters #1009

Description

@nwesthoff

🐛 Bug Report

#332 fixed an issue generating component names with special characters. Though this fix does not seem to be used to generate export names in index files, which throws the following error:

> svgr-special-character-bug@1.0.0 build:icons ~/Git/svgr-special-character-bug
> svgr --out-dir icons -- svg

svg/Direction=Down.svg -> icons/Direction=down.js
~/Git/svgr-special-character-bug/node_modules/.pnpm/@svgr+cli@8.1.0/node_modules/@svgr/cli/dist/index.js:435
    throw error;
    ^

SyntaxError: Unexpected token, expected "," (1:30)
> 1 | export { default as Direction=down } from './Direction=down'

To Reproduce

  1. Add an icon with special characters in the file name (I've tested = and )
  2. Run svgr cli svgr --out-dir icons -- svg (in repro pnpm build:icons), no special config
  3. Generating the icon components works
  4. Generating the index file fails

Expected behavior

I expect index files to use the same getComponentName function to generate the export name to avoid issues with special characters.

Link to repl or repo (highly encouraged)

GitHub Repro

System Info

## System:
 - OS: macOS 15.6
 - CPU: (12) arm64 Apple M2 Pro
 - Memory: 155.48 MB / 16.00 GB
 - Shell: 5.9 - /bin/zsh
## Binaries:
 - Node: 24.2.0 - /opt/homebrew/bin/node
 - Yarn: 1.22.22 - /opt/homebrew/bin/yarn
 - npm: 11.3.0 - /opt/homebrew/bin/npm
 - pnpm: 10.10.0 - ~/Library/pnpm/pnpm
 - bun: 1.1.43 - ~/.bun/bin/bun
## npmPackages:
 - @svgr/cli: ^8.1.0 => 8.1.0 
 - @svgr/core: ^8.1.0 => 8.1.0 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions