Current npm version (0.11.0) fails with react-scripts 4.0
QuinnFreedman opened this issue · 4 comments
0.11.0 worked fine with create-react-app
3.x.x
, but after bumping to 4.0
, it no longer compiles. I get the following error:
pragma and pragmaFrag cannot be set when runtime is automatic
Luckily, it seems like as of #5e23db4 master does work. But, I can't install directly from GitHub. Doing something like:
yarn add github:davidhu2000/react-spinners#5e23db437cc31170a646103a3fe81b9ae5e2a08
just clones the whole repo into my node_modules
so the compiler can't find index.js
when I try to import.
Is it possible to either:
- Release a new version to NPM
- Modify the structure of the repo so that it installs correctly straight from github with
yarn
Is the relevant commit #451? It would be great to get a release for this! 💛
Also, if this helps anybody else's debugging journey, I get an error that suggests Webpack is mad about the first line of a component's .js
file, but it's actually mad about the first line of the .d.ts
file.
Said differently, this error message is completely off:
...node_modules/react-spinners/BarLoader.js
SyntaxError: pragma and pragmaFrag cannot be set when runtime is automatic.
> 1 | "use strict";
| ^
2 | var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3 | if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4 | return cooked;
> Build error occurred
Error: > Build failed because of webpack errors
It's actually mad about the first line /** @jsx jsx */
in the .d.ts files. This may be helpful for folks trying to roll their own temporary patches via yarn.
@crazytoucan it seems like #451 is the most likely commit or maybe ed0714b . Either way, I know HEAD works.
Workaround: Until this fix is pushed to NPM, you can add "react-spinners": "github:davidhu2000/react-spinners#5e23db437cc31170a646103a3fe81b9ae5e2a080"
to your package.json
(which just clones the repo into your node_modules
but doesn't set it up) and then add "postinstall": "cd node_modules/react-spinners && yarn prepare"
to your scripts
. This will setup the package every time you yarn install
. Something similar probably works for npm
.
0.12 should fix this. doing a little more testing then publishing it
Looks like this is fixed for me (as of 0.12.0-alpha.3
)