Skip to content

Commit

Permalink
fix: cmap causing 168 bundles in webpack #32
Browse files Browse the repository at this point in the history
  • Loading branch information
arkokoley committed Apr 19, 2020
1 parent 2fb67d8 commit 83cfe32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/Pdfvuer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@
else
throw new TypeError('invalid src type');
// see https://github.com/mozilla/pdf.js/blob/628e70fbb5dea3b9066aa5c34cca70aaafef8db2/src/display/dom_utils.js#L64
source.CMapReaderFactory = function () {
this.fetch = function (query) {
return import('raw-loader!pdfjs-dist/cmaps/' + query.name + '.bcmap' /* webpackChunkName: "pdfjs/noprefetch-[request]" */)
.then(function (bcmap) {
return {
cMapData: bcmap,
compressionType: pdfjsLib.CMapCompressionType.BINARY,
};
});
}
};
var loadingTask = pdfjsLib.getDocument(source).promise;
loadingTask.__PDFDocumentLoadingTask = true; // since PDFDocumentLoadingTask is not public
Expand Down
19 changes: 19 additions & 0 deletions src/cmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pdfjsLib from 'pdfjs-dist/webpack.js';


// see https://github.com/mozilla/pdf.js/blob/628e70fbb5dea3b9066aa5c34cca70aaafef8db2/src/display/dom_utils.js#L64

export default function() {

this.fetch = function(query) {

return import('raw-loader!pdfjs-dist/cmaps/' + query.name + '.bcmap' /* webpackChunkName: "pdfjs/noprefetch-[request]" */)
.then(function(bcmap) {

return {
cMapData: bcmap,
compressionType: pdfjsLib.CMapCompressionType.BINARY,
};
});
}
}

0 comments on commit 83cfe32

Please sign in to comment.