Closed gabrielbahniuk closed 2 years ago
I'm also getting this error. When compiling with webpack it's working fine, but as soon as I try and load a spinner I get this error
Failed to compile.
./src/node_modules/react-spinners/BarLoader.js
SyntaxError: /app/src/node_modules/react-spinners/BarLoader.js: 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;
It might be linked to https://github.com/emotion-js/emotion/issues/2041?
this isn't something i've tested. but i found this comment in another repo. https://github.com/system-ui/theme-ui/issues/1160#issuecomment-683830024
does that solve your issue?
I'm also getting this error. When compiling with webpack it's working fine, but as soon as I try and load a spinner I get this error
Failed to compile. ./src/node_modules/react-spinners/BarLoader.js SyntaxError: /app/src/node_modules/react-spinners/BarLoader.js: 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;
It might be linked to emotion-js/emotion#2041?
Hi @AwolDes, I think we have different problems.
Mine is regarding using the BarLoader as externals in webpack and adding it into an template.prod.html file. This gives me a different error output from yours.
Are you sure they are related somehow?
@gabrielbahniuk i published a new alpha version. try using externals with this url?
https://unpkg.com/browse/react-spinners@0.12.0-alpha.1/umd/index.js
seems like we get a different error now.
so based on what i've worked through, while this is techincally possible, I personally would not recommend doing this. The main issue being: the loaders in this require react to run, so i'd have to bundle react as well.
I pushed a code change to fix tree shaking
https://bundlephobia.com/package/react-spinners@0.12.0-alpha.1
so your final bundle will only include the loader you imported. (each loader around 8kb)
closing this issue for now. feel free to reopen if there are any follow ups
Hi,
I am trying to use react-spinners version 0.11.0 with React and for the Prod html template I load it:
Then in my webpack.prod.js I have:
I import it like this in my code:
import { BarLoader } from 'react-spinners'
However I get the following errors:
Is there a working version in a CDN? I could not find a /dist folder.
If not, would that be possible to create it?
Thank you.