Seeking help from the SAP Spartacus team.
Encountering errors while developing a Spartacus component, specifically with certain Spartacus .d.ts
definition files that cannot be resolved.
The issue is reproducible in this Github repository/branch:
This problem occurs only with specific Spartacus definitions, not all of them.
When using the import statement below in our component code, tsc
can compile without any problems (the file
/Users/i070295/SAPDevelop/vis/commerce-cloud-poc/storefront/node_modules/@spartacus/storefront/cms-structure/page/model/cms-component-data.d.ts
exists):
import { CmsComponentData } from '@spartacus/storefront/cms-structure/page/model/cms-component-data';
However, running ng serve --verbose
, it seems Angular/Webpack are not searching for it correctly. The probing looks for files with a .ts
extension but not a .d.ts
extension:
[Error messages]
Attempted a suggested workaround online to modify the import path by adding a .d suffix to trick the module loading mechanism into treating a .d.ts
file as a .ts
file, but this does not work with angular 10.1 due to proper identification of uncompiled .ts
files:
[More error messages]
Tried an alternative import statement that also failed:
import { CmsComponentData } from '@spartacus/storefront/cms-structure/page/model';
This issue seems to be isolated to specific Spartacus definition files.
Switched from using CmsComponentData
to importing and using a different type (B2cStorefrontModule
) at the same location in the code, which worked fine without any issues arising:
import { B2cStorefrontModule } from '@spartacus/storefront';
Open to suggestions on how to resolve this issue, kindly seeking assistance.
Regards, Sam Garland