angular-architects / module-federation-plugin

MIT License
728 stars 197 forks source link

NG0203: inject() must be called from an injection context such as a constructor #628

Open mpanichella opened 2 months ago

mpanichella commented 2 months ago

Using Angular 18.2.1 with native-federation 18.1.2 The remove app works fine, and the shell works fine, but using the remote inside the host fail with the error

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 at injectInjectorOnly (_angular_core.wlA5_LT8-c-dev.js:658:11) at ɵɵinject (_angular_core.wlA5_LT8-c-dev.js:668:59) at Object.factory (_angular_core.wlA5_LT8-c-dev.js:16085:45) at core.mjs:3132:35 at runInInjectorProfilerContext (core.mjs:866:5) at R3Injector.hydrate (core.mjs:3131:11) at R3Injector.get (core.mjs:3005:23) at definition.getStandaloneInjector (_angular_core.wlA5_LT8-c-dev.js:16092:27) at ComponentFactory.create (core.mjs:16511:53) at ViewContainerRef2.createComponent (core.mjs:16975:43)

image
AlanGRutter commented 2 months ago

I found the same issues several days ago - I am using v18.1.5 and found that upgrading to v18.2.1 doesn't work. For more details see the issue I raised over on Angular

kudarias commented 2 months ago

duplicate with https://github.com/angular-architects/module-federation-plugin/issues/621

kudarias commented 1 month ago

I found the same issues several days ago - I am using v18.1.5 and found that upgrading to v18.2.1 doesn't work. For more details see the issue I raised over on Angular

@AlanGRutter any new info? or we have to wait till they will fix it on native federation plugin ??

augustomentz commented 1 month ago

Same here at v18.2.3

kudarias commented 1 month ago

Same here at v18.2.3

https://github.com/angular-architects/module-federation-plugin/issues/621 here i wrote tested versions which work, you can try it, till it will be fixed