Skip to content

Commit 72b3a7e

Browse files
committed
add react-app-rewired to fix CRA
1 parent 6b5b3dd commit 72b3a7e

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ This is a simple monorepo template with some specific design goals:
88
* Watch mode works
99
* ESM and CJS work (with distinct build outputs)
1010
* Vanilla TS and React packages work
11-
* Create React App works (with hot module reloading of the entire workspace)
11+
* Create React App works* (with hot module reloading of the entire workspace)
12+
13+
\* Create React App, which uses Webpack 5, can't resolve ES modules without .mjs file extensions by default, so [react-app-rewired](https://github.com/timarney/react-app-rewired) is minimally used to [configure Webpack](packages/app/create-react-app/config-overrides.js) to do this.
1214

1315
## Prerequisites
1416

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = function (config) {
2+
config.module.rules.push({
3+
test: /\.m?js$/,
4+
resolve: {
5+
fullySpecified: false,
6+
},
7+
});
8+
9+
return config;
10+
};

packages/app/create-react-app/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@testing-library/jest-dom": "^5.16.4",
6+
"@testing-library/jest-dom": "^5.16.5",
77
"@testing-library/react": "^13.3.0",
88
"@testing-library/user-event": "^13.5.0",
99
"@types/jest": "^27.5.2",
1010
"@types/node": "^16.11.47",
1111
"@types/react": "^18.0.15",
1212
"@types/react-dom": "^18.0.6",
13-
"@types/testing-library__jest-dom": "^5.0.0",
13+
"@types/testing-library__jest-dom": "^5.14.5",
1414
"react": "^18.2.0",
15+
"react-app-rewired": "^2.2.1",
1516
"react-dom": "^18.2.0",
1617
"react-scripts": "5.0.1",
1718
"shx": "^0.3.4",
@@ -21,10 +22,10 @@
2122
},
2223
"scripts": {
2324
"clean": "shx mkdir -p build && shx rm -rf build",
24-
"start": "react-scripts start",
25-
"build": "react-scripts build",
2625
"prebuild": "pnpm run clean",
27-
"test": "react-scripts test",
26+
"start": "react-app-rewired start",
27+
"build": "react-app-rewired build",
28+
"test": "react-app-rewired test",
2829
"eject": "react-scripts eject"
2930
},
3031
"eslintConfig": {

0 commit comments

Comments
 (0)