Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Build not picked up from TypeScript import #424

Open
Jonarod opened this issue Oct 23, 2024 · 2 comments
Open

Custom Build not picked up from TypeScript import #424

Jonarod opened this issue Oct 23, 2024 · 2 comments

Comments

@Jonarod
Copy link

Jonarod commented Oct 23, 2024

Description

When imported from TypeScript file, the full build is imported instead of the custom one.

Additional details

  • ExifReader version: 4.23.7
  • Web browser and version: Chrome
  • Node version: 20.3.0

How to reproduce

  1. Create a TypeScript project using Vite
  2. Add some 'include tags in the exifreader field of package.json:
  "exifreader": {
    "include": {
      "exif": [
        "GPSLatitude",
        "GPSLatitudeRef",
        "GPSLongitude",
        "GPSLongitudeRef",
        "GPSAltitude",
        "GPSAltitudeRef"
      ]
    }
  }
  1. npm rebuild exifreader && rm -rf node_modules/.vite
  2. In some Typescript file: import ExifReader from 'exifreader';

What I expected would happen:

I expected to see only the tags I included.

What really happened:

Every tags were loaded instead.

My guess is that instead of looking for the node_modules/exifreader/dist/exif-reader.js file, TypeScript directly tries to load node_modules/exifreader/exif-reader.d.ts and then loads the full build instead of the custom build.

@Jonarod
Copy link
Author

Jonarod commented Oct 23, 2024

I was able to bypass this using a direct import of the custom build:

/* @ts-ignore */
import ExifReader from 'exifreader/dist/exif-reader.js';

The /* @ts-ignore */ is not excellent resolution for the purists but it made my day for now :)

Leaving this open as I consider this a bug for TypeScript users, but feel free to close it.

@mattiasw
Copy link
Owner

Hi!

I think the issue is that it will always look at the module property in package.json which points to the main entry file, not the built file. You could try changing the compilerOptions.moduleResolution value in your tsconfig.json and see if that helps.

The package.json should use the exports property instead which could help solve this issue, but I think that is an update for the next major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants