Skip to content

Commit 0b19c00

Browse files
authored
Add docs for cra4 troubleshooting (#1919)
1 parent d30c765 commit 0b19c00

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

docs/src/pages/[platform]/getting-started/troubleshooting/troubleshooting.react.mdx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,60 @@ export default defineConfig({
8989
...
9090
```
9191
92+
## Create React App
93+
94+
Versions of [Create React App](https://create-react-app.dev/) prior to v5 may not include necessary plugins to transpile ES2020 features. This may result in an `Unexpected token` error:
95+
96+
```bash
97+
Module parse failed: Unexpected token
98+
File was processed with these loaders:
99+
* ./node_modules/babel-loader/lib/index.js
100+
You may need an additional loader to handle the result of these loaders.
101+
```
102+
103+
The best solution to this error is to upgrade the version of Create React App to v5 where ES2020 features are transpiled correctly:
104+
105+
```shell
106+
npm install --save react-scripts@5
107+
```
108+
109+
If you are unable to upgrade your `react-scripts` version, try making your browser target list less aggressive by doing the following:
110+
111+
**1.** Remove the `.cache` directory from your project's `node_modules`:
112+
113+
```shell
114+
rm -rf node_modules/.cache
115+
```
116+
117+
**2.** Change the `browserslist` block in your `package.json` from:
118+
119+
```json
120+
"browserslist": {
121+
"production": [
122+
">0.2%",
123+
"not dead",
124+
"not op_mini all"
125+
],
126+
"development": [
127+
"last 1 chrome version",
128+
"last 1 firefox version",
129+
"last 1 safari version"
130+
]
131+
}
132+
```
133+
134+
to the following:
135+
136+
```json
137+
"browserslist": [
138+
">0.2%",
139+
"not dead",
140+
"not op_mini all"
141+
]
142+
```
143+
144+
**3.** Try rebuilding and starting your project.
145+
92146
## Jest
93147
94148
As of v2.15.0 of `@aws-amplify/ui-react` which included the release of Geo components, users of the Jest testing framework may run into the following error when attempting to run tests:
@@ -100,6 +154,7 @@ window.URL.createObjectURL is not a function
100154
Please follow the steps below to resolve this issue.
101155

102156
**1.** Navigate to or create a [Jest setup file](https://jestjs.io/docs/configuration#setupfilesafterenv-array) for your project.
157+
103158
**2.** Add the following code to polyfill the unrecognized function in your Jest setup file:
104159

105160
```js

0 commit comments

Comments
 (0)