Skip to content

Commit 175d9c3

Browse files
lex111slorber
andauthored
feat(v2): support/use React v17 by default (#4218)
* chore(v2): allow React v17 as peer dependency * minor React 17 changes * Revert examples * Possible fix * Use @docusaurus/react-loadable fork * add back react-loadable to please eslint/ts/linters, even if it's unused in practice * missing dependency bump * move enzyme dependencies to docusaurus v1 Co-authored-by: slorber <lorber.sebastien@gmail.com>
1 parent 6a94ad9 commit 175d9c3

File tree

31 files changed

+118
-57
lines changed

31 files changed

+118
-57
lines changed

examples/classic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
]
3434
},
3535
"description": "Docusaurus example project"
36-
}
36+
}

examples/facebook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
]
5151
},
5252
"description": "Docusaurus example project (facebook template)"
53-
}
53+
}

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@
102102
"babel-eslint": "^10.0.3",
103103
"concurrently": "^5.3.0",
104104
"cross-env": "^7.0.3",
105-
"enzyme": "^3.10.0",
106-
"enzyme-adapter-react-16": "^1.15.1",
107105
"eslint": "^7.13.0",
108106
"eslint-config-airbnb": "^18.2.1",
109107
"eslint-config-prettier": "^6.15.0",
@@ -121,8 +119,8 @@
121119
"netlify-cli": "^2.58.0",
122120
"nodemon": "^2.0.7",
123121
"prettier": "^2.0.2",
124-
"react": "^16.8.4",
125-
"react-dom": "^16.8.4",
122+
"react": "^17.0.1",
123+
"react-dom": "^17.0.1",
126124
"rimraf": "^3.0.2",
127125
"serve": "^11.3.2",
128126
"stylelint": "^13.2.1",

packages/docusaurus-1.x/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
"commander": "^4.0.1",
4646
"crowdin-cli": "^0.3.0",
4747
"cssnano": "^4.1.10",
48+
"enzyme": "^3.10.0",
49+
"enzyme-adapter-react-16": "^1.15.1",
4850
"escape-string-regexp": "^2.0.0",
4951
"express": "^4.17.1",
5052
"feed": "^4.2.1",

packages/docusaurus-init/templates/bootstrap/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"@docusaurus/preset-bootstrap": "2.0.0-alpha.70",
1818
"@mdx-js/react": "^1.5.8",
1919
"classnames": "^2.2.6",
20-
"react": "^16.8.4",
21-
"react-dom": "^16.8.4"
20+
"react": "^17.0.1",
21+
"react-dom": "^17.0.1"
2222
},
2323
"browserslist": {
2424
"production": [

packages/docusaurus-init/templates/classic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"@docusaurus/preset-classic": "2.0.0-alpha.70",
1818
"@mdx-js/react": "^1.6.21",
1919
"clsx": "^1.1.1",
20-
"react": "^16.8.4",
21-
"react-dom": "^16.8.4"
20+
"react": "^17.0.1",
21+
"react-dom": "^17.0.1"
2222
},
2323
"browserslist": {
2424
"production": [

packages/docusaurus-init/templates/facebook/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"@docusaurus/preset-classic": "2.0.0-alpha.70",
2222
"@mdx-js/react": "^1.6.21",
2323
"clsx": "^1.1.1",
24-
"react": "^16.8.4",
25-
"react-dom": "^16.8.4"
24+
"react": "^17.0.1",
25+
"react-dom": "^17.0.1"
2626
},
2727
"devDependencies": {
2828
"babel-eslint": "^10.0.3",

packages/docusaurus-mdx-loader/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
"unist-util-remove-position": "^2.0.1"
4545
},
4646
"peerDependencies": {
47-
"react": "^16.8.4",
48-
"react-dom": "^16.8.4"
47+
"react": "^16.8.4 || ^17.0.0",
48+
"react-dom": "^16.8.4 || ^17.0.0"
4949
},
5050
"engines": {
5151
"node": ">=10.15.1"

packages/docusaurus-migrate/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ export async function migrateDocusaurusProject(
106106
'@docusaurus/core': DOCUSAURUS_VERSION,
107107
'@docusaurus/preset-classic': DOCUSAURUS_VERSION,
108108
clsx: '^1.1.1',
109-
react: '^16.10.2',
110-
'react-dom': '^16.10.2',
109+
react: '^17.0.1',
110+
'react-dom': '^17.0.1',
111111
};
112112
try {
113113
createClientRedirects(siteConfig, deps, config);

packages/docusaurus-plugin-client-redirects/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"lodash": "^4.17.20"
3030
},
3131
"peerDependencies": {
32-
"react": "^16.8.4",
33-
"react-dom": "^16.8.4"
32+
"react": "^16.8.4 || ^17.0.0",
33+
"react-dom": "^16.8.4 || ^17.0.0"
3434
},
3535
"engines": {
3636
"node": ">=10.9.0"

packages/docusaurus-plugin-content-blog/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"webpack": "^4.44.1"
3636
},
3737
"peerDependencies": {
38-
"react": "^16.8.4",
39-
"react-dom": "^16.8.4"
38+
"react": "^16.8.4 || ^17.0.0",
39+
"react-dom": "^16.8.4 || ^17.0.0"
4040
},
4141
"engines": {
4242
"node": ">=10.15.1"

packages/docusaurus-plugin-content-docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"webpack": "^4.44.1"
4949
},
5050
"peerDependencies": {
51-
"react": "^16.8.4",
52-
"react-dom": "^16.8.4"
51+
"react": "^16.8.4 || ^17.0.0",
52+
"react-dom": "^16.8.4 || ^17.0.0"
5353
},
5454
"engines": {
5555
"node": ">=10.15.1"

packages/docusaurus-plugin-content-pages/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"webpack": "^4.44.1"
3434
},
3535
"peerDependencies": {
36-
"react": "^16.8.4",
37-
"react-dom": "^16.8.4"
36+
"react": "^16.8.4 || ^17.0.0",
37+
"react-dom": "^16.8.4 || ^17.0.0"
3838
},
3939
"engines": {
4040
"node": ">=10.15.1"

packages/docusaurus-plugin-debug/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"react-json-view": "^1.20.4"
2424
},
2525
"peerDependencies": {
26-
"react": "^16.8.4",
27-
"react-dom": "^16.8.4"
26+
"react": "^16.8.4 || ^17.0.0",
27+
"react-dom": "^16.8.4 || ^17.0.0"
2828
},
2929
"engines": {
3030
"node": ">=10.15.1"

packages/docusaurus-plugin-google-analytics/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"@docusaurus/core": "2.0.0-alpha.70"
1717
},
1818
"peerDependencies": {
19-
"react": "^16.8.4",
20-
"react-dom": "^16.8.4"
19+
"react": "^16.8.4 || ^17.0.0",
20+
"react-dom": "^16.8.4 || ^17.0.0"
2121
},
2222
"engines": {
2323
"node": ">=10.15.1"

packages/docusaurus-plugin-google-gtag/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"@docusaurus/core": "2.0.0-alpha.70"
1717
},
1818
"peerDependencies": {
19-
"react": "^16.8.4",
20-
"react-dom": "^16.8.4"
19+
"react": "^16.8.4 || ^17.0.0",
20+
"react-dom": "^16.8.4 || ^17.0.0"
2121
},
2222
"engines": {
2323
"node": ">=10.15.1"

packages/docusaurus-plugin-ideal-image/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"webpack": "^4.44.1"
3131
},
3232
"peerDependencies": {
33-
"react": "^16.8.4",
34-
"react-dom": "^16.8.4"
33+
"react": "^16.8.4 || ^17.0.0",
34+
"react-dom": "^16.8.4 || ^17.0.0"
3535
},
3636
"engines": {
3737
"node": ">=10.15.1"

packages/docusaurus-plugin-pwa/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"workbox-window": "^6.0.2"
3030
},
3131
"peerDependencies": {
32-
"react": "^16.8.4",
33-
"react-dom": "^16.8.4"
32+
"react": "^16.8.4 || ^17.0.0",
33+
"react-dom": "^16.8.4 || ^17.0.0"
3434
}
3535
}

packages/docusaurus-plugin-sitemap/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"sitemap": "^3.2.2"
2626
},
2727
"peerDependencies": {
28-
"react": "^16.8.4",
29-
"react-dom": "^16.8.4"
28+
"react": "^16.8.4 || ^17.0.0",
29+
"react-dom": "^16.8.4 || ^17.0.0"
3030
},
3131
"engines": {
3232
"node": ">=10.15.1"

packages/docusaurus-preset-bootstrap/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"@docusaurus/theme-bootstrap": "2.0.0-alpha.70"
2121
},
2222
"peerDependencies": {
23-
"react": "^16.8.4",
24-
"react-dom": "^16.8.4"
23+
"react": "^16.8.4 || ^17.0.0",
24+
"react-dom": "^16.8.4 || ^17.0.0"
2525
},
2626
"engines": {
2727
"node": ">=10.15.1"

packages/docusaurus-preset-classic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"@docusaurus/theme-search-algolia": "2.0.0-alpha.70"
2626
},
2727
"peerDependencies": {
28-
"react": "^16.8.4",
29-
"react-dom": "^16.8.4"
28+
"react": "^16.8.4 || ^17.0.0",
29+
"react-dom": "^16.8.4 || ^17.0.0"
3030
},
3131
"engines": {
3232
"node": ">=10.15.1"

packages/docusaurus-remark-plugin-npm2yarn/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"to-vfile": "^6.0.0"
2222
},
2323
"peerDependencies": {
24-
"react": "^16.8.4",
25-
"react-dom": "^16.8.4"
24+
"react": "^16.8.4 || ^17.0.0",
25+
"react-dom": "^16.8.4 || ^17.0.0"
2626
},
2727
"engines": {
2828
"node": ">=10.15.1"

packages/docusaurus-theme-classic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"@docusaurus/module-type-aliases": "2.0.0-alpha.70"
5151
},
5252
"peerDependencies": {
53-
"react": "^16.8.4",
54-
"react-dom": "^16.8.4"
53+
"react": "^16.8.4 || ^17.0.0",
54+
"react-dom": "^16.8.4 || ^17.0.0"
5555
},
5656
"engines": {
5757
"node": ">=10.15.1"

packages/docusaurus-theme-common/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"@docusaurus/module-type-aliases": "2.0.0-alpha.70"
2929
},
3030
"peerDependencies": {
31-
"react": "^16.8.4",
32-
"react-dom": "^16.8.4"
31+
"react": "^16.8.4 || ^17.0.0",
32+
"react-dom": "^16.8.4 || ^17.0.0"
3333
},
3434
"engines": {
3535
"node": ">=10.15.1"

packages/docusaurus-theme-live-codeblock/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"react-live": "^2.2.3"
2222
},
2323
"peerDependencies": {
24-
"react": "^16.8.4",
25-
"react-dom": "^16.8.4"
24+
"react": "^16.8.4 || ^17.0.0",
25+
"react-dom": "^16.8.4 || ^17.0.0"
2626
},
2727
"engines": {
2828
"node": ">=10.15.1"

packages/docusaurus-theme-search-algolia/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"lodash": "^4.17.19"
2626
},
2727
"peerDependencies": {
28-
"react": "^16.8.4",
29-
"react-dom": "^16.8.4"
28+
"react": "^16.8.4 || ^17.0.0",
29+
"react-dom": "^16.8.4 || ^17.0.0"
3030
},
3131
"engines": {
3232
"node": ">=10.15.1"

packages/docusaurus/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@babel/runtime-corejs3": "^7.12.5",
5151
"@babel/traverse": "^7.12.12",
5252
"@docusaurus/cssnano-preset": "2.0.0-alpha.70",
53+
"@docusaurus/react-loadable": "5.5.0",
5354
"@docusaurus/types": "2.0.0-alpha.70",
5455
"@docusaurus/utils": "2.0.0-alpha.70",
5556
"@docusaurus/utils-validation": "2.0.0-alpha.70",
@@ -86,6 +87,7 @@
8687
"lodash.isplainobject": "^4.0.6",
8788
"lodash.isstring": "^4.0.1",
8889
"mini-css-extract-plugin": "^0.8.0",
90+
"module-alias": "^2.2.2",
8991
"nprogress": "^0.2.0",
9092
"null-loader": "^4.0.0",
9193
"optimize-css-assets-webpack-plugin": "^5.0.4",
@@ -116,8 +118,8 @@
116118
"webpackbar": "^5.0.0-3"
117119
},
118120
"peerDependencies": {
119-
"react": "^16.8.4",
120-
"react-dom": "^16.8.4"
121+
"react": "^16.8.4 || ^17.0.0",
122+
"react-dom": "^16.8.4 || ^17.0.0"
121123
},
122124
"engines": {
123125
"node": ">=10.15.1"

packages/docusaurus/src/webpack/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
getMinimizer,
2121
} from './utils';
2222
import {STATIC_DIR_NAME} from '../constants';
23+
import SharedModuleAliases from './sharedModuleAliases';
2324

2425
const CSS_REGEX = /\.css$/;
2526
const CSS_MODULE_REGEX = /\.module\.css$/;
@@ -101,6 +102,8 @@ export function createBaseConfig(
101102
process.cwd(),
102103
],
103104
alias: {
105+
...SharedModuleAliases,
106+
104107
'@site': siteDir,
105108
'@generated': generatedFilesDir,
106109

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import moduleAlias from 'module-alias';
9+
10+
// The shared module aliases are module aliases that need to work in both SSR/NodeJS + Webpack
11+
const SharedModuleAliases = {
12+
// Useful to fix the react-loadable warning
13+
// See https://github.com/jamiebuilds/react-loadable/pull/213#issuecomment-778246548
14+
'react-loadable': '@docusaurus/react-loadable',
15+
};
16+
17+
moduleAlias.addAliases(SharedModuleAliases);
18+
19+
export default SharedModuleAliases;

website/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"clsx": "^1.1.1",
4141
"color": "^3.1.3",
4242
"npm-to-yarn": "^1.0.0-2",
43-
"react": "^16.8.4",
44-
"react-dom": "^16.8.4",
43+
"react": "^17.0.1",
44+
"react-dom": "^17.0.1",
4545
"workbox-routing": "^5.0.0",
4646
"workbox-strategies": "^5.0.0"
4747
},

0 commit comments

Comments
 (0)