Skip to content

Commit 9bd4b73

Browse files
authored
Update to support react 19 (#20)
* deps: update to react 19 * package: move react and grapes to peers + add clean script * refactor: move example app to 19 * feat: add react app 18 example * further changes to support react 18 + 19 * refactor: use create root for react 19 demo * package: updates * * yarn lock * * ci: init * ci: add core build * ci: * * ci: * * ci: * * ci: * * feat: add docker files * * * docker * * apply react codemod * * * ci: * * * * * * fix build errors? * fix errors 2? * fix 3 * * * * * * * * * feat: add two simple examples in 18 & 19 * fix: use import type newline vs same * fix: build cjs main * fix: cjs and exclude react jsx runtime from build * refactor: remove simple example * pkg fix * ci *
1 parent c5d6401 commit 9bd4b73

File tree

100 files changed

+3717
-1454
lines changed

Some content is hidden

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

100 files changed

+3717
-1454
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Setup Project
2+
description: Sets up the project by installing dependencies
3+
4+
inputs:
5+
node-version:
6+
required: false
7+
default: 22.4.1
8+
description: "The version of Node.js to use."
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: ${{ inputs.node-version }}
16+
registry-url: "https://registry.npmjs.org"
17+
cache: "yarn"
18+
- name: Install dependencies
19+
run: yarn
20+
shell: bash

.github/workflows/pr.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
react-version: [19, 18]
15+
include:
16+
- react-version: 19
17+
app-name: react-app-19
18+
react-dom-version: ^19.0.0
19+
react-types-version: ^19.0.0
20+
- react-version: 18
21+
app-name: react-app-18
22+
react-dom-version: ^18.2.0
23+
react-types-version: ^18.2.0
24+
25+
name: Build with React ${{ matrix.react-version }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Project Base
31+
uses: ./.github/actions/setup-project
32+
33+
## We specify the version of react and react-dom we want to run vite build with
34+
- name: Install React Dependencies in Root
35+
run: |
36+
cd ./packages/grapesjs-react && yarn add \
37+
react@^19.0.0 \
38+
react-dom@^19.0.0 \
39+
@types/react@^19.0.0 \
40+
@types/react-dom@^19.0.0
41+
42+
- name: Build Core
43+
run: yarn workspace @grapesjs/react run build
44+
45+
- name: Build Full Example App
46+
run: yarn workspace @grapesjs/${{ matrix.app-name }} run build

DOCKER.md

+48

Dockerfile.base

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM node:20-alpine
2+
3+
WORKDIR /app
4+
5+
RUN apk add --no-cache python3 make g++ wget
6+
7+
COPY package.json yarn.lock ./
8+
COPY packages/grapesjs-react/package.json ./packages/grapesjs-react/package.json
9+
COPY packages/grapesjs-react-app-18/package.json ./packages/grapesjs-react-app-18/package.json
10+
COPY packages/grapesjs-react-app-19/package.json ./packages/grapesjs-react-app-19/package.json
11+
12+
RUN yarn install
13+
14+
WORKDIR /app/packages/grapesjs-react
15+
16+
RUN yarn add \
17+
react@^19.0.0 \
18+
react-dom@^19.0.0 \
19+
@types/react@^19.0.0 \
20+
@types/react-dom@^19.0.0
21+
22+
WORKDIR /app
23+
24+
COPY . .
25+
26+
RUN yarn workspace @grapesjs/react run build

Dockerfile.react18

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM grapesjs-base:latest
2+
3+
RUN yarn add -W \
4+
react@^18.2.0 \
5+
react-dom@^18.2.0 \
6+
@types/react@^18.2.0 \
7+
@types/react-dom@^18.2.0
8+
9+
WORKDIR /app/packages/grapesjs-react
10+
RUN yarn link
11+
12+
WORKDIR /app/packages/grapesjs-react-app-18
13+
RUN yarn link @grapesjs/react
14+
15+
WORKDIR /app
16+
RUN yarn install
17+
18+
WORKDIR /app/packages/grapesjs-react-app-18
19+
20+
EXPOSE 5173
21+
22+
CMD ["yarn", "dev", "--host", "0.0.0.0"]

Dockerfile.react19

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM grapesjs-base:latest
2+
3+
RUN yarn add -W \
4+
react@^19.0.0 \
5+
react-dom@^19.0.0 \
6+
@types/react@^19.0.0 \
7+
@types/react-dom@^19.0.0
8+
9+
WORKDIR /app/packages/grapesjs-react
10+
RUN yarn link
11+
12+
WORKDIR /app/packages/grapesjs-react-app-19
13+
RUN yarn link @grapesjs/react
14+
15+
WORKDIR /app
16+
RUN yarn install
17+
18+
WORKDIR /app/packages/grapesjs-react-app-19
19+
20+
EXPOSE 5173
21+
22+
CMD ["yarn", "dev", "--host", "0.0.0.0"]

docker-compose.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: "3.8"
2+
3+
services:
4+
base:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.base
8+
image: grapesjs-base:latest
9+
10+
react18:
11+
build:
12+
context: .
13+
dockerfile: Dockerfile.react18
14+
ports:
15+
- "5173:5173"
16+
healthcheck:
17+
test: ["CMD", "wget", "--spider", "http://localhost:5173"]
18+
interval: 5s
19+
timeout: 5s
20+
retries: 10
21+
environment:
22+
- VITE_DEV_SERVER_HOST=0.0.0.0
23+
- VITE_DEV_SERVER_PORT=5173
24+
volumes:
25+
- ./packages/grapesjs-react-app-18:/app/packages/grapesjs-react-app-18
26+
- /app/packages/grapesjs-react-app-18/node_modules
27+
28+
react19:
29+
build:
30+
context: .
31+
dockerfile: Dockerfile.react19
32+
ports:
33+
- "5173:5173"
34+
healthcheck:
35+
test: ["CMD", "wget", "--spider", "http://localhost:5173"]
36+
interval: 5s
37+
timeout: 5s
38+
retries: 10
39+
environment:
40+
- VITE_DEV_SERVER_HOST=0.0.0.0
41+
- VITE_DEV_SERVER_PORT=5173
42+
volumes:
43+
- ./packages/grapesjs-react-app-19:/app/packages/grapesjs-react-app-19
44+
- /app/packages/grapesjs-react-app-19/node_modules

package.json

+30-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,40 @@
33
"private": true,
44
"packageManager": "[email protected]",
55
"scripts": {
6-
"start": "yarn workspace @grapesjs/react run dev & yarn workspace @grapesjs/react-app run dev"
6+
"build": "yarn build:core && yarn build:app-18 && yarn build:app-19",
7+
"start": "yarn workspace @grapesjs/react run dev & yarn workspace @grapesjs/react-app run dev",
8+
"clean": "find . -type d \\( -name \"node_modules\" -o -name \"build\" -o -name \"dist\" \\) -exec rm -rf {} + && rm ./yarn.lock",
9+
"build:core": "yarn workspace @grapesjs/react run build",
10+
"build:app-18": "yarn workspace @grapesjs/react-app-18 run build",
11+
"build:app-19": "yarn workspace @grapesjs/react-app-19 run build"
712
},
813
"workspaces": {
914
"packages": [
1015
"packages/*"
16+
],
17+
"nohoist": [
18+
"**/react",
19+
"**/react-dom",
20+
"**/react/**",
21+
"**/react-dom/**",
22+
"**/@types/react",
23+
"**/@types/react-dom"
1124
]
25+
},
26+
"dependencies": {
27+
"@types/node": "^20.3.3",
28+
"grapesjs": "^0.22.5",
29+
"vite-plugin-dts": "^4.5.0",
30+
"@typescript-eslint/eslint-plugin": "^5.59.0",
31+
"@typescript-eslint/parser": "^5.59.0",
32+
"@vitejs/plugin-react": "^4.0.0",
33+
"autoprefixer": "^10.4.14",
34+
"eslint": "^8.38.0",
35+
"eslint-plugin-react-hooks": "^4.6.0",
36+
"eslint-plugin-react-refresh": "^0.3.4",
37+
"postcss": "^8.4.24",
38+
"tailwindcss": "^3.3.2",
39+
"typescript": "^5.0.2",
40+
"vite": "^4.3.9"
1241
}
1342
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nodeLinker: node-modules
2+
nmMode: hardlinks-local
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@grapesjs/react-app-18",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite --force",
8+
"build": "tsc && vite build",
9+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@emotion/react": "^11.11.1",
14+
"@emotion/styled": "^11.11.0",
15+
"@mdi/js": "^7.2.96",
16+
"@mdi/react": "^1.6.1",
17+
"@mui/material": "^5.13.5",
18+
"@grapesjs/react": "1.0.0",
19+
"react": "^18.2.0",
20+
"react-dom": "^18.2.0"
21+
},
22+
"devDependencies": {
23+
"@types/react": "^18.2.0",
24+
"@types/react-dom": "^18.2.0"
25+
},
26+
"resolutions": {
27+
"react": "^18.2.0",
28+
"react-dom": "^18.2.0"
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import GrapesJsEditor, { AssetsProvider, Canvas, EditorProps, ModalProvider } from '@grapesjs/react';
2+
import { ThemeProvider } from '@mui/material/styles';
3+
import { MAIN_BORDER_COLOR, customTheme, defaultEditorProps } from './common';
4+
import CustomAssetManager from './components/CustomAssetManager';
5+
import CustomModal from './components/CustomModal';
6+
import RightSidebar from './components/RightSidebar';
7+
import Topbar from './components/Topbar';
8+
9+
export default function CustomEditor(props: Partial<EditorProps>) {
10+
return (
11+
<ThemeProvider theme={customTheme}>
12+
<GrapesJsEditor
13+
className="gjs-custom-editor"
14+
{...defaultEditorProps}
15+
{...props}
16+
>
17+
<div className={`flex h-full border-t ${MAIN_BORDER_COLOR}`}>
18+
<div className="gjs-column-m flex flex-col flex-grow">
19+
<Topbar className="min-h-[48px]"/>
20+
<Canvas className="flex-grow gjs-custom-editor-canvas"/>
21+
</div>
22+
<RightSidebar className={`gjs-column-r w-[300px] border-l ${MAIN_BORDER_COLOR}`}/>
23+
</div>
24+
<ModalProvider>
25+
{({ open, title, content, close }) => (
26+
<CustomModal open={open} title={<>{title}</>} close={close}>
27+
<>{content}</>
28+
</CustomModal>
29+
)}
30+
</ModalProvider>
31+
<AssetsProvider>
32+
{({ assets, select, close, Container }) => (
33+
<Container>
34+
<CustomAssetManager assets={assets} select={select} close={close}/>
35+
</Container>
36+
)}
37+
</AssetsProvider>
38+
</GrapesJsEditor>
39+
</ThemeProvider>
40+
)
41+
}

packages/grapesjs-react-app/src/examples/DefaultCustomEditor.tsx renamed to packages/grapesjs-react-app-18/src/examples/DefaultCustomEditor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function DefaultCustomEditor(props: Partial<EditorProps>) {
6262
</AssetsProvider>
6363
<ModalProvider>
6464
{({ open, title, content, close }) => (
65-
<CustomModal open={open} title={title} children={content} close={close}/>
65+
<CustomModal open={open} title={<>{title}</>} children={<>{content}</>} close={close}/>
6666
)}
6767
</ModalProvider>
6868
</GrapesJsEditor>

packages/grapesjs-react-app/src/examples/components/CustomModal.tsx renamed to packages/grapesjs-react-app-18/src/examples/components/CustomModal.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { mdiClose } from '@mdi/js';
2+
import type { ReactNode } from 'react';
23
import Icon from '@mdi/react';
34
import Box from '@mui/material/Box';
45
import Fade from '@mui/material/Fade';
@@ -21,9 +22,9 @@ const style = {
2122
};
2223

2324
interface CustomModalProps extends Omit<ModalProps, 'title'> {
24-
title: React.ReactNode,
25+
title: ReactNode,
2526
close: () => void,
26-
}
27+
}
2728

2829
export default function CustomModal({ children, title, close, ...props }: CustomModalProps) {
2930
return (

0 commit comments

Comments
 (0)