schoero / swissqrbill

Swiss QR Bill generation in Node.js and browsers
MIT License
156 stars 29 forks source link

swissqrbill 4 With typescript projects #422

Open RCBiczok opened 8 months ago

RCBiczok commented 8 months ago

First - thank you so much for this package!

I unfortunately encountered one minor problem when using swissqrcode 4 in webpack + Typescript projects. It somehow is not able to resolve this imports:

import { Table } from "swissqrbill/pdf";

It works when I add the "lib" prefix in each element of the export section within the package.json and changing the import to

import { Table } from "swissqrbill/lib/pdf";

Could it be that the build somehow is not supposed to generate the *d.ts files within the "lib" folders?

I can try to make an PR with a test to fix if you encouter the same error.

schoero commented 8 months ago

I think the key is to use "moduleResolution": "bundler" in tsconfig.json.

https://stackblitz.com/edit/schoero-swissqrbill-avypz7?file=src%2Fpdf.ts (open in chrome)

RCBiczok commented 8 months ago

Jup that solved it - thank you!

schoero commented 7 months ago

With swissqrbill v4.0.2, it should now be possible to also use "moduleResolution": "NodeNext".

pavelsvagr commented 7 months ago

@schoero NodeNext is not working for me because your https://github.com/schoero/svg-engine does not seem to be ready for that.

error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. 
Did you mean '../elements/SVGElement.js'?
schoero commented 7 months ago

Thank you for mentioning @pavelsvagr. I will have a look at it

schoero commented 7 months ago

@pavelsvagr I was not able to reproduce your error. For me it always works, both for svg and pdf files 🤷‍♂️

But I have updated svg-engine and fixed the imports that had no file extension. Can you update to the latest version of svg-engine by running

npm update svg-engine

in your project and let me know if that fixed the problem? Would it otherwise be possible for you to provide a minimal example to reproduce the error?