Skip to content

Fix issues with pdf-js dependencies

Mike Greiling requested to merge fix-pdf-dependencies into master

Since merging "PDFLab" into GitLab's repo (!10642 (merged)), we've had a few odd problems:

  1. We're referencing Mozilla's PDF library inconsistently. We're referencing the main script through the npm-installed module:

    import pdfjsLib from 'pdfjs-dist';

    and we're referencing the web worker from our /vendor/assets/javascripts directory:

    import workerSrc from 'vendor/pdf.worker';

    They are actually different versions of the library. (npm module is 1.8.252, and vendored worker script is 1.8.172)

  2. We still have the compiled 422kb pdflab.js library in our /vendor/assets/javascripts directory even though we aren't using it.

  3. The way we were compiling the web worker in our assets (with file-loader) does not uglify the output so we are serving a 1.5Mb un-minified script in production.

  4. The worker file output by file-loader has an ambiguous filename that ends up looking like 7f6c63f374471c4da264a31dca499ed2.js.

  5. The pdfjs-dist node module depends on worker-loader which has a hard peerDependency with webpack v2.X. This is preventing us from upgrading to webpack v3 !12298 (merged).

This MR addresses all of these by updating our settings, and vendoring all of the pdfjs-dist assets into vendor/assets/javascripts at version 1.8.172.

Once https://github.com/webpack-contrib/worker-loader/issues/75 is resolved, we can use the node module again for both the web worker and the main lib.

Edited by Mike Greiling

Merge request reports

Loading