Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConfigModule.withConfig or provideConfig in Spartacus

What is the difference between those two configs and which should be used when?

ConfigModule.withConfig({})

and

provideConfig({})

The documentation didn't provide the clear answer to this question. https://sap.github.io/spartacus-docs/global-configuration-in-spartacus/

like image 592
Jevgenijs Jaunslavietis Avatar asked Oct 27 '25 07:10

Jevgenijs Jaunslavietis


1 Answers

As mentioned in the docs, they are the same.

ConfigModule.withConfig({}) behaves the same way as provideConfig({})

The difference between them is that the first is used to be used in import's array, whereas the latter is used in the provider's array

However, you can create an issue in the Spartacus repository https://github.com/SAP/spartacus/issues in order to open the discussion of deprecating ConfigModule.withConfig

'legacy' way

@NgModule({
  imports: [ConfigModule.withConfig({...})],
  providers: [...]
  ...
})
...

'preferred' way

@NgModule({
  imports: [...],
  providers: [provideConfig({...})]
  ...
})
like image 94
BrianGJ Avatar answered Oct 29 '25 06:10

BrianGJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!