Skip to content

Commit 29fa507

Browse files
Hydration fix (#523)
* Hydration fix * HOCs removed * Proper GIAP+GSP/GSSP * Removed HYDRATE * Coverage --------- Co-authored-by: bjoluc <[email protected]>
1 parent 726d0d1 commit 29fa507

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+11747
-16724
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717

18-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v3
1919
with:
2020
node-version: '16.x'
21-
registry-url: 'https://registry.npmjs.org'
2221

2322
- id: yarn-cache-dir-path
24-
run: echo "::set-output name=dir::$(yarn cache dir)"
23+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
2524

26-
- uses: actions/cache@v2
25+
- uses: actions/cache@v3
2726
with:
2827
path: |
2928
${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -42,6 +41,15 @@ jobs:
4241
env:
4342
CI: true
4443

44+
# FIXME Coverage report
45+
46+
- uses: actions/upload-artifact@v3
47+
if: failure()
48+
with:
49+
path: |
50+
packages/*/test-results
51+
packages/*/coverage
52+
4553
- run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
4654

4755
- run: yarn publish:release ${TAG} --yes

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ lib
88
node_modules
99
npm-debug*
1010
out
11+
test-results
1112
types
1213
lerna-debug.log
1314

.lintstagedrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"*.{js,jsx,ts,tsx}": ["yarn eslint", "git add"],
2+
"*.{js,jsx,ts,tsx}": ["yarn lint", "git add"],
33
"*.{js,jsx,ts,tsx,css,scss,sass,less,md,yml,json}": ["yarn prettier", "git add"]
44
}

README.md

Lines changed: 342 additions & 644 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@
1313
"test:quick": "lerna run test:quick --stream --concurrency=1",
1414
"publish:release": "lerna publish --tag-version-prefix=\"\" --force-publish=* --no-push --no-git-tag-version",
1515
"prettier": "prettier --write --ignore-path=.eslintignore --loglevel=warn",
16-
"eslint": "eslint --cache --cache-location node_modules/.cache/eslint --fix",
17-
"lint": "eslint --cache --cache-location .eslint/cache --fix",
18-
"lint:all": "yarn eslint . && yarn prettier .",
16+
"lint": "eslint --cache --cache-location node_modules/.cache/eslint --fix",
17+
"lint:all": "yarn lint . && yarn prettier .",
1918
"lint:staged": "lint-staged --debug"
2019
},
2120
"devDependencies": {
22-
"eslint": "8.29.0",
21+
"eslint": "8.33.0",
2322
"eslint-config-ringcentral-typescript": "7.0.3",
2423
"husky": "7.0.4",
2524
"lerna": "4.0.0",
2625
"lint-staged": "11.1.2",
27-
"prettier": "2.5.1",
28-
"rimraf": "3.0.2",
29-
"typescript": "4.5.2"
26+
"prettier": "2.8.3",
27+
"rimraf": "4.1.2",
28+
"typescript": "4.5.5"
3029
},
3130
"workspaces": [
3231
"packages/*"
@@ -43,6 +42,7 @@
4342
"license": "MIT",
4443
"packageManager": "[email protected]",
4544
"resolutions": {
46-
"@types/react": "17.0.37"
45+
"@types/react": "18.0.27",
46+
"typescript": "4.5.5"
4747
}
4848
}

packages/configs/playwright.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
/** @type {import('@playwright/test').PlaywrightTestConfig} */
12
module.exports = {
3+
use: {
4+
trace: process.env.CI ? 'retain-on-failure' : 'off',
5+
video: 'retain-on-failure',
6+
screenshot: 'on',
7+
},
8+
outputDir: process.cwd() + '/test-results/out',
9+
reporter: [
10+
['html', {outputFolder: process.cwd() + '/test-results/html', open: 'never'}],
11+
['list'],
12+
['junit', {outputFile: process.cwd() + '/test-results/junit.xml'}],
13+
['json', {outputFile: process.cwd() + '/test-results/results.json'}],
14+
],
215
webServer: {
316
command: 'yarn start',
417
port: 3000,

packages/demo-page/next-env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference types="next" />
2-
/// <reference types="next/types/global" />
32
/// <reference types="next/image-types/global" />
43

54
// NOTE: This file should not be edited

packages/demo-page/next.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @type {import('next').NextConfig} */
2+
module.exports = {
3+
// transpilePackages: ['next-redux-wrapper'], // @see https://nextjs.org/docs/advanced-features/compiler#module-transpilation
4+
swcMinify: true,
5+
};

packages/demo-page/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
"dependencies": {
1212
"jsondiffpatch": "0.4.1",
1313
"next-redux-wrapper": "*",
14-
"react": "17.0.2",
15-
"react-dom": "17.0.2",
14+
"react": "18.2.0",
15+
"react-dom": "18.2.0",
1616
"react-redux": "7.2.6",
1717
"redux": "4.1.2",
1818
"redux-logger": "3.0.6"
1919
},
2020
"devDependencies": {
21-
"@playwright/test": "1.17.1",
22-
"@types/react": "17.0.37",
23-
"@types/react-dom": "17.0.11",
21+
"@playwright/test": "1.30.0",
22+
"@types/react": "18.0.27",
23+
"@types/react-dom": "18.0.10",
2424
"@types/react-redux": "7.1.20",
2525
"@types/redux-logger": "3.0.9",
26-
"next": "12.0.4",
26+
"next": "13.1.6",
2727
"next-redux-wrapper-configs": "*",
28-
"playwright": "1.17.1",
28+
"playwright": "1.30.0",
2929
"rimraf": "3.0.2",
30-
"typescript": "4.5.2"
30+
"typescript": "4.9.5"
3131
},
3232
"author": "Kirill Konshin",
3333
"repository": {

packages/demo-page/src/components/reducer.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import {AnyAction} from 'redux';
2-
import {HYDRATE} from 'next-redux-wrapper';
3-
import {diff} from 'jsondiffpatch';
42

53
export interface State {
64
page: string;
75
}
86

97
const reducer = (state: State = {page: 'init'}, action: AnyAction) => {
108
switch (action.type) {
11-
case HYDRATE:
12-
const stateDiff = diff(state, action.payload) as any;
13-
const wasBumpedOnClient = stateDiff?.page?.[0]?.endsWith('X');
14-
console.log('HYDRATE action handler', {
15-
stateDiff,
16-
wasBumpedOnClient,
17-
});
18-
return {
19-
...state,
20-
...action.payload,
21-
page: wasBumpedOnClient ? state.page : action.payload.page,
22-
};
239
case 'PAGE':
2410
return {...state, page: action.payload};
2511
case 'BUMP':

0 commit comments

Comments
 (0)