resolve-import
Learn how to resolve import paths in source files.
This action rewrites import paths marked with a ?/ prefix in source files.
Templates often include source files that need to import modules from the target project, but the exact path depends on each project's structure and alias configuration. The ?/ prefix lets you write imports as glob patterns instead of hardcoded paths. The action searches the project for files matching the pattern, finds the one that exports the expected names, and replaces the import with the actual path — resolved through the project's alias configuration or as a relative path.
Example
The following template downloads a component and resolves its imports. The example uses TypeScript, but the same approach applies to any supported language:
{ "$schema": "https://schema.croct.com/json/v1/template.json", "title": "Component setup", "description": "Downloads a component and resolves its imports.", "actions": [ { "name": "download", "source": "./code/hero.tsx", "destination": "src/components" }, { "name": "resolve-import", "path": "src/components/hero.tsx" } ]}Suppose the downloaded file contains the following import:
import {cn} from "?/src/**/utils/*.ts";The ?/ prefix marks the specifier as a wildcard pattern. The action searches the project for files matching src/**/utils/*.ts that export cn, and rewrites the import to the resolved path:
import {cn} from "@/lib/utils";The final path depends on where the matching file lives and how the project's path aliases are configured.
Properties
These are the supported properties: