Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New v5 generate index.js feature does not account for filenames beginning with numerals #379

Closed
ReidBraswell opened this issue Jan 9, 2020 · 7 comments
Labels

Comments

@ReidBraswell
Copy link

🐛 Bug Report

The index.${ext} file that is now generated with v5 does not account for filenames beginning with numerals.

To Reproduce

Steps to reproduce the behavior:

  • create folder with a file named: 2circles.svg
  • run svgr cli command with --out-dir option
  • inspect created index.js file
  • output should be:
export { default as 2circles } from './2circles.svg'

Expected behavior

Since the componentName is generated from the .svg filename and prepends the Svg string to account for filenames with numerals, it would be expected for the generateIndex function to be consistent and instead return the following for the example above:

export { default as Svg2circles } from './2circles.svg';

envinfo

## System:
 - OS: Windows 10 10.0.16299
 - CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
 - Memory: 6.37 GB / 15.88 GB
## Binaries:
 - Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
 - npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
@gregberge
Copy link
Owner

Hey @renadr 👋,
Thank you for opening an issue. We'll get back to you as soon as we can.
Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers.
If you use Loadable at work, you can also ask your company to sponsor us ❤️.

@gregberge
Copy link
Owner

It is actually a bug yes, thanks for reporting.

@ReidBraswell
Copy link
Author

Thanks for acknowledging @gregberge! Is this something you need a PR for to fix, or do you have bandwidth to tackle?

Also, I did see closed issues in the repo that were tagged with a feature requests for a --prefix option. I could see this extended to enable that feature too.

Thanks for all of your help and effort put into this tool. It's extremely helpful!

@kelly-tock
Copy link

is there a way to handle folders inside the root source directory to generate in the index.ts as well?

@TrySound
Copy link
Contributor

@gregberge Adding Svg prefix will probably be a breaking change. We can add _ before numbers for now.

@gregberge
Copy link
Owner

@TrySound since SVG starting with a number does not actually work, it would not be a breaking change.

I am OK for adding Svg prefix to all Svg starting with a number. I will not fix it right now, feel free to submit a PR.

@TrySound
Copy link
Contributor

@gregberge #383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants