xseman / bysquare

Encode & Decode "PAY by square" QR string.
https://xseman.github.io/bysquare/
Apache License 2.0
29 stars 7 forks source link

No import named PaymentOption in v2.8.1 #22

Closed Glogo closed 6 months ago

Glogo commented 6 months ago

After updating to version 2.8.1 I'm getting error:

import { encode, PaymentOptions } from 'bysquare';
                 ^^^^^^^^^^^^^^
SyntaxError: The requested module 'bysquare' does not provide an export named 'PaymentOptions'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

I am using it in Node.js v18.14.2 module without running typescript. Could it be related to the recent tsconfig changes in bysquare?

Glogo commented 6 months ago

After further reviewing your dist folder the "types.js" file is empty, so probably some issue with the ts build and packaging?

Screenshot 2024-03-18 at 15 34 56
xseman commented 6 months ago

It's related to const enum which are inlined in Javascript. The types.d.ts file still retains these values, but it fails to import in Javascript because it doesn't import any varaibles. I'll switch back to regular enums for now, to avoid this problem.

@Glogo What do you think about changing it to standard as const to avoid compilation problems like this one?

xseman commented 6 months ago

Fixed by https://github.com/xseman/bysquare/pull/23

Glogo commented 6 months ago

What do you think about changing it to standard as const to avoid compilation problems like this one?

I don't have any preference regarding this, your change did the trick though, thanks