diegomura/react-pdf

<Image /> throws error when using in NextJS with swcMinify

开放

#2,063 创建于 2022年10月26日

 (5 条评论) (0 个反应) (0 位负责人)TypeScript (1,339 个派生)batch import
help wanted

仓库指标

星标
 (16,756 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Describe the bug I'm using react-pdf with nextjs (v12). When running in dev mode everything works as expected. When building the app for production with swcMinfiy: true in next.config.js I'm getting the following error on the component

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'width')
    at drawImage (_app-4582e1627b46c737.js:115:440420)
    at renderImage (_app-4582e1627b46c737.js:115:440829)
    at renderNode (_app-4582e1627b46c737.js:115:452973)
    at d (_app-4582e1627b46c737.js:115:452461)
    at Array.forEach (<anonymous>)
    at renderChildren (_app-4582e1627b46c737.js:115:452482)
    at renderNode (_app-4582e1627b46c737.js:115:452985)
    at d (_app-4582e1627b46c737.js:115:452461)
    at Array.forEach (<anonymous>)
    at renderChildren (_app-4582e1627b46c737.js:115:452482)

Using swcMinify: false it works as expected. But swc is considered best practice/ stable and is on per default starting Nextjs v13. So leaving it off can't be the solution.

To Reproduce as described above

Expected behavior Should not throw error

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS M1
  • Browser: Chrome
  • Nextjs v12
  • React v18
  • React-pdf v.3.0.0

贡献者指南