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

Angular 19 support #268

Open
rdamazio opened this issue Nov 19, 2024 · 5 comments
Open

Angular 19 support #268

rdamazio opened this issue Nov 19, 2024 · 5 comments

Comments

@rdamazio
Copy link

Angular 19 is out! :) But it seems that this package is currently restricted to 18 :(
Can we get an update to the latest version?

I'm happy to send a PR if you'd like, but it seems there aren't a lot of tests here, so I'm hesitant that I'll be able to test properly that nothing breaks.

Thanks in advance

@limonte
Copy link
Member

limonte commented Nov 19, 2024

PRs are welcome 🤗 thank you!

@rdamazio
Copy link
Author

I tried to just add the new version to projects/ngx-sweetalert2/package.json, but it crashes at startup with my app, even though the tests on this repo pass :(

NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.io/errors/NG0203
    at injectInjectorOnly (/Users/rdamazio/Development/efis-editor/.angular/cache/19.0.0/efis-editor/vite/deps_ssr/@sweetalert2_ngx-sweetalert2.js:11728:11)
    at ɵɵinject (/Users/rdamazio/Development/efis-editor/.angular/cache/19.0.0/efis-editor/vite/deps_ssr/@sweetalert2_ngx-sweetalert2.js:11736:59)
    at ɵɵdirectiveInject (/Users/rdamazio/Development/efis-editor/.angular/cache/19.0.0/efis-editor/vite/deps_ssr/@sweetalert2_ngx-sweetalert2.js:16935:12)
    at NodeInjectorFactory.SwalDirective_Factory (/Users/rdamazio/Development/efis-editor/.angular/cache/19.0.0/efis-editor/vite/deps_ssr/@sweetalert2_ngx-sweetalert2.js:32182:54)

It could be something on my side, but unfortunately I won't be able to debug this any time soon :/ so I'll let you perform the upgrade.

@rdamazio
Copy link
Author

Made a few more attempts, but I don't understand what it wants here - it seems to be related to the move to standalone components, and its inability to inject the loader service at construction time? My app and its tests do import the module though, and I did try changing everything to standalone: false on ngx-sweetalert2.

Chrome Headless 131.0.0.0 (Mac OS 10.15.7) NodeComponent should create FAILED
	Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.dev/errors/NG0203
	error properties: Object({ code: -203 })
	    at injectInjectorOnly (node_modules/@angular/core/fesm2022/core.mjs:1104:15)
	    at ɵɵinject (node_modules/@angular/core/fesm2022/core.mjs:1117:60)
	    at Module.ɵɵdirectiveInject (node_modules/@angular/core/fesm2022/core.mjs:12953:16)
	    at NodeInjectorFactory.factory (ngx-sweetalert2/projects/ngx-sweetalert2/src/lib/sweetalert2-loader.service.ts:14:14)
	    at getNodeInjectable (node_modules/@angular/core/fesm2022/core.mjs:5433:44)
	    at instantiateAllDirectives (node_modules/@angular/core/fesm2022/core.mjs:13827:27)
	    at createDirectivesInstances (node_modules/@angular/core/fesm2022/core.mjs:13223:5)
	    at ɵɵelementStart (node_modules/@angular/core/fesm2022/core.mjs:27718:9)
	    at templateFn (ng:///ChecklistTreeNodeComponent.js:84:5)
	    at executeTemplate (node_modules/@angular/core/fesm2022/core.mjs:13183:9)

@rdamazio
Copy link
Author

And spent a few more hours on this - sadly, my conclusion so far is that this package only works past Angular 14 by accident, since it uses too many deprecated features (like dynamically creating components outside an injection context, ComponentFactoryResolver, zone-testing, non-standalone components, CommonModule, etc.), and all the dependencies are very old by now (last update was 2y ago?). Angular dependencies were updated over time up to v16 (and claimed compatibility to v18), but without updating the code for it.

Getting this to continue working will be a major undertaking unfortunately, especially since the lack of tests means validating it all manually for all possible use cases 😞

@limonte
Copy link
Member

limonte commented Nov 24, 2024

Thank you so much for putting your time into investigating this @rdamazio

What you described in your report indicates that a new major release of this library would be needed to Angular 19.

There's no chance I can find the required for this task time and energy 😢


This project is now looking for a maintainer(s): #269

Anyone who's willing to give this repo a new life is very welcome 🙌

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

No branches or pull requests

2 participants