Skip to content

Commit 0cbe8b7

Browse files
committed
Add React 18+ support
1 parent 5e2b14a commit 0cbe8b7

26 files changed

+1182
-263
lines changed

.github/workflows/nodejs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

4-
name: Node.js CI
4+
name: CI
55

66
on:
77
push:
@@ -16,12 +16,12 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [10.x, 12.x]
19+
node-version: [16.x, 17.x, 18.x, 20.x, 22.x]
2020

2121
steps:
2222
- uses: actions/checkout@v2
2323
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v1
24+
uses: actions/setup-node@v3
2525
with:
2626
node-version: ${{ matrix.node-version }}
2727
- run: npm ci

.github/workflows/npmpublish.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15-
- uses: actions/setup-node@v1
15+
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 12
17+
node-version-file: ".nvmrc"
1818
- run: npm ci
1919
- run: npm run build
2020
- run: npm test
@@ -24,9 +24,9 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v2
27-
- uses: actions/setup-node@v1
27+
- uses: actions/setup-node@v3
2828
with:
29-
node-version: 12
29+
node-version-file: ".nvmrc"
3030
registry-url: https://registry.npmjs.org/
3131
- run: npm ci
3232
- run: npm run build

.github/workflows/playwright.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@v3
1111
- uses: actions/setup-node@v3
1212
with:
13-
node-version: 18
13+
node-version-file: ".nvmrc"
1414
- name: Install dependencies
1515
run: npm ci
1616
- name: Install Playwright Browsers

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dist-server
55
/test-results/
66
/playwright-report/
77
/playwright/.cache/
8+
/*.scratchpad.*

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.16.0
1+
v22.3

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 3.x.x
4+
5+
## 3.0.0 Bling bang bang born
6+
37
## 2.x.x
48

59
### 2.0.x

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This is a part of server side render phase. Se an example for the whole code.
3535
const { ServerDataContext, resolveData } = createServerContext();
3636

3737
// We need to render app twice.
38-
// First - render App to reqister all effects
38+
// First - render App to register all effects
3939
renderToString(
4040
<ServerDataContext>
4141
<App />
@@ -49,7 +49,7 @@ const data = await resolveData();
4949
res.write(data.toHtml());
5050

5151
// Render App for the second time
52-
// This time data form effects will be avaliable in components
52+
// This time data form effects will be available in components
5353
const htmlStream = renderToNodeStream(
5454
<ServerDataContext>
5555
<App />

babel.config.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"presets": [
33
"@babel/env",
4-
"@babel/preset-react",
4+
[
5+
"@babel/preset-react",
6+
{
7+
"runtime": "automatic"
8+
}
9+
],
510
"@babel/preset-typescript"
611
]
712
}
File renamed without changes.

examples/basic/configs/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
{
1313
test: [/\.jsx?$/, /\.tsx?$/],
1414
use: ["babel-loader"],
15+
exclude: /node_modules/,
1516
},
1617
{
1718
test: /\.(jpe?g|png|gif|svg)$/i,

examples/basic/server.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import express from 'express';
22
import path from 'path';
3-
import React from 'react';
43
import fs from 'fs';
5-
import {renderToPipeableStream} from 'react-dom/server';
6-
import {Page} from './Page';
4+
import { renderToPipeableStream } from 'react-dom/server';
5+
import { Page } from './Page';
76

87
const pageRaw = fs.readFileSync(
98
path.resolve(__dirname, '../../dist/index.html'),
@@ -18,7 +17,7 @@ const app = express();
1817
app.use('/static', express.static(path.resolve(__dirname, '../../dist')));
1918

2019
app.use('/error', (req, res) => {
21-
res.status(503).json({error: true});
20+
res.status(503).json({ error: true });
2221
});
2322

2423
app.use('/data', (_req, res) => {

jest.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module.exports = {
22
preset: 'ts-jest',
3-
testEnvironment: 'jsdom',
3+
testMatch: [
4+
'**/src/**/*.test.{ts,tsx}'
5+
]
46
};

0 commit comments

Comments
 (0)