I am well aware that having Prettier as an imported dependency is an unusual use case and I am still confident that it is what I want. What I am working on requires formatting code that the end user has entered. I'm not saying this to be snarky, I just know it's the first question I'd have :)
Yes.
Yes, I have created a new CRA project, installed prettier as the only extra dependency and upgraded yarn before installing.
"compile", "failed to compile", "module parse failed", "loader"
node -v: v8.4.0npm -v: v5.6.0yarn --version (if you use Yarn): 1.3.2npm ls react-scripts (if you haven’t ejected): [email protected]
└── [email protected]
Operating system: macos Sierra 10.12.6
You can reproduce the issue by doing the following:
npx creat-react-app CRA-prettier-test.git && cd CRA-prettier-testyarnyarn add prettierimport prettier from "prettier"; to the top of ./src/index.jsyarn startThe problem is that this project will not compile.
That prettier doesn't break compilation! If you comment out the prettier import at ./src/index.js:6 in my example project this is the behaviour you should see.
The project should immediately show the following error:

I've created a very simple example project demonstrating the problem at https://github.com/tonyonodi/CRA-prettier-test you can use it to replicate the problem with
git clone https://github.com/tonyonodi/CRA-prettier-test.git && cd CRA-prettier-testyarnyarn start@tonyonodi you should also subscribe to this issue since apparently latest prettier can't run in-browser right now anyway.
Thanks for investigating, @heyimalex!
Thanks @heyimalex! I happen to be using CRA in Electron so hopefully I'll be able to fix this by refactoring the project so that Prettier isn't bundled by webpack.
This is an issue with using Prettier on the web, not CRA: https://github.com/prettier/prettier/issues/3296
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.
looks like it was fixed upstream
Most helpful comment
Here's the relevant issue.
@tonyonodi you should also subscribe to this issue since apparently latest prettier can't run in-browser right now anyway.