kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

Incorrect main/module/exports specified in package.json #340

Closed CMeeg closed 2 years ago

CMeeg commented 2 years ago

Brief bug description

I am using a few Kontent packages in a project that is using Vite as the build tool. When I run vite build I receive errors like Failed to resolve entry for package "@kentico/kontent-delivery". The package may have incorrect main/module/exports specified in its package.json..

If I look at the entries in package.json and compare to the package in node_modules it does seem to be an issue of incorrect paths being specified as, for example, package.json defines the module path as ./dist/esm5/index.js, but there is no such path under dist.

This incorrect paths issue also seems to be the case in:

Not sure if there are others - these are the ones I happen to be using. If this is an issue that requires fixing, should I raise the same issue in each of those repositories?

Repro steps

  1. Go to this repro on StackBlitz
  2. Run npm run build in the terminal
  3. See error

Expected behavior

There should be no "incorrect main/module/exports" error in the build and the build should succeed.

I have changed the paths in the package.json of my local node_modules, for example, set "module": "./dist/esnext/index.js" (as that path does exist) and can confirm this fixes the build error.

Test environment

Screenshots

image