build: remove unused image-size dependency - #1529
Open
oanaOM wants to merge 1 commit into
Open
Conversation
image-size is declared as a runtime dependency but never imported. Its only reference is inside getSizeFromImage() in src/gen-media.ts, which is commented out and marked "FIXME: TODO: currently unused" - and which requires 'sizeof' rather than 'image-size' in any case, a package that is not in the dependency tree at all. Removing it leaves the emitted bundles byte-identical (verified by md5 of src/bld/pptxgen.js, pptxgen.cjs.js and pptxgen.es.js before and after), since nothing references it for rollup to externalize. The browser field stub is dropped alongside it as it becomes dead config. This matters to consumers because image-size currently has no patched release: GHSA-w3rx-r6r6-pgpr (ICNS) and GHSA-5p2g-fcmc-qvqq (JXL/HEIF) both cover <= 2.0.2, and 2.0.2 is the latest published version. Every pptxgenjs install therefore surfaces two unfixable HIGH advisories for code that is never executed, and `npm audit fix --force` proposes downgrading pptxgenjs to 1.1.5 to resolve them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Hey, this is already fixed in pptxgenjs-plus - switching to a maintained fork of pptxgenjs is one line. Change dependency: And update your imports: - import pptxgen from "pptxgenjs"
+ import pptxgen from "pptxgenjs-plus" |
|
@gitbrent Could you complete this PR it causing NPM audit hits in workflows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Submission Guidelines
src/*.tsfiles (do not submitdistorsrc/bldfiles) — nodistorsrc/bldfiles included; this is a manifest-only change (package.json+package-lock.json), matching the shape of the previous dependency commit9b1b8b8("updated image-size for pull bump image-size to 1.2.1 #1387")src/core-interfaces.tsandtypes/index.d.ts— N/A, no properties added or changeddemos/modules/*.mjsfile — N/A, not a featureChange Summary
Removes
image-sizefromdependencies. It is declared as a runtime dependency but never imported.Change Description
The only reference to it in the codebase is inside
getSizeFromImage()insrc/gen-media.ts, which is commented out and marked unused:Note that even if that block were re-enabled it would not resolve
image-size— it requires'sizeof', which is not in the dependency tree at all.The
browserfield stub ("image-size": false) is removed alongside it, since it becomes dead config once the dependency is gone.No new npm libraries are needed; this only removes one.
Change Type
Related Issue
None. Raised from downstream dependency-audit findings — see Motivation below.
Motivation and Context
image-sizecurrently has no patched release. Two HIGH advisories:Both cover
<= 2.0.2, and 2.0.2 is the latest published version. There is nothing to upgrade to.The practical effect is that every
pptxgenjsinstall surfaces two unfixable HIGH findings for code that never executes, andnpm audit fix --force"resolves" them by proposing a major downgrade of pptxgenjs itself:That leaves downstream consumers either accepting the risk with a written justification or suppressing the alerts. Dropping the unused declaration removes the finding at its source instead.
For the record, the advisories are not false positives — calling
imageSize()directly on a crafted ICNS buffer with a zero-valued entry length hangs the process indefinitely. The flaw is real; it is simply unreachable throughpptxgenjs.Checklist before requesting a review
/demos/modules/— N/A, not a featuresrcfiles touchednpm run demo-all) rather than the browser demo, since this change only affects Node dependency resolution; details belowVerification
1. Build output is byte-identical. I md5'd
src/bld/pptxgen.js,pptxgen.cjs.jsandpptxgen.es.jsonmaster, applied the change, reinstalled and rebuilt — all three hashes match:Nothing references
image-size, so rollup'sexternal: [...Object.keys(pkg.dependencies)]had nothing to externalize.2.
grep -c "image-size"is0across all three built bundles, both before and after.3. Full Node demo suite passes with
image-sizeabsent from the tree. Installed the modified local package intodemos/node(confirmednode_modules/image-sizeabsent), then rannpm run demo-all, which exercises Master, Chart, Image, Media, Shape, Text and Table:Completed with no errors and a valid deck. The Image module in particular runs fine without the package present.
Note
https: ^1.0.0independencieslooks similarly vestigial — it also has abrowser: falsestub and appears unused. I left it out to keep this PR focused, but happy to address it separately if useful.