Skip to content

Comments

Get PDF.js version from "package-lock.json"#1159

Merged
szaimen merged 1 commit intomasterfrom
get-pdfjs-version-from-package-lock-json
Feb 25, 2025
Merged

Get PDF.js version from "package-lock.json"#1159
szaimen merged 1 commit intomasterfrom
get-pdfjs-version-from-package-lock-json

Conversation

@danxuliu
Copy link
Member

@danxuliu danxuliu commented Feb 24, 2025

The pdfjs-get.js script downloads and unpacks pdfjs-dist in js/pdfjs so it can be loaded from the PDF viewer. However, the PDF.js version to download was got from package.json, which just specifies the desired ranges of versions to use, but not the exact versions actually being built.

Due to that it could happen, for example after running npm audit fix, that pdfjs-get.js downloaded version X.Y, as it was the minimum desired version specified in package.json, but the dependencies were resolved and built against version X.Z, as it was the actual version specified in package-lock.json.

To solve that now the PDF.js version is got from package-lock.json instead, which provides the exact version to use.

Note, however, that this is just a "safety net" to avoid unexpected mismatches as a result of running npm audit fix or similar (see, for example, #1146); in general the PDF.js version is expected to be in sync between package.json and package-lock.json.

The "pdfjs-get.js" script downloads and unpacks "pdfjs-dist" in
"js/pdfjs" so it can be loaded from the PDF viewer. However, the PDF.js
version to download was got from "package.json", which just specifies
the desired ranges of versions to use, but not the exact versions
actually being built.

Due to that it could happen, for example after running "npm audit fix",
that "pdfjs-get.js" downloaded version X.Y, as it was the minimum
desired version specified in "package.json", but the dependencies were
resolved and built against version X.Z, as it was the actual version
specified in "package-lock.json".

To solve that now the PDF.js version is got from "package-lock.json"
instead, which provides the exact version to use.

Note, however, that this is just a "safety net" to avoid unexpected
mismatches as a result of running "npm audit fix" or similar; in general
the PDF.js version is expected to be in sync between "package.json" and
"package-lock.json".

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu
Copy link
Member Author

/backport to stable31

@danxuliu
Copy link
Member Author

/backport to stable30

@danxuliu
Copy link
Member Author

/backport to stable29

@danxuliu danxuliu mentioned this pull request Feb 24, 2025
Copy link
Collaborator

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@szaimen szaimen merged commit 57eba4c into master Feb 25, 2025
36 checks passed
@danxuliu danxuliu deleted the get-pdfjs-version-from-package-lock-json branch May 6, 2025 09:19
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants