Skip to content

Commit

Permalink
fix: react 19 reconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomura committed Nov 16, 2024
1 parent deb5c42 commit 4768a03
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion e2e/node-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"dependencies": {
"@react-pdf/renderer": "^4.0.2",
"react": "19.0.0-rc-66855b96-20241106"
"react": "^18.2.0"
}
}
2 changes: 1 addition & 1 deletion e2e/node-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"dependencies": {
"@react-pdf/renderer": "^4.0.2",
"react": "19.0.0-rc-66855b96-20241106"
"react": "^18.2.0"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@
"lint-staged": "^10.5.4",
"pdfjs-dist": "3.2.146",
"prettier": "^3.2.0",
"react": "19.0.0-rc-66855b96-20241106",
"react": "^18.2.0",
"react-16": "npm:react@^16.8.0",
"react-17": "npm:react@^17.0.0",
"react-18": "npm:react@^18.2.0",
"react-dom": "19.0.0-rc-66855b96-20241106",
"react-19": "npm:react@19.0.0-rc-66855b96-20241106",
"react-dom": "^18.2.0",
"react-dom-16": "npm:react-dom@^16.8.0",
"react-dom-17": "npm:react-dom@^17.0.0",
"react-dom-18": "npm:react-dom@^18.2.0",
"react-dom-19": "npm:react-dom@19.0.0-rc-66855b96-20241106",
"rimraf": "^2.6.3",
"rollup": "^4.9.0",
"rollup-plugin-copy": "^3.5.0",
Expand Down
7 changes: 4 additions & 3 deletions packages/examples/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
"homepage": "https://github.com/diegomura/react-pdf#readme",
"repository": "[email protected]:diegomura/react-pdf.git",
"scripts": {
"dev": "vite ./src --open"
"dev": "vite ./src --open",
"build:site": "vite build ./src"
},
"dependencies": {
"@react-pdf/renderer": "^4.0.2"
},
"peerDependencies": {
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106"
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/vite/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './index.css';

import React, { useEffect, useState } from 'react';
import { createRoot } from 'react-dom/client';
import ReactPDF, { PDFViewer } from '@react-pdf/renderer';
import { PDFViewer } from '@react-pdf/renderer';

import EXAMPLES from './examples';

Expand Down
11 changes: 10 additions & 1 deletion packages/reconciler/build/trim-reconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const KEEP_OPTIONS = {
createTextInstance: true,
createInstance: true,
appendInitialChild: true,
noTimeout: true,
getCurrentUpdatePriority: true,
setCurrentUpdatePriority: true,
resolveUpdatePriority: true,
shouldAttemptEagerTransition: true,
requestPostPaintCallback: true,
maySuspendCommit: true,
};

const STATIC_OPTIONS = {
Expand All @@ -39,7 +46,9 @@ const STATIC_OPTIONS = {

const METHOD_KEYS = {
updateContainer: true,
updateContainerSync: true,
createContainer: true,
flushSyncWork: true,
};

function clearReconcilerOptions(path) {
Expand All @@ -48,7 +57,7 @@ function clearReconcilerOptions(path) {
const optionName = node.property?.name;

// If we are not visiting config object, skip.
if (objectName !== '$$$hostConfig') return;
if (objectName !== '$$$hostConfig' && objectName !== '$$$config') return;

// If it's an option we want to keep, skip.
if (KEEP_OPTIONS[optionName]) return;
Expand Down
4 changes: 2 additions & 2 deletions packages/reconciler/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default [
plugins: [
resolve({ resolveOnly: ['react-reconciler-31'] }),
commonjs({ esmExternals: (id) => id === 'scheduler' }),
// trimReconciler(),
// terser({ compress: { dead_code: true } }),
trimReconciler(),
terser({ compress: { dead_code: true } }),
],
},
];
39 changes: 17 additions & 22 deletions packages/reconciler/src/reconciler-31.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/extensions */
/* eslint-disable import/no-extraneous-dependencies */

import Reconciler from 'react-reconciler-31/cjs/react-reconciler.production.js';
import Reconciler from 'react-reconciler-31';
import {
ConcurrentRoot,
DefaultEventPriority,
} from 'react-reconciler-31/cjs/react-reconciler-constants.production.js';
} from 'react-reconciler-31/constants';

import propsEqual from './propsEqual';

Expand All @@ -31,36 +31,32 @@ const createRenderer = ({
};

const reconciler = Reconciler({
supportsMutation: true,
isPrimaryRenderer: false,
warnsIfNotActing: false,
appendChild,
appendChildToContainer,
appendInitialChild: appendChild,
createInstance,
createTextInstance,
insertBefore,
commitUpdate: _commitUpdate,
commitTextUpdate,
removeChild,
removeChildFromContainer,
resetAfterCommit,
noTimeout: -1,
shouldSetTextContent: () => false,
finalizeInitialChildren: () => false,
getPublicInstance: (instance) => instance,
getRootHostContext: () => emptyObject,
getChildHostContext: () => emptyObject,
prepareForCommit() {},
clearContainer() {},
resetAfterCommit,
resetTextContent() {},
getRootHostContext: () => emptyObject,
getChildHostContext: () => emptyObject,
shouldSetTextContent: () => false,
noTimeout: -1,
useSyncScheduling: true,
appendChild,
appendChildToContainer,
insertBefore,
removeChild,
removeChildFromContainer,
commitTextUpdate,
commitUpdate: _commitUpdate,
getCurrentUpdatePriority: () => DefaultEventPriority,
setCurrentUpdatePriority: () => {},
maySuspendCommit: () => false,
requestPostPaintCallback: () => {},
resolveUpdatePriority: () => DefaultEventPriority,
setCurrentUpdatePriority: () => {},
shouldAttemptEagerTransition: () => false,
requestPostPaintCallback: () => {},
maySuspendCommit: () => false,
});

const createContainer = (container) => {
Expand All @@ -84,7 +80,6 @@ const createRenderer = ({
};

return {
...reconciler,
createContainer,
updateContainer,
};
Expand Down
3 changes: 1 addition & 2 deletions packages/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"events": "^3.3.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"queue": "^6.0.1",
"scheduler": "0.25.0-rc-603e6108-20241029"
"queue": "^6.0.1"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
Expand Down
4 changes: 1 addition & 3 deletions packages/renderer/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const getPlugins = ({ browser, declarationDests, minify = false }) => [
json(),
...(browser ? [ignore(['fs', 'path', 'url'])] : []),
babel(babelConfig()),
commonjs({
esmExternals: ['scheduler'],
}),
commonjs(),
nodeResolve({ browser, preferBuiltins: !browser }),
replace({
preventAssignment: true,
Expand Down
25 changes: 11 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8673,12 +8673,10 @@ randombytes@^2.1.0:
loose-envify "^1.1.0"
object-assign "^4.1.1"

"react-18@npm:react@^18.2.0":
version "18.3.1"
resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891"
integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==
dependencies:
loose-envify "^1.1.0"
"react-19@npm:[email protected]":
version "19.0.0-rc-66855b96-20241106"
resolved "https://registry.yarnpkg.com/react/-/react-19.0.0-rc-66855b96-20241106.tgz#f04d7283454a32bdd8e9757db4308b75b9739e56"
integrity sha512-klH7xkT71SxRCx4hb1hly5FJB21Hz0ACyxbXYAECEqssUjtJeFUAaI2U1DgJAzkGEnvEm3DkxuBchMC/9K4ipg==

"react-dom-16@npm:react-dom@^16.8.0":
version "16.14.0"
Expand All @@ -8699,13 +8697,12 @@ randombytes@^2.1.0:
object-assign "^4.1.1"
scheduler "^0.20.2"

"react-dom-18@npm:react-dom@^18.2.0":
version "18.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.1.tgz#c2265d79511b57d479b3dd3fdfa51536494c5cb4"
integrity sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==
"react-dom-19@npm:react-dom@19.0.0-rc-66855b96-20241106":
version "19.0.0-rc-66855b96-20241106"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-19.0.0-rc-66855b96-20241106.tgz#beba73decfd1b9365a3c83673a298623b15acb0b"
integrity sha512-D25vdaytZ1wFIRiwNU98NPQ/upS2P8Co4/oNoa02PzHbh8deWdepjm5qwZM/46OdSiGv4WSWwxP55RO9obqJEQ==
dependencies:
loose-envify "^1.1.0"
scheduler "^0.23.2"
scheduler "0.25.0-rc-66855b96-20241106"

[email protected]:
version "19.0.0-rc-66855b96-20241106"
Expand All @@ -8714,7 +8711,7 @@ [email protected]:
dependencies:
scheduler "0.25.0-rc-66855b96-20241106"

react-dom@^18:
react-dom@^18, react-dom@^18.2.0:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.1.tgz#c2265d79511b57d479b3dd3fdfa51536494c5cb4"
integrity sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==
Expand Down Expand Up @@ -8763,7 +8760,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/react/-/react-19.0.0-rc-66855b96-20241106.tgz#f04d7283454a32bdd8e9757db4308b75b9739e56"
integrity sha512-klH7xkT71SxRCx4hb1hly5FJB21Hz0ACyxbXYAECEqssUjtJeFUAaI2U1DgJAzkGEnvEm3DkxuBchMC/9K4ipg==

react@^18:
react@^18, react@^18.2.0:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891"
integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==
Expand Down

0 comments on commit 4768a03

Please sign in to comment.