ynab / ynab-sdk-js

YNAB API Client for JavaScript
https://api.ynab.com
Apache License 2.0
217 stars 20 forks source link

ESM build not updated #173

Closed fa-sharp closed 2 weeks ago

fa-sharp commented 2 weeks ago

Hey team! I noticed that the flag_name property was missing in flagged transactions when using the SDK, and it seems the underlying issue is that the ESM build (under the dist/esm folder) is not being updated for some reason. This causes ESM bundlers like Parcel to end up with an older version of the SDK. For example, the following file in the ESM build is missing the flag_name property, which means the property won't be parsed:

https://github.com/ynab/ynab-sdk-js/blob/7cda942e8077be84ecf0caac43df67ad49f67665/dist/esm/models/TransactionDetail.js#L60-L62

The flag_name property does appear in the Common JS build:

https://github.com/ynab/ynab-sdk-js/blob/7cda942e8077be84ecf0caac43df67ad49f67665/dist/models/TransactionDetail.js#L67-L70

Could you take a look? I'm guessing it might have something to do with the OpenAPI Generator that's being used. Let me know if you need more info or if I can help in any way!

fa-sharp commented 2 weeks ago

Did some more digging and I think I found the issue - it's the tsBuildInfoFile property in the tsconfig file. The ESM tsconfig needs a separate file for incremental compilation, otherwise it won't generate the new ESM files.

I added "tsBuildInfoFile": "./tsconfig.esm.tsbuildinfo" to the ESM tsconfig file:

https://github.com/ynab/ynab-sdk-js/blob/7cda942e8077be84ecf0caac43df67ad49f67665/src/tsconfig.esm.json#L5-L8

Then when running the build command, the new ESM files are built as expected in the dist/esm folder.

The generated tsconfig.esm.tsbuildinfo file will also need to be added to .gitignore.

Hope that fixes this, but let me know if you need anything else!

bradymholt commented 2 weeks ago

Thanks for the report and help here @fa-sharp ! I've incorporated this fix in https://github.com/ynab/ynab-sdk-js/pull/175.