Webpack entry point cannot find worker-loader in Yarn 2 repo
See original GitHub issueAttach (recommended) or Link to PDF file here: https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
Configuration:
- Web browser and its version: Firefox 84.0
- Operating system and its version: Ubuntu 20.10
- PDF.js version: 2.6.347
- Also note: Webpack 5.11.0 and Yarn 2.3.3 workspaces
Steps to reproduce the problem: To see the manual worker setup resort to fake worker:
- clone and setup with Yarn 2: https://github.com/jcamden/pdfjs-yarn-2
- run the webpack dev server with
yarn start
- check browser console log for ‘Warning: Setting up fake worker.’
To see the webpack entry point fail:
- uncomment line 8 of packages/client/App.tsx “// pdfWebpackEntry(‘./dummy.pdf’);”
- run the webpack dev server with ‘yarn start’
- check terminal for ‘Module not found: Error: Can’t resolve ‘worker-loader’…’
What is the expected behavior? (add screenshot)
- Using the Webpack entry point succeeds, or
- Manually configuring the worker succeeds, or
- I make a million dollars.
What went wrong? (add screenshot)
- Manually setting up worker fails:
- Webpack entry point fails:
- Still no million dollars.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
worker-loader - webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >@expo/webpack-config | Yarn - Package Manager
Welcome to @expo/webpack-config. Webpack config that's optimized for running universal React and react-native-web projects
Read more >Webpack 2 not resolving entry point in webpack.config.js
I did this, and I get no error. But why? If I pass PATHS.src to the context parameter, doesn't webpack start at that...
Read more >webpack-require-from - npm
Webpack plugin that allows to configure path or URL for fetching dynamic imports. Latest version: 1.8.6, last published: a year ago.
Read more >webpack/webpack - Gitter
I'm using the worker-loader and exports-loader to handle that part. ... I feel like there is something small i'm missing but unsure where...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Snuffleupagus The issue is that
pdfjs-dist
lacks an optional(?) peer dependency onworker-loader
so Yarn PnP (not Yarn 2) is denying it accessYou’re installing
worker-loader@^2
butesModule
is aworker-loader@^3
option, granted ifpdfjs-dist
properly declared its dependencies that would have been avoidedJust want to clarify a couple of things for posterity:
import pdfjsLib from 'pdfjs-dist/webpack';
) evinced in the docs and examples (e.g. here) is now deprecated. It took me some time to sort out why pdfjs was not defined—since my mind was already operating in the realm of worker issues; so I hope to save someone else some time.I’ve updated the repro repo with the fixes to serve as an example for anyone trying to integrate pdfjs into a Yarn PnP monorepo with webpack 5. That’s the least I can do to pay it forward. Thank you for your awesome contributions.