Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 5 compatibility #340

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-pdf",
"version": "4.2.0",
"version": "5.0.0",
"description": "vue.js pdf viewer",
"main": "src/vuePdfNoSss.vue",
"scripts": {},
Expand All @@ -21,10 +21,9 @@
"homepage": "https://github.com/FranckFreiburger/vue-pdf#readme",
"dependencies": {
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"loader-utils": "^1.4.0",
"loader-utils": "^2.0.0",
"raw-loader": "^4.0.1",
"worker-loader": "^2.0.0",
"pdfjs-dist": "^2.5.207 <2.8.0",
"pdfjs-dist": "^2.9.359",
"vue-resize-sensor": "^2.0.0"
},
"peerDependencies": {}
Expand Down
2 changes: 1 addition & 1 deletion src/CMapReaderFactory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CMapCompressionType } from 'pdfjs-dist/es5/build/pdf.js'
import { CMapCompressionType } from 'pdfjs-dist'

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

Expand Down
2 changes: 1 addition & 1 deletion src/pdfjsWrapper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PDFLinkService } from 'pdfjs-dist/es5/web/pdf_viewer';
import { PDFLinkService } from 'pdfjs-dist/web/pdf_viewer';

var pendingOperation = Promise.resolve();

Expand Down
42 changes: 21 additions & 21 deletions src/vuePdfNoSss.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<style src="./annotationLayer.css"></style>
<script>

import componentFactory from './componentFactory.js'

if ( process.env.VUE_ENV !== 'server' ) {

var pdfjsWrapper = require('./pdfjsWrapper.js').default;
var PDFJS = require('pdfjs-dist/es5/build/pdf.js');

if ( typeof window !== 'undefined' && 'Worker' in window && navigator.appVersion.indexOf('MSIE 10') === -1 ) {

var PdfjsWorker = require('worker-loader!pdfjs-dist/es5/build/pdf.worker.js');
PDFJS.GlobalWorkerOptions.workerPort = new PdfjsWorker();
}

var component = componentFactory(pdfjsWrapper(PDFJS));
} else {

var component = componentFactory({});
}

export default component;
import componentFactory from "./componentFactory.js";
import pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";

if (process.env.VUE_ENV !== "server") {
var pdfjsWrapper = require("./pdfjsWrapper").default;
var PDFJS = require("pdfjs-dist");

if (
typeof window !== "undefined" &&
"Worker" in window &&
navigator.appVersion.indexOf("MSIE 10") === -1
) {
PDFJS.GlobalWorkerOptions.workerSrc = pdfjsWorker;
}

var component = componentFactory(pdfjsWrapper(PDFJS));
} else {
var component = componentFactory({});
}

export default component;
</script>
21 changes: 9 additions & 12 deletions src/vuePdfNoSssNoWorker.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<style src="./annotationLayer.css"></style>
<script>
import componentFactory from "./componentFactory.js";

import componentFactory from './componentFactory.js'
if (process.env.VUE_ENV !== "server") {
var pdfjsWrapper = require("./pdfjsWrapper").default;
var PDFJS = require("pdfjs-dist");
var component = componentFactory(pdfjsWrapper(PDFJS));
} else {
var component = componentFactory({});
}

if ( process.env.VUE_ENV !== 'server' ) {

var pdfjsWrapper = require('./pdfjsWrapper.js').default;
var PDFJS = require('pdfjs-dist/es5/build/pdf.js');
var component = componentFactory(pdfjsWrapper(PDFJS));
} else {

var component = componentFactory({});
}

export default component;
export default component;
</script>
28 changes: 12 additions & 16 deletions src/vuePdfSss.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
<style src="./annotationLayer.css"></style>
<script>
import componentFactory from "./componentFactory";
import pdfjsWrapper from "./pdfjsWrapper";
import pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";

import componentFactory from './componentFactory'
import pdfjsWrapper from './pdfjsWrapper'
var PDFJS = require("pdfjs-dist");

var PDFJS = require('pdfjs-dist/es5/build/pdf.js');
if (process.env.VUE_ENV !== "server") {
if (typeof window !== "undefined" && "Worker" in window) {
PDFJS.GlobalWorkerOptions.workerSrc = pdfjsWorker;
}
}

if ( process.env.VUE_ENV !== 'server' ) {

if ( typeof window !== 'undefined' && 'Worker' in window ) {

var PdfjsWorker = require('worker-loader!pdfjs-dist/es5/build/pdf.worker.js');
PDFJS.GlobalWorkerOptions.workerPort = new PdfjsWorker();
}
}

var component = componentFactory(pdfjsWrapper(PDFJS));
component.PDFJS = PDFJS;

export default component;
var component = componentFactory(pdfjsWrapper(PDFJS));
component.PDFJS = PDFJS;

export default component;
</script>