56a8c934dd
Despite this patch removing the `disableWorker` option itself, please note that we'll still fallback to loading the worker file(s) on the main-thread when running in environments without proper Web Worker support. Furthermore it's still possible, even with this patch, to force the use of fake workers by manually loading the necessary file using a `<script>` tag on the main-thread.[1] That way, the functionality of the now removed `SINGLE_FILE` build target and the resulting `build/pdf.combined.js` file can still be achieved simply by adding e.g. `<script src="build/pdf.worker.js"></script>` to the HTML (obviously with the path adjusted as needed). Finally note that the `disableWorker` option is a performance footgun, and unfortunately many existing third-party examples actually use it without providing any sort of warning/justification. --- [1] This approach is used in the default viewer, since certain kind of debugging may be easier if the code is running directly on the main-thread. |
||
---|---|---|
.. | ||
.gitignore | ||
index.html | ||
main.js | ||
package.json | ||
README.md | ||
webpack.config.js |
Overview
Example to demonstrate PDF.js library usage with Webpack.
Getting started
Build project and install the example dependencies:
$ gulp dist-install
$ cd examples/webpack
$ npm install
To build Webpack bundles, run node_modules/.bin/webpack
. If you are running
a web server, you can observe the build results at
http://localhost:8888/examples/webpack/index.html
See main.js and webpack.config.js files. Please notice that PDF.js
packaging requires packaging of the main application and PDF.js worker code,
and the workerSrc
path shall be set to the latter file.