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

@svgr/cli generated exports incomplete / truncated #433

Closed
m7kvqbe1 opened this issue Apr 20, 2020 · 3 comments · Fixed by #443 · May be fixed by NOUIY/layer0-docs#478
Closed

@svgr/cli generated exports incomplete / truncated #433

m7kvqbe1 opened this issue Apr 20, 2020 · 3 comments · Fixed by #443 · May be fixed by NOUIY/layer0-docs#478
Labels

Comments

@m7kvqbe1
Copy link

m7kvqbe1 commented Apr 20, 2020

🐛 Bug Report

The generated index.tsx exports file from the below command appears to be either incomplete or truncated. I get a different set of exports written to file each time I run the command. It looks like there is some kind of race condition going on.

To Reproduce

Steps to reproduce the behavior:

  1. Create multiple directories of SVG icons.

  2. Run the following:

rm -rf src/icons; svgr --ext tsx -d src/icons src/assets/**/
  1. Note the generated exports in src/icons/index.tsx

Expected behavior

Exports for all of the generated React components are included within the index.tsx file.

Link to repl or repo (highly encouraged)

Repro can be found here on this branch:

https://github.com/Royal-Navy/standards-toolkit/tree/repro/svgr-generated-exports-truncated/packages/icon-library

Env info

## System:
 - OS: macOS 10.15.3
 - CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
 - Memory: 90.29 MB / 16.00 GB
 - Shell: 5.7.1 - /bin/zsh
## Binaries:
 - Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
 - Yarn: 1.19.1 - ~/.yarn/bin/yarn
 - npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
@open-collective-bot
Copy link

Hey @m7kvqbe1 👋,
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 SVGR at work, you can also ask your company to sponsor us ❤️.

@m7kvqbe1 m7kvqbe1 changed the title @svgr/cli generated exports truncated @svgr/cli generated exports incomplete / truncated Apr 20, 2020
@m7kvqbe1
Copy link
Author

It's worth noting that i'm currently working around this issue using a little bit of my own Bash:

#!/usr/bin/env bash

set -uo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
IFS=$'\n\t'

:> src/index.ts

for file in src/icons/*; do
  filename=$(basename -- "$file")
  filename_no_ext=${filename%%.*}
  echo "export {default as Icon${filename_no_ext}} from './icons/${filename_no_ext}'" >> src/index.ts
done

@gregberge
Copy link
Owner

Hello @m7kvqbe1, thanks for this bug. I think the issue only occurs with --ignore-existing option. Work in progress!

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