Skip to content

Commit 83cfe32

Browse files
committed
fix: cmap causing 168 bundles in webpack #32
1 parent 2fb67d8 commit 83cfe32

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/Pdfvuer.vue

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,6 @@
2828
else
2929
throw new TypeError('invalid src type');
3030
31-
// see https://github.com/mozilla/pdf.js/blob/628e70fbb5dea3b9066aa5c34cca70aaafef8db2/src/display/dom_utils.js#L64
32-
source.CMapReaderFactory = function () {
33-
34-
this.fetch = function (query) {
35-
36-
return import('raw-loader!pdfjs-dist/cmaps/' + query.name + '.bcmap' /* webpackChunkName: "pdfjs/noprefetch-[request]" */)
37-
.then(function (bcmap) {
38-
39-
return {
40-
cMapData: bcmap,
41-
compressionType: pdfjsLib.CMapCompressionType.BINARY,
42-
};
43-
});
44-
}
45-
};
46-
47-
4831
var loadingTask = pdfjsLib.getDocument(source).promise;
4932
loadingTask.__PDFDocumentLoadingTask = true; // since PDFDocumentLoadingTask is not public
5033

src/cmap.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pdfjsLib from 'pdfjs-dist/webpack.js';
2+
3+
4+
// see https://github.com/mozilla/pdf.js/blob/628e70fbb5dea3b9066aa5c34cca70aaafef8db2/src/display/dom_utils.js#L64
5+
6+
export default function() {
7+
8+
this.fetch = function(query) {
9+
10+
return import('raw-loader!pdfjs-dist/cmaps/' + query.name + '.bcmap' /* webpackChunkName: "pdfjs/noprefetch-[request]" */)
11+
.then(function(bcmap) {
12+
13+
return {
14+
cMapData: bcmap,
15+
compressionType: pdfjsLib.CMapCompressionType.BINARY,
16+
};
17+
});
18+
}
19+
}

0 commit comments

Comments
 (0)