getlago / lago-javascript-client

Lago Javascript Client
MIT License
21 stars 2 forks source link

[BUG]: Build error: Module not found: Default condition should be last one #11

Closed ohueter closed 1 year ago

ohueter commented 1 year ago

I'm getting the following build error when using lago-javascript-client in a Node 18 / Next.js / TypeScript / pnpm project:

Module not found: Default condition should be last one
> 1 | import {
  2 |   Client,
  3 |   getLagoError
  4 | } from 'lago-javascript-client'

The fix is to reverse the order of types and default exports in the package.json of this library, just as the error says:

"exports": {
  ".": {
    "import": {
      "types": "./types/mod.d.ts",
      "default": "./esm/mod.js"
    },
    "require": {
      "types": "./types/mod.d.ts",
      "default": "./script/mod.js"
    }
  }
},

Compare the documentation on this property:

"default" - the generic fallback that always matches. Can be a CommonJS or ES module file. This condition should always come last.

From: https://nodejs.org/api/packages.html#conditional-exports

Would you accept a PR for this fix?

arjunyel commented 1 year ago

Fixed here: https://github.com/getlago/lago-javascript-client/pull/12

You'll have to wait till the next Lago release for this to make it to npm since npm doesn't let you publish to the same version and the Lago team wants the version to be in sync with the main Lago product.

I recommend patch-package in the meantime

ohueter commented 1 year ago

Thanks a lot for fixing this so quickly! 🚀

ohueter commented 1 year ago

You'll have to wait till the next Lago release for this to make it to npm since npm doesn't let you publish to the same version and the Lago team wants the version to be in sync with the main Lago product.

There seems to be a patch version field in your versioning scheme. As this seems to be the first bug issue in this repo, maybe this would be a good opportunity to begin using it? :)

arjunyel commented 1 year ago

You could ask the Lago team in Slack, they originally told me they wanted SDK versions pinned to the main Lago release

ansmonjol commented 1 year ago

Hey,

Thanks both for raising and fixing this issue.

A new version of this client is available with the bugfix

0.26.1-beta