Skip to content

Commit 600ffb4

Browse files
committed
fix(example): patch create-react-app 4.0
due to 9921 is not released yet (facebook/create-react-app#9921)
1 parent 0c68123 commit 600ffb4

File tree

5 files changed

+110
-52
lines changed

5 files changed

+110
-52
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ npm install --save-dev react-app-rewired react-app-rewire-alias
5454

5555
#### Usage
5656

57+
Current `create-react-app` and `react-scripts` **v4.0** has a bug which is fixed here:
58+
[create-react-app #9921](https://github.com/facebook/create-react-app/pull/9921) - but
59+
it does released yet. Use previous version of create-react-app/react-scripts or
60+
wait for new release or check commit referenced in #9 to learn how make it worked
61+
using patch-package.
62+
5763
Place for alias foldes is recommended near to **src**.
5864
Alias folders outside of the root of project is not recommended.
5965

@@ -62,8 +68,6 @@ Alias folders outside of the root of project is not recommended.
6268
* add **extends** section to `jsconfig.json` or `tsconfig.json`
6369
* configure alias in `jsconfig.paths.json` or `tsconfig.paths.json`
6470

65-
#### Modify config-overrides.js to add `react-app-rewire-alias`
66-
6771
```js
6872
const {alias, configPaths} = require('react-app-rewire-alias')
6973

example/main/README.md

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
1-
# Getting Started with Create React App
1+
# Demo
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
## react-scripts patched
44

5-
## Available Scripts
5+
Patched due to [create-react-app #9921](https://github.com/facebook/create-react-app/pull/9921) not yet released
6+
Wait for any crete-react-app version above 4.0
7+
after upgrade - remove **appropriate** patches
8+
If no any more patches:
9+
* remove deps: patch-package postinstall-postinstall
10+
* remove "postinstall": "patch-package" from "scripts" (package.json)
611

7-
In the project directory, you can run:
8-
9-
### `yarn start`
10-
11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13-
14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
16-
17-
### `yarn test`
18-
19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21-
22-
### `yarn build`
23-
24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26-
27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31-
32-
### `yarn eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35-
36-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39-
40-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41-
42-
## Learn More
43-
44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45-
46-
To learn React, check out the [React documentation](https://reactjs.org/).

example/main/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111
"@types/react": "^16.9.53",
1212
"@types/react-dom": "^16.9.8",
1313
"eslint-loader": "^4.0.2",
14+
"patch-package": "^6.2.2",
15+
"postinstall-postinstall": "^2.1.0",
1416
"react": "^17.0.1",
1517
"react-app-rewire-alias": "file:../../",
1618
"react-app-rewired": "^2.1.6",
1719
"react-dom": "^17.0.1",
1820
"react-scripts": "4.0.0",
19-
"typescript": "^4.0.3",
21+
"typescript": "4.0.3",
2022
"web-vitals": "^0.2.4"
2123
},
2224
"scripts": {
25+
"postinstall": "patch-package",
2326
"start": "react-app-rewired start",
2427
"build": "react-app-rewired build",
2528
"test": "react-app-rewired test"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
2+
index 00139ee..dd0932e 100644
3+
--- a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
4+
+++ b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
5+
@@ -148,7 +148,7 @@ function verifyTypeScriptSetup() {
6+
jsx: {
7+
parsedValue:
8+
hasJsxRuntime && semver.gte(ts.version, '4.1.0-beta')
9+
- ? ts.JsxEmit.ReactJsx
10+
+ ? ts.JsxEmit.ReactJSX // wait for create-react-app above 4.0 released (then remove patch)
11+
: ts.JsxEmit.React,
12+
value:
13+
hasJsxRuntime && semver.gte(ts.version, '4.1.0-beta')
14+
@@ -218,6 +218,15 @@ function verifyTypeScriptSetup() {
15+
if (appTsConfig.compilerOptions == null) {
16+
appTsConfig.compilerOptions = {};
17+
firstTimeSetup = true;
18+
+ } else {
19+
+ // wait for create-react-app above 4.0 released (then remove patch)
20+
+ // This is bug fix code of https://github.com/facebook/create-react-app/issues/9868
21+
+ // Bellow code release variable from non-extensible and freeze status.
22+
+ appTsConfig.compilerOptions = JSON.parse(JSON.stringify(appTsConfig.compilerOptions));
23+
+
24+
+ // Original appTsConfig.compilerOptions status
25+
+ // Object.isExtensible(appTsConfig.compilerOptions) output: false
26+
+ // Object.isFrozen(appTsConfig.compilerOptions) output: true
27+
}
28+
29+
for (const option of Object.keys(compilerOptions)) {

example/main/yarn.lock

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,11 @@
20192019
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
20202020
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
20212021

2022+
"@yarnpkg/lockfile@^1.1.0":
2023+
version "1.1.0"
2024+
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
2025+
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==
2026+
20222027
abab@^2.0.3:
20232028
version "2.0.5"
20242029
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a"
@@ -3472,7 +3477,7 @@ cross-spawn@7.0.3, cross-spawn@^7.0.0, cross-spawn@^7.0.2:
34723477
shebang-command "^2.0.0"
34733478
which "^2.0.1"
34743479

3475-
cross-spawn@^6.0.0:
3480+
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
34763481
version "6.0.5"
34773482
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
34783483
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
@@ -4943,6 +4948,14 @@ find-up@^3.0.0:
49434948
dependencies:
49444949
locate-path "^3.0.0"
49454950

4951+
find-yarn-workspace-root@^1.2.1:
4952+
version "1.2.1"
4953+
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-1.2.1.tgz#40eb8e6e7c2502ddfaa2577c176f221422f860db"
4954+
integrity sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q==
4955+
dependencies:
4956+
fs-extra "^4.0.3"
4957+
micromatch "^3.1.4"
4958+
49464959
flat-cache@^2.0.1:
49474960
version "2.0.1"
49484961
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0"
@@ -5044,7 +5057,16 @@ from2@^2.1.0:
50445057
inherits "^2.0.1"
50455058
readable-stream "^2.0.0"
50465059

5047-
fs-extra@^7.0.0:
5060+
fs-extra@^4.0.3:
5061+
version "4.0.3"
5062+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94"
5063+
integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==
5064+
dependencies:
5065+
graceful-fs "^4.1.2"
5066+
jsonfile "^4.0.0"
5067+
universalify "^0.1.0"
5068+
5069+
fs-extra@^7.0.0, fs-extra@^7.0.1:
50485070
version "7.0.1"
50495071
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
50505072
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
@@ -6761,6 +6783,13 @@ kind-of@^6.0.0, kind-of@^6.0.2:
67616783
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
67626784
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
67636785

6786+
klaw-sync@^6.0.0:
6787+
version "6.0.0"
6788+
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
6789+
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
6790+
dependencies:
6791+
graceful-fs "^4.1.11"
6792+
67646793
kleur@^3.0.3:
67656794
version "3.0.3"
67666795
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
@@ -7885,6 +7914,24 @@ pascalcase@^0.1.1:
78857914
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
78867915
integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=
78877916

7917+
patch-package@^6.2.2:
7918+
version "6.2.2"
7919+
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.2.2.tgz#71d170d650c65c26556f0d0fbbb48d92b6cc5f39"
7920+
integrity sha512-YqScVYkVcClUY0v8fF0kWOjDYopzIM8e3bj/RU1DPeEF14+dCGm6UeOYm4jvCyxqIEQ5/eJzmbWfDWnUleFNMg==
7921+
dependencies:
7922+
"@yarnpkg/lockfile" "^1.1.0"
7923+
chalk "^2.4.2"
7924+
cross-spawn "^6.0.5"
7925+
find-yarn-workspace-root "^1.2.1"
7926+
fs-extra "^7.0.1"
7927+
is-ci "^2.0.0"
7928+
klaw-sync "^6.0.0"
7929+
minimist "^1.2.0"
7930+
rimraf "^2.6.3"
7931+
semver "^5.6.0"
7932+
slash "^2.0.0"
7933+
tmp "^0.0.33"
7934+
78887935
path-browserify@0.0.1:
78897936
version "0.0.1"
78907937
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"
@@ -8718,6 +8765,11 @@ postcss@^8.1.0:
87188765
nanoid "^3.1.15"
87198766
source-map "^0.6.1"
87208767

8768+
postinstall-postinstall@^2.1.0:
8769+
version "2.1.0"
8770+
resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
8771+
integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==
8772+
87218773
prelude-ls@^1.2.1:
87228774
version "1.2.1"
87238775
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@@ -9864,6 +9916,11 @@ sisteransi@^1.0.4:
98649916
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
98659917
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==
98669918

9919+
slash@^2.0.0:
9920+
version "2.0.0"
9921+
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
9922+
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==
9923+
98679924
slash@^3.0.0:
98689925
version "3.0.0"
98699926
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
@@ -10720,10 +10777,10 @@ typedarray@^0.0.6:
1072010777
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1072110778
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1072210779

10723-
typescript@^4.0.3:
10724-
version "4.1.2"
10725-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9"
10726-
integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==
10780+
typescript@4.0.3:
10781+
version "4.0.3"
10782+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"
10783+
integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==
1072710784

1072810785
unicode-canonical-property-names-ecmascript@^1.0.4:
1072910786
version "1.0.4"

0 commit comments

Comments
 (0)