react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Webpack version inconsistency after `npm update`

Open fkocovski opened this issue 2 years ago • 12 comments

Before you start - checklist

  • [X] I followed instructions in documentation written for my React-PDF version
  • [X] I have checked if this bug is not already reported
  • [X] I have checked if an issue is not listed in Known issues
  • [ ] If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

Whenever I run an npm update command to update other packages and after that I try an npm run start or npm run build I get following error message:

Screenshot 2021-12-20 at 09 28 41

The only way I currently found to fix this is to manually remove the node_modules folder and delete the package-lock.json file, uninstall react-pdf, run a clean npm install and only afterwards run once more npm i react-pdf. How can I fix this?

Steps to reproduce

  1. Install latest version
  2. Downgrade another package
  3. Run npm update
  4. Run npm run start or npm run build

Expected behavior

Should not have webpack inconsistency

Actual behavior

Screenshot 2021-12-20 at 09 28 41

Additional information

No response

Environment

- **Browser (if applicable)**: Version 98.0.4758.9 (Official Build) dev (arm64)
- **React-PDF version**: 5.6.0
- **React version**: 17.0.1
- **Webpack version (if applicable)**:

fkocovski avatar Dec 20 '21 08:12 fkocovski

No idea what your npm is doing, but react-pdf does not depend on webpack. It does, however, depend on file-loader, so you might be a victim of idiotic npm 7 behavior where peerDependencies are automatically installed.

wojtekmaj avatar Dec 28 '21 23:12 wojtekmaj

Ok thanks for the info. Would you perhaps have an idea into which direction to point me to solve my issue perhaps? Many thanks

fkocovski avatar Dec 29 '21 10:12 fkocovski

file-loader should be a devDependency in project.json instead an dependency. This causes problems with create-react-app >= 5.0.0 too.

rpaasche avatar Mar 21 '22 10:03 rpaasche

file-loader is not really a devDependency. It has to install with React-PDF for Webpack 4 entry file to work. However, it has no use in Webpack 5 entry file, Parcel entry file, generic entry file... Perhaps dropping support for Webpack 4 altogether would be a better choice.

wojtekmaj avatar Mar 21 '22 14:03 wojtekmaj

file-loader is not really a devDependency. It has to install with React-PDF for Webpack 4 entry file to work. However, it has no use in Webpack 5 entry file, Parcel entry file, generic entry file... Perhaps dropping support for Webpack 4 altogether would be a better choice.

Hmm right, but this would make it a perfect peerDependency, only required in combination with webpack 4.

rpaasche avatar Mar 21 '22 15:03 rpaasche

Agreed! Let's do this.

wojtekmaj avatar Mar 21 '22 15:03 wojtekmaj

Note that peerDependencies are now installed by default in npm7+, so probably we also should mark the dependency as optional: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependenciesmeta

yuliya-ivaniukovich avatar May 20 '22 12:05 yuliya-ivaniukovich

Would love to see this fixed!

Snipx avatar May 20 '22 12:05 Snipx

@wojtekmaj I've added the otional flag to the PR

rpaasche avatar May 21 '22 13:05 rpaasche

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar Aug 22 '22 00:08 github-actions[bot]

Any change to get a release?

rpaasche avatar Aug 23 '22 09:08 rpaasche

Ahh I see it is in v6.0.0-beta.3, thanks.

rpaasche avatar Aug 23 '22 09:08 rpaasche

I'm using webpack 5 with react-pdf 6.1.1 but the build breaks because I don't have file-loader installed. For all other assets I use the new asset loader from webpack. Is it still required for webpack 5 to install file-loader when using react-pdf or it this a bug ?

martinbroos avatar Nov 21 '22 14:11 martinbroos

Have you tried this from the docs? image

Otherwise "build breaks" is insufficient to help

rpaasche avatar Nov 21 '22 15:11 rpaasche

Ah i see I was using entry.webpack instead of entry.webpack5 . Thanks all working now :)

martinbroos avatar Nov 21 '22 16:11 martinbroos

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar Feb 20 '23 00:02 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Mar 20 '23 00:03 github-actions[bot]