Upgrade react-pdf and migrate to ESM
#51
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details
react-pdfto fix a crash that occurs when a PDF source changes before the previous PDF has finished loading:webpackto fix a crash when importingpdf.js:react-pdfhas dropped support for CommonJS and is now ESM-only.Related Issues
Expensify/App#76303
Manual Tests
Apply the following patch in E/App to make testing easier:
Diff
You may also need to update the source URLs to PDFs uploaded from your account.
Open a PDF viewer (attachment or receipt) and quickly click on the
Open different PDFbutton multiple times.Observe that the page crashes and the following error is printed in the console:
Cannot read properties of null (reading 'sendWithPromise').Run
npm i && npm run build && npm packon this PR to build the package.Install it in E/App using
npm pkg set overrides.webpack=^5.104.1 devDependencies.webpack=^5.104.1 && npm install ../react-fast-pdf/react-fast-pdf-1.0.30.tgz(you may need to adjust the path), and removeesm/from the path here.Repeat step 2 and verify that the page no longer crashes.
Linked PRs
Videos
Screen.Recording.2026-01-10.at.20.11.40.mov
Screen.Recording.2026-01-10.at.21.54.21.mov