From 4d3cce4bd70269df788e83d9c410d6377c453e00 Mon Sep 17 00:00:00 2001 From: Cody Olsen <81981+stipsan@users.noreply.github.com> Date: Tue, 28 May 2024 12:47:20 +0200 Subject: [PATCH] feat: support react 19 (#170) * feat: support react 19 * chore: fix failing tests --- package.json | 13 ++--- pnpm-lock.yaml | 110 +++++++++++++++++++++++++++++++++++++++++ tsconfig.dist.json | 1 + tsconfig.json | 1 + tsconfig.settings.json | 7 +-- 5 files changed, 121 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 169a248..0d365b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@portabletext/react", - "version": "3.0.18", + "version": "3.1.0-canary.0", "description": "Render Portable Text with React", "keywords": [ "portable-text" @@ -35,14 +35,12 @@ "src" ], "scripts": { - "build": "run-s clean pkg:build pkg:check", + "build": "pkg-utils build --strict --check --clean", "build:demo": "vite build demo --config=./vite.config.demo.ts --base=/react-portabletext/", "clean": "rimraf dist coverage demo/dist .nyc_output", "dev": "vite demo", "format": "prettier --write --cache --ignore-unknown .", "lint": "eslint .", - "pkg:build": "pkg-utils build --strict", - "pkg:check": "pkg-utils --strict", "prepare": "husky install", "prepublishOnly": "run-s build lint type-check", "start": "vite demo", @@ -77,6 +75,7 @@ "ecmaVersion": 9, "sourceType": "module" }, + "plugins": ["react-compiler"], "extends": [ "sanity", "sanity/react", @@ -84,7 +83,8 @@ "prettier" ], "rules": { - "react/prop-types": "off" + "react/prop-types": "off", + "react-compiler/react-compiler": "error" }, "ignorePatterns": [ "dist/**/" @@ -116,6 +116,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-config-sanity": "^7.1.2", "eslint-plugin-react": "^7.34.2", + "eslint-plugin-react-compiler": "0.0.0-experimental-c8b3f72-20240517", "eslint-plugin-react-hooks": "^4.6.2", "husky": "^8.0.3", "leaflet": "^1.9.4", @@ -136,7 +137,7 @@ "vitest": "^1.6.0" }, "peerDependencies": { - "react": "^17 || ^18" + "react": "^17 || ^18 || >=19.0.0-rc" }, "packageManager": "pnpm@9.1.3", "engines": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e84aa2f..2676fcd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -78,6 +78,9 @@ importers: eslint-plugin-react: specifier: ^7.34.2 version: 7.34.2(eslint@8.57.0) + eslint-plugin-react-compiler: + specifier: 0.0.0-experimental-c8b3f72-20240517 + version: 0.0.0-experimental-c8b3f72-20240517(eslint@8.57.0) eslint-plugin-react-hooks: specifier: ^4.6.2 version: 4.6.2(eslint@8.57.0) @@ -159,10 +162,20 @@ packages: resolution: {integrity: sha512-S7m4eNa6YAPJRHmKsLHIDJhNAGNKoWNiWefz1MBbpnt8g9lvMDl1hir4P9bo/57bQEmuwEhnRU/AMWsD0G/Fbg==} engines: {node: '>=6.9.0'} + '@babel/helper-annotate-as-pure@7.24.6': + resolution: {integrity: sha512-DitEzDfOMnd13kZnDqns1ccmftwJTS9DMkyn9pYTxulS7bZxUxpMly3Nf23QQ6NwA4UB8lAqjbqWtyvElEMAkg==} + engines: {node: '>=6.9.0'} + '@babel/helper-compilation-targets@7.24.6': resolution: {integrity: sha512-VZQ57UsDGlX/5fFA7GkVPplZhHsVc+vuErWgdOiysI9Ksnw0Pbbd6pnPiR/mmJyKHgyIW0c7KT32gmhiF+cirg==} engines: {node: '>=6.9.0'} + '@babel/helper-create-class-features-plugin@7.24.6': + resolution: {integrity: sha512-djsosdPJVZE6Vsw3kk7IPRWethP94WHGOhQTc67SNXE0ZzMhHgALw8iGmYS0TD1bbMM0VDROy43od7/hN6WYcA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-environment-visitor@7.24.6': resolution: {integrity: sha512-Y50Cg3k0LKLMjxdPjIl40SdJgMB85iXn27Vk/qbHZCFx/o5XO3PSnpi675h1KEmmDb6OFArfd5SCQEQ5Q4H88g==} engines: {node: '>=6.9.0'} @@ -175,6 +188,10 @@ packages: resolution: {integrity: sha512-SF/EMrC3OD7dSta1bLJIlrsVxwtd0UpjRJqLno6125epQMJ/kyFmpTT4pbvPbdQHzCHg+biQ7Syo8lnDtbR+uA==} engines: {node: '>=6.9.0'} + '@babel/helper-member-expression-to-functions@7.24.6': + resolution: {integrity: sha512-OTsCufZTxDUsv2/eDXanw/mUZHWOxSbEmC3pP8cgjcy5rgeVPWWMStnv274DV60JtHxTk0adT0QrCzC4M9NWGg==} + engines: {node: '>=6.9.0'} + '@babel/helper-module-imports@7.24.6': resolution: {integrity: sha512-a26dmxFJBF62rRO9mmpgrfTLsAuyHk4e1hKTUkD/fcMfynt8gvEKwQPQDVxWhca8dHoDck+55DFt42zV0QMw5g==} engines: {node: '>=6.9.0'} @@ -185,14 +202,28 @@ packages: peerDependencies: '@babel/core': ^7.0.0 + '@babel/helper-optimise-call-expression@7.24.6': + resolution: {integrity: sha512-3SFDJRbx7KuPRl8XDUr8O7GAEB8iGyWPjLKJh/ywP/Iy9WOmEfMrsWbaZpvBu2HSYn4KQygIsz0O7m8y10ncMA==} + engines: {node: '>=6.9.0'} + '@babel/helper-plugin-utils@7.24.6': resolution: {integrity: sha512-MZG/JcWfxybKwsA9N9PmtF2lOSFSEMVCpIRrbxccZFLJPrJciJdG/UhSh5W96GEteJI2ARqm5UAHxISwRDLSNg==} engines: {node: '>=6.9.0'} + '@babel/helper-replace-supers@7.24.6': + resolution: {integrity: sha512-mRhfPwDqDpba8o1F8ESxsEkJMQkUF8ZIWrAc0FtWhxnjfextxMWxr22RtFizxxSYLjVHDeMgVsRq8BBZR2ikJQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-simple-access@7.24.6': resolution: {integrity: sha512-nZzcMMD4ZhmB35MOOzQuiGO5RzL6tJbsT37Zx8M5L/i9KSrukGXWTjLe1knIbb/RmxoJE9GON9soq0c0VEMM5g==} engines: {node: '>=6.9.0'} + '@babel/helper-skip-transparent-expression-wrappers@7.24.6': + resolution: {integrity: sha512-jhbbkK3IUKc4T43WadP96a27oYti9gEf1LdyGSP2rHGH77kwLwfhO7TgwnWvxxQVmke0ImmCSS47vcuxEMGD3Q==} + engines: {node: '>=6.9.0'} + '@babel/helper-split-export-declaration@7.24.6': resolution: {integrity: sha512-CvLSkwXGWnYlF9+J3iZUvwgAxKiYzK3BWuo+mLzD/MDGOZDj7Gq8+hqaOkMxmJwmlv0iu86uH5fdADd9Hxkymw==} engines: {node: '>=6.9.0'} @@ -229,6 +260,13 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-proposal-private-methods@7.18.6': + resolution: {integrity: sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==} + engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead. + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-object-rest-spread@7.8.3': resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==} peerDependencies: @@ -1690,6 +1728,12 @@ packages: eslint-plugin-react-hooks: optional: true + eslint-plugin-react-compiler@0.0.0-experimental-c8b3f72-20240517: + resolution: {integrity: sha512-cxUTFNMEKiLX6uFaRfrr2GHnB7KUHDMYLjEGzDec82ka6WyBCHg906nGSf3JvVnQKHaBDfUk7Mmv/JMvdgQB8Q==} + engines: {node: ^14.17.0 || ^16.0.0 || >= 18.0.0} + peerDependencies: + eslint: '>=7' + eslint-plugin-react-hooks@4.6.2: resolution: {integrity: sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==} engines: {node: '>=10'} @@ -2048,6 +2092,12 @@ packages: hastscript@7.2.0: resolution: {integrity: sha512-TtYPq24IldU8iKoJQqvZOuhi5CyCQRAbvDOX0x1eW6rsHSxa/1i2CCiptNTotGHJ3VoHRGmqiv6/D3q113ikkw==} + hermes-estree@0.20.1: + resolution: {integrity: sha512-SQpZK4BzR48kuOg0v4pb3EAGNclzIlqMj3Opu/mu7bbAoFw6oig6cEt/RAi0zTFW/iW6Iz9X9ggGuZTAZ/yZHg==} + + hermes-parser@0.20.1: + resolution: {integrity: sha512-BL5P83cwCogI8D7rrDCgsFY0tdYUtmFP9XaXtl2IQjC+2Xo+4okjfXintlTxcIwl4qeGddEl28Z11kbVIw0aNA==} + homedir-polyfill@1.0.3: resolution: {integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==} engines: {node: '>=0.10.0'} @@ -3609,6 +3659,10 @@ snapshots: '@jridgewell/trace-mapping': 0.3.25 jsesc: 2.5.2 + '@babel/helper-annotate-as-pure@7.24.6': + dependencies: + '@babel/types': 7.24.6 + '@babel/helper-compilation-targets@7.24.6': dependencies: '@babel/compat-data': 7.24.6 @@ -3617,6 +3671,19 @@ snapshots: lru-cache: 5.1.1 semver: 6.3.1 + '@babel/helper-create-class-features-plugin@7.24.6(@babel/core@7.24.6)': + dependencies: + '@babel/core': 7.24.6 + '@babel/helper-annotate-as-pure': 7.24.6 + '@babel/helper-environment-visitor': 7.24.6 + '@babel/helper-function-name': 7.24.6 + '@babel/helper-member-expression-to-functions': 7.24.6 + '@babel/helper-optimise-call-expression': 7.24.6 + '@babel/helper-replace-supers': 7.24.6(@babel/core@7.24.6) + '@babel/helper-skip-transparent-expression-wrappers': 7.24.6 + '@babel/helper-split-export-declaration': 7.24.6 + semver: 6.3.1 + '@babel/helper-environment-visitor@7.24.6': {} '@babel/helper-function-name@7.24.6': @@ -3628,6 +3695,10 @@ snapshots: dependencies: '@babel/types': 7.24.6 + '@babel/helper-member-expression-to-functions@7.24.6': + dependencies: + '@babel/types': 7.24.6 + '@babel/helper-module-imports@7.24.6': dependencies: '@babel/types': 7.24.6 @@ -3641,12 +3712,27 @@ snapshots: '@babel/helper-split-export-declaration': 7.24.6 '@babel/helper-validator-identifier': 7.24.6 + '@babel/helper-optimise-call-expression@7.24.6': + dependencies: + '@babel/types': 7.24.6 + '@babel/helper-plugin-utils@7.24.6': {} + '@babel/helper-replace-supers@7.24.6(@babel/core@7.24.6)': + dependencies: + '@babel/core': 7.24.6 + '@babel/helper-environment-visitor': 7.24.6 + '@babel/helper-member-expression-to-functions': 7.24.6 + '@babel/helper-optimise-call-expression': 7.24.6 + '@babel/helper-simple-access@7.24.6': dependencies: '@babel/types': 7.24.6 + '@babel/helper-skip-transparent-expression-wrappers@7.24.6': + dependencies: + '@babel/types': 7.24.6 + '@babel/helper-split-export-declaration@7.24.6': dependencies: '@babel/types': 7.24.6 @@ -3682,6 +3768,12 @@ snapshots: '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.24.6) '@babel/plugin-transform-parameters': 7.24.1(@babel/core@7.24.6) + '@babel/plugin-proposal-private-methods@7.18.6(@babel/core@7.24.6)': + dependencies: + '@babel/core': 7.24.6 + '@babel/helper-create-class-features-plugin': 7.24.6(@babel/core@7.24.6) + '@babel/helper-plugin-utils': 7.24.6 + '@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.24.6)': dependencies: '@babel/core': 7.24.6 @@ -5257,6 +5349,18 @@ snapshots: eslint-plugin-react: 7.34.2(eslint@8.57.0) eslint-plugin-react-hooks: 4.6.2(eslint@8.57.0) + eslint-plugin-react-compiler@0.0.0-experimental-c8b3f72-20240517(eslint@8.57.0): + dependencies: + '@babel/core': 7.24.6 + '@babel/parser': 7.24.6 + '@babel/plugin-proposal-private-methods': 7.18.6(@babel/core@7.24.6) + eslint: 8.57.0 + hermes-parser: 0.20.1 + zod: 3.23.8 + zod-validation-error: 3.3.0(zod@3.23.8) + transitivePeerDependencies: + - supports-color + eslint-plugin-react-hooks@4.6.2(eslint@8.57.0): dependencies: eslint: 8.57.0 @@ -5721,6 +5825,12 @@ snapshots: property-information: 6.5.0 space-separated-tokens: 2.0.2 + hermes-estree@0.20.1: {} + + hermes-parser@0.20.1: + dependencies: + hermes-estree: 0.20.1 + homedir-polyfill@1.0.3: dependencies: parse-passwd: 1.0.0 diff --git a/tsconfig.dist.json b/tsconfig.dist.json index b50b5ef..8f3073b 100644 --- a/tsconfig.dist.json +++ b/tsconfig.dist.json @@ -5,6 +5,7 @@ "rootDir": ".", "outDir": "./dist", + "jsx": "preserve", "lib": ["ES2016", "DOM"], "noUncheckedIndexedAccess": true, "forceConsistentCasingInFileNames": true diff --git a/tsconfig.json b/tsconfig.json index 1b5bdf0..fc73875 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "rootDir": ".", "outDir": "./dist", + "jsx": "react-jsx", "lib": ["ES2016", "DOM"], "noUncheckedIndexedAccess": true, "forceConsistentCasingInFileNames": true, diff --git a/tsconfig.settings.json b/tsconfig.settings.json index 2f96213..ab94f4c 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -1,11 +1,10 @@ { "compilerOptions": { - "module": "ES2020", + "module": "Preserve", "target": "ES2020", "declaration": true, "declarationMap": true, "sourceMap": true, - "jsx": "react-jsx", // Strict type-checking "strict": true, @@ -24,8 +23,6 @@ "skipLibCheck": true, // Module resolution - "moduleResolution": "node", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true + "allowSyntheticDefaultImports": true } }