1

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
Lars
  • 431
  • 4
  • 4
  • It said in clear text that `annotpdf/lib/object-util.js` and `annotpdf/lib/array-util.js` circularly depends on one another. Not your fault. The lib did it. Not sure how to fix though. Is it a warning or an error? If warning just ignore. – hackape Dec 02 '21 at 18:27
  • Thanks hackape! Your comments helped me to debug the issue further: as you suspected, the circular dependencies are not the culprit, but a harmless warning. If you add your comment as answer, I will accept it and open a new question about the real troublemaker... – Lars Dec 04 '21 at 11:02
  • 1
    No problem. I don't feel it worth posting as an answer so I'll pass. If you like you can answer your own question, that actually makes more sense since you have more info than I do. – hackape Dec 04 '21 at 19:49

0 Answers0