chore: upgrade image-size deps to v2 (#11065)

* upgrade image-size to v2

* fix resizeImage script

* fix tests
This commit is contained in:
Sébastien Lorber 2025-04-07 18:29:15 +02:00 committed by GitHub
parent 31b279fea6
commit b7ba0b54fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 24 deletions

View file

@ -27,7 +27,7 @@
"estree-util-value-to-estree": "^3.0.1",
"file-loader": "^6.2.0",
"fs-extra": "^11.1.1",
"image-size": "^1.0.2",
"image-size": "^2.0.2",
"mdast-util-mdx": "^3.0.0",
"mdast-util-to-string": "^4.0.0",
"rehype-raw": "^7.0.0",

View file

@ -8,7 +8,6 @@
import path from 'path';
import url from 'url';
import fs from 'fs-extra';
import {promisify} from 'util';
import {
toMessageRelativeFilePath,
posixPath,
@ -17,7 +16,7 @@ import {
getFileLoaderUtils,
} from '@docusaurus/utils';
import escapeHtml from 'escape-html';
import sizeOf from 'image-size';
import {imageSizeFromFile} from 'image-size/fromFile';
import logger from '@docusaurus/logger';
import {assetRequireAttributeValue, transformNode} from '../utils';
import type {Plugin, Transformer} from 'unified';
@ -80,7 +79,7 @@ async function toImageRequireNode(
}
try {
const size = (await promisify(sizeOf)(imagePath))!;
const size = (await imageSizeFromFile(imagePath))!;
if (size.width) {
attributes.push({
type: 'mdxJsxAttribute',