Open johanbook opened 1 year ago
Wow, we are dealing with the exact same issue... Thanks for reporting...
Hello, version is fixed, you should not have this problem. I tried to upgrade prettier to v3 in svgr but it breaks because of ESM. The whole toolchain have to move to ESM, it is a big work.
I'm having a different failure as a result of the prettier 3 upgrade:
/project/node_modules/@svgr/cli/dist/index.js:435
throw error;
^
TypeError: prettier.resolveConfig.sync is not a function
at prettierPlugin (/project/node_modules/@svgr/cli/node_modules/@svgr/plugin-prettier/dist/index.js:10:74)
at run (/project/node_modules/@svgr/core/dist/index.js:174:16)
at transform.sync (/project/node_modules/@svgr/core/dist/index.js:184:10)
at convert (/project/node_modules/@svgr/cli/dist/index.js:70:25)
at convertFile (/project/node_modules/@svgr/cli/dist/index.js:79:10)
at async write (/project/node_modules/@svgr/cli/dist/index.js:199:18)
at async /project/node_modules/@svgr/cli/dist/index.js:235:28
at async Promise.all (index 3)
at async handle (/project/node_modules/@svgr/cli/dist/index.js:232:23)
at async /project/node_modules/@svgr/cli/dist/index.js:268:7
at async Promise.all (index 0)
at async dirCommand (/project/node_modules/@svgr/cli/dist/index.js:264:3)
at async run (/project/node_modules/@svgr/cli/dist/index.js:431:3)
I figured I would add it to this issue instead of creating a new one.
Any chance of addressing the prettier 3 breakage mentioned above? Or is there any known workaround (@EvHaus)?
I've tried disabling prettier in
My issue was that I was forcing all SVGR
config, but that does not help.prettier
versions in my dependency graph to the latest, but I believe that it holds that this is an issue that should be addressed anyway
What workarounds are you guys using atm?
What workarounds are you guys using atm?
I turn the SVGR prettier option off (for example with โprettierโ: false
in .svgrrc.json
) and run prettier after the svgr command.
For example, with a script in package.json
like:
"generate:svgr": "svgr --no-index --out-dir src src && prettier --write ./src"
fwiw, you can pass the --no-prettier
option to the CLI to disable prettier.
๐ Bug Report
When running svgr with Prettier 3.0.0 I get this error message
To Reproduce
Install the following with pnpm
And run svgr.
Expected behavior
The React components should be generated without the CLI fialing.
Link to repl or repo (highly encouraged)
https://github.com/johanbook/bug-reproduction-svgr-prettier-v3.0.0
Run
npx envinfo --system --binaries --npmPackages @svgr/core,@svgr/cli,@svgr/webpack,@svgr/rollup --markdown --clipboard