Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swissqrbill 4 With typescript projects #422

Open
RCBiczok opened this issue Nov 12, 2023 · 6 comments
Open

swissqrbill 4 With typescript projects #422

RCBiczok opened this issue Nov 12, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@RCBiczok
Copy link

RCBiczok commented Nov 12, 2023

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.

@RCBiczok RCBiczok changed the title swissqrcode 4 With typescript projects swissqrbill 4 With typescript projects Nov 12, 2023
@schoero
Copy link
Owner

schoero commented Nov 12, 2023

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
Copy link
Author

Jup that solved it - thank you!

@schoero
Copy link
Owner

schoero commented Nov 17, 2023

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

@pavelsvagr
Copy link

@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
Copy link
Owner

schoero commented Nov 29, 2023

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

@schoero schoero reopened this Nov 29, 2023
@schoero
Copy link
Owner

schoero commented Dec 5, 2023

@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?

@schoero schoero added the bug Something isn't working label Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants