Skip to content
New issue

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

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

Already on GitHub? # to your account

Error after upgrading to 18 #98

Closed
Sergiobop opened this issue Jun 10, 2024 · 15 comments
Closed

Error after upgrading to 18 #98

Sergiobop opened this issue Jun 10, 2024 · 15 comments

Comments

@Sergiobop
Copy link

Sergiobop commented Jun 10, 2024

Hi! First of all, thanks for this awesome package.

I'm having some issues after upgrading to Angular 18 and 18.1.1 version of this lib:

 [ERROR] Cannot assign to import "stringToBytes"

    node_modules/ngx-kjua/fesm2022/ngx-kjua.mjs:587:7:
      587 │ qr_gen.stringToBytes = qr_gen.stringToBytesFuncs["UTF-8"];
          ╵        ~~~~~~~~~~~~~

  Imports are immutable in JavaScript. To modify the value of this import, you must export a setter
  function in the imported file (e.g. "setStringToBytes") and then import and call that function
  here instead.

I didn't have any issue in NG17
Thanks

Edit: I think this is the problem?

(qr_gen as any).stringToBytes = qr_gen.stringToBytesFuncs["UTF-8"];

I'm using the application builder since it's recommended in v17 and higher

@rbalet
Copy link
Contributor

rbalet commented Jun 11, 2024

@Sergiobop Can you try this pull request ?

#99

@Sergiobop
Copy link
Author

How can i test it @rbalet ?

Can we do a mini-release @werthdavid ? If so, i will test it ASAP

@rbalet
Copy link
Contributor

rbalet commented Jun 12, 2024

@Sergiobop I woud
Either @werthdavid Push a temporary version, or

  1. Download the library
  2. npm i
  3. ng build ngx-kjua --configuration production
  4. cd /dist/ngx-kjua
  5. npm link

That way you prepare locally the library

Then, in the project where you're using it, you use the local npm repo by doing :
6. npm link ngx-kjua
7. Test it out

@werthdavid
Copy link
Owner

Feel free to test, didn't have much time this week sorry. I will probably find time today or tomorrow. If the suggested PR works, we can make a release.

@Sergiobop
Copy link
Author

The compilation error is gone, but i get this now:

main.ts:5 ERROR TypeError: Cannot read properties of null (reading 'firstCreatePass')
    at createViewQuery (core.mjs:17743:15)
    at ɵɵviewQuery (core.mjs:27273:5)
    at NgxKjuaComponent_Query (ngx-kjua.component.ts:30:30)
    at executeViewQueryFn (core.mjs:12499:9)
    at renderView (core.mjs:12665:13)
    at renderComponent (core.mjs:12617:5)
    at renderChildComponents (core.mjs:12719:9)
    at renderView (core.mjs:12699:13)
    at renderComponent (core.mjs:12617:5)
    at renderChildComponents (core.mjs:12719:9)

I don't know if its because i did something wrong in the process

Note: Is kjua-svg needed to work? In my old project i just did npm i ngx-kjua --save, not npm i ngx-kjua kjua-svg --save like the README says

@rbalet
Copy link
Contributor

rbalet commented Jun 12, 2024

@Sergiobop Ah, forgot to tell you, but by using link, you need to add "preserveSymlinks": true, in your angular.json file

image

@Sergiobop
Copy link
Author

Sergiobop commented Jun 12, 2024

A new error @rbalet :

✘ [ERROR] Could not resolve "qrcode-generator"

    node_modules/ngx-kjua/fesm2022/ngx-kjua.mjs:3:19:
      3 │ import qrcode from 'qrcode-generator';
        ╵                    ~~~~~~~~~~~~~~~~~~

  You can mark the path "qrcode-generator" as external to exclude it from the bundle, which will
  remove this error and leave the unresolved path in the bundle.

@rbalet
Copy link
Contributor

rbalet commented Jun 12, 2024

@Sergiobop you're missing a dependency here, please do npm i qrcode-generator

@Sergiobop
Copy link
Author

Sergiobop commented Jun 12, 2024

Okey, ITS WORKING @rbalet @werthdavid

Should the README be updated to have that qrcode-generator dependency when installing the package?
Personally i think the best would be just "npm i ngx-kjua" and you are good to go

Thanks

@werthdavid
Copy link
Owner

werthdavid commented Jun 12, 2024

thank you guys. I will update the readme accordingly

@rbalet
Copy link
Contributor

rbalet commented Jun 12, 2024

@werthdavid @Sergiobop no, the qrcode-generator is a peerDependency, therefore it will be downloaded automatically while doing npm i ngx-kjua.

It is just not working while trying it locally.

Cheers

@Sergiobop
Copy link
Author

Sergiobop commented Jun 12, 2024

@werthdavid @Sergiobop no, the qrcode-generator is a peerDependency, therefore it will be downloaded automatically while doing npm i ngx-kjua.

It is just not working while trying it locally.

Cheers

Ohh, ok, thanks! And kjua-svg is needed?

@werthdavid
Copy link
Owner

kjua-svg is NOT needed anymore!
Can be tested with the official 18.1.2 now!

@Sergiobop
Copy link
Author

I will test it in a few minutes and close the issue if everything is good

Thanks a lot

@Sergiobop
Copy link
Author

Everything is working fine,
Thanks again

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants