How to avoid `circular dependencies` when loading pdfAnnotate in svelte?

400 views Asked by At

I would like to use pdfAnnotate in svelte, but when I start the app, npm run dev complains about Circular dependencies. I did not find any example, how to fix this error. Could anyone explain to me what I am doing wrong, or point me to a solution?

To reproduce my problem:

  # 1. install svelte-pdf
  npx degit sveltejs/template my-svelte-project
  npm install
  npm install svelte-pdf
  cp ../../example.pdf public/
  # now add to src/App.svelte see below [1]
  npm run dev
  # now the webpage <host>:5000 works fine and shows the pdf

  # 2. install pdfAnnotate 
  npm install annotpdf
  # now add it to src/App.svelte, too, see below [2].
  npm run dev
  # says "Ciruclar dependencies" and the page <host>:5000 is blank.

where I added in step [1] to src/App.svelte:

<script>
  import PdfViewer from 'svelte-pdf';
</script>
<main>
  <PdfViewer url='./example.pdf' />
</main>

and in step [2] to src/App.svelte:

<script>
  import AnnotationFactory from 'annotpdf';
</script>

(I added the lines inside the existing script and main elements, I did not use multiple such elements.)

The full error message is:

(!) Circular dependencies
node_modules/annotpdf/lib/object-util.js -> node_modules/annotpdf/lib/array-util.js -> node_modules/annotpdf/lib/object-util.js
node_modules/annotpdf/lib/object-util.js -> node_modules/annotpdf/lib/array-util.js -> /home/lst/tmp/pdf/pdfjs-svelte-app/node_modules/annotpdf/lib/object-util.js?commonjs-proxy -> node_modules/annotpdf/lib/object-util.js
0

There are 0 answers