davidhu2000 / react-spinners

A collection of loading spinner components for react
https://www.davidhu.io/react-spinners
MIT License
3.01k stars 262 forks source link

Current npm version (0.11.0) fails with react-scripts 4.0 #458

Closed QuinnFreedman closed 2 years ago

QuinnFreedman commented 2 years ago

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:

  1. Release a new version to NPM
  2. Modify the structure of the repo so that it installs correctly straight from github with yarn
crazytoucan commented 2 years ago

Is the relevant commit https://github.com/davidhu2000/react-spinners/pull/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.

QuinnFreedman commented 2 years ago

@crazytoucan it seems like #451 is the most likely commit or maybe ed0714b5ce48549d4b90c9c71bbe60a4bbbcbfed . 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.

davidhu2000 commented 2 years ago

0.12 should fix this. doing a little more testing then publishing it

QuinnFreedman commented 2 years ago

Looks like this is fixed for me (as of 0.12.0-alpha.3)