Skip to content

Metadata and FormatEnum types are not exported in 0.35 #4546

Description

@benmccann

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "import 'sharp'" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

  npmPackages:
    sharp: ^0.35.0 => 0.35.1

Does this problem relate to file caching?

The default behaviour of libvips is to cache input files, which can lead to EBUSY or EPERM errors on Windows.
Use sharp.cache(false) to switch this feature off.

  • Adding sharp.cache(false) does not fix this problem.

Does this problem relate to images appearing to have been rotated by 90 degrees?

Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.

  • To auto-orient pixel values use the parameter-less rotate() operation.

  • To retain EXIF Orientation use keepExif().

  • Using rotate() or keepExif() does not fix this problem.

What are the steps to reproduce?

What is the expected behaviour?

The Metadata interface should be exported

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

We use it here:

https://github.com/sveltejs/kit/blob/b42cc23f086afd45ffa4dd714ee838513bacafd1/packages/enhanced-img/src/index.js#L16

It seems it was exported in 0.34 and not in 0.35?

$ pnpm check
$ tsc
../../node_modules/.pnpm/imagetools-core@10.0.0/node_modules/imagetools-core/dist/transforms/format.d.ts:2:15 - error TS2614: Module '"sharp"' has no exported member 'FormatEnum'. Did you mean to use 'import FormatEnum from "sharp"' instead?

2 import type { FormatEnum } from 'sharp';
                ~~~~~~~~~~

../../node_modules/.pnpm/imagetools-core@10.0.0/node_modules/imagetools-core/dist/types.d.ts:1:15 - error TS2614: Module '"sharp"' has no exported member 'Metadata'. Did you mean to use 'import Metadata from "sharp"' instead?

1 import type { Metadata, Sharp } from 'sharp';
                ~~~~~~~~

../../node_modules/.pnpm/vite-imagetools@10.0.1_vite@8.0.10_@types+node@22.19.19_esbuild@0.27.3_jiti@2.4.2_yaml@2.8.3_/node_modules/vite-imagetools/dist/types.d.ts:2:15 - error TS2614: Module '"sharp"' has no exported member 'Metadata'. Did you mean to use 'import Metadata from "sharp"' instead?

2 import type { Metadata } from 'sharp';
                ~~~~~~~~

src/index.js:16:28 - error TS2694: Namespace '"/home/bmccann/src/kit/node_modules/.pnpm/sharp@0.35.1/node_modules/sharp/dist/index"' has no exported member 'Metadata'.

16  * @param {import('sharp').Metadata} meta
                              ~~~~~~~~


Found 4 errors in 4 files.

Errors  Files
     1  ../../node_modules/.pnpm/imagetools-core@10.0.0/node_modules/imagetools-core/dist/transforms/format.d.ts:2
     1  ../../node_modules/.pnpm/imagetools-core@10.0.0/node_modules/imagetools-core/dist/types.d.ts:1
     1  ../../node_modules/.pnpm/vite-imagetools@10.0.1_vite@8.0.10_@types+node@22.19.19_esbuild@0.27.3_jiti@2.4.2_yaml@2.8.3_/node_modules/vite-imagetools/dist/types.d.ts:2
     1  src/index.js:16
[ELIFECYCLE] Command failed with exit code 2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions