Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/short-facts-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack": patch
---

remove image-size
2 changes: 1 addition & 1 deletion packages/repack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"exit-hook": "^4.0.0",
"flow-remove-types": "^2.277.0",
"gradient-string": "^2.0.2",
"image-size": "^1.1.1",
"jsonwebtoken": "^9.0.3",
"memfs": "^4.11.1",
"mime-types": "^2.1.35",
Expand All @@ -101,6 +100,7 @@
"schema-utils": "^4.2.0",
"semver": "^7.7.2",
"shallowequal": "^1.1.0",
"sharp": "^0.35.3",
"tapable": "^2.2.1",
"terser-webpack-plugin": "^5.3.14",
"throttleit": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/repack/src/loaders/assetsLoader/assetsLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export default async function repackAssetsLoader(
}

const scale = getScaleNumber(scaleKey);
const dimensions = getAssetDimensions({
const dimensions = await getAssetDimensions({
resourceData: content,
resourceScale: scale,
});
Expand Down
9 changes: 5 additions & 4 deletions packages/repack/src/loaders/assetsLoader/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path';
import { imageSize } from 'image-size';
import sharp from 'sharp';
import type { Asset, AssetDimensions, CollectedScales } from './types.js';

export function getScaleNumber(scaleKey: string) {
Expand All @@ -12,15 +12,16 @@ export function getAssetSize(assets: Asset[]) {
return assets[0].dimensions;
}

export function getAssetDimensions({
export async function getAssetDimensions({
resourceData,
resourceScale,
}: {
resourceData: Buffer;
resourceScale: number;
}): AssetDimensions | null {
}): Promise<AssetDimensions | null> {
try {
const info = imageSize(resourceData);
const sharpInstance = sharp(resourceData);
const info = await sharpInstance.metadata();
if (!info.width || !info.height) {
return null;
}
Expand Down
Loading
Loading