Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article provides information about the clone module process and known issues associated with this process in Microsoft Dynamics 365 Commerce.
Introduction
The Dynamics 365 e-commerce software development kit (SDK) provides the clone command-line interface (CLI) command to clone a module from the module library. The clone command attempts to copy a module from the module library to your repo for customization. When you run the clone command, the e-commerce SDK will:
- Copy the files inside the immediate module folder (except the test files) to your repo.
- Rename the module in the module definition to the new name provided.
- Rename all the file and class names to map to the new module names.
- Attempt to update all the imports in the *.tsx files.
- If it's a local reference, the path will be updated to reflect the new name of the module.
- If it's a reference outside the module folder, we try to resolve the partial file path and fix the file reference.
- Attempt to update the data action file path so the references are correct.
Note
Both steps 4 and 5 are prone to errors, so it's recommended to review these files manually and fix broken references.
Known issues
Error: Can't resolve '@msdyn365-commerce-modules/<moduleName>'
After cloning a module, you get a build error stating "Can't resolve <moduleName>." This issue occurs because the module has an incorrect package.json file. The following screenshot shows that "main"
should always point to the entry file of the module, which is typically index.js. For errors stating "Can't resolve <moduleName> where the package exists," check if the path of the entry file .js is correct.
Error: Export 'IFullProductsSearchResultsWithCount' was not found in './get-full-products-by-collection'
When building a custom module, you might get this error even though the interface exists in the given path.
A good resource to understand the background of this issue is the Stackoverflow thread. To summarize this thread, it's recommended to have an interface in its own file. If the interface and class are in the same file, you can't import or export them like this:
The screenshot above shows thatIFullProductsSearchResultsWithCount
and GetFullProductsByCollectionInput
are in the same class and can't be imported like that. Instead, it should be imported with the type
keyword, as shown in the following screenshot: