ng-hcaptcha icon indicating copy to clipboard operation
ng-hcaptcha copied to clipboard

Is the library working in a standalone component?

Open lmame opened this issue 11 months ago • 0 comments

Hi :)

I was using ng-hcaptcha on Angular 12 until now and it was working perfectly, I had an Angular component and a module for it where I was using it: https://github.com/bmcsoftware/innovation-studio-developer/blob/main/22.1/test210500/bundle/src/main/webapp/libs/com-example-test210500/src/lib/view-components/captcha/runtime/captcha.module.ts#L9

@NgModule({
  imports: [CommonModule, NgHcaptchaModule.forRoot()],
  exports: [CaptchaComponent],
  declarations: [CaptchaComponent],
  entryComponents: [CaptchaComponent]
})

I tried to refactor the component with Angular 14 and change the Component to be a standalone component, so something like:

@Component({
  selector: 'com-example-test210500-com-example-test210500-captcha',
  templateUrl: './captcha.component.html',
  standalone: true,
  imports: [CommonModule, NgHcaptchaModule.forRoot()]
})

However this triggers an error during build: In Webstorm: TS2322: Type ModuleWithProviders<NgHcaptchaModule> is not assignable to type any[] | Type<any>

During build:

Error: libs/com-example-test210500/src/lib/view-components/captcha/runtime/captcha.component.ts:18:27 - error TS2322: Type 'ModuleWithProviders<NgHcaptchaModule>' is not assignable to type 'any[] | Type<any>'.
imports: [CommonModule, NgHcaptchaModule.forRoot()]

According to Angular I could use importProvidersFrom but in our use case. we are a Platform and we load dynamically those components, so we don't have access to boostrapapplication.

I was wondering if this was something on the radar?

lmame avatar Mar 01 '24 18:03 lmame