-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional chaining in axios-retry causes Webpack errors in Create React App #292
Comments
Optional chaining ( You should upgrade your Node.js version to 14 or higher — this will resolve the issue. However:
In summary:
|
This issue does not appear to be related to the Node.js version. I have already updated to Node.js 20, and the error persists. Instead, the root cause lies with the Babel and Webpack versions bundled with Create React App (CRA), which are not fully compatible with the optional chaining (?.) syntax used in the axios-retry package. While more recent Babel and Webpack configurations can handle this syntax, CRA abstracts these tools, preventing users from updating or configuring them directly without ejecting or patching react-scripts. Given that the use of optional chaining here is non-critical, it might be worth considering a more compatible approach to avoid breaking projects built with older CRA versions. This would improve the library's usability across a broader range of setups. This is the exact error
|
Description
I encountered an issue when using the latest version of
axios-retry
in a project created with Create React App (CRA). The library's use of optional chaining (?.
) in the distributed package causes Webpack to fail with a syntax error because CRA does not transpile code fromnode_modules
by default.This makes it difficult to use the library in projects with standard CRA configurations without additional customization.
Steps to Reproduce
npx create-react-app my-app cd my-app npm install axios-retry
App.js
:Observed Behavior
The development server fails to start and shows the following error:
Expected Behavior
The library should work seamlessly in a default CRA setup without requiring additional Webpack customization.
Possible Solution
To improve compatibility, consider:
dist/
directory or similar.engines
field inpackage.json
.Environment
axios-retry
version:4.5.0
5.0.1
10.9.0
18.3.1
The text was updated successfully, but these errors were encountered: