evolit 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/package.json +1 -1
- package/src/compiler.js +16 -0
- package/templates/default/app/page.jsx +1 -1
- package/templates/default/jsconfig.json +5 -0
package/README.md
CHANGED
|
@@ -32,6 +32,20 @@ Supported authored module extensions:
|
|
|
32
32
|
- `.tsx`
|
|
33
33
|
- `.mjs`
|
|
34
34
|
|
|
35
|
+
### Internal imports
|
|
36
|
+
|
|
37
|
+
Imports beginning with `@/` resolve from the application root in server and browser graphs. This
|
|
38
|
+
keeps internal imports stable when modules move between route directories:
|
|
39
|
+
|
|
40
|
+
```jsx
|
|
41
|
+
import FeatureCard from "@/app/components/feature-card";
|
|
42
|
+
import { formatPrice } from "@/lib/format-price";
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Generated applications declare `"@/*": ["./*"]` in `jsconfig.json`, so editors and typechecking
|
|
46
|
+
use the same convention. An explicit `@/*` mapping in `jsconfig.json` or `tsconfig.json` takes
|
|
47
|
+
priority when an application needs a different source root.
|
|
48
|
+
|
|
35
49
|
## Commands
|
|
36
50
|
|
|
37
51
|
```sh
|
package/package.json
CHANGED
package/src/compiler.js
CHANGED
|
@@ -706,8 +706,24 @@ async function resolveProjectPathAlias(projectRoot, specifier) {
|
|
|
706
706
|
return null;
|
|
707
707
|
}
|
|
708
708
|
|
|
709
|
+
async function resolveProjectRootAlias(projectRoot, specifier) {
|
|
710
|
+
if (!specifier.startsWith("@/") || specifier.length === 2) return null;
|
|
711
|
+
|
|
712
|
+
const normalizedProjectRoot = path.resolve(projectRoot);
|
|
713
|
+
const candidatePath = path.resolve(normalizedProjectRoot, specifier.slice(2));
|
|
714
|
+
const relativePath = path.relative(normalizedProjectRoot, candidatePath);
|
|
715
|
+
const isOutsideProject =
|
|
716
|
+
relativePath === ".."
|
|
717
|
+
|| relativePath.startsWith(`..${path.sep}`)
|
|
718
|
+
|| path.isAbsolute(relativePath);
|
|
719
|
+
if (isOutsideProject) return null;
|
|
720
|
+
|
|
721
|
+
return resolveImportPath(path.join(normalizedProjectRoot, "__alias__.js"), candidatePath);
|
|
722
|
+
}
|
|
723
|
+
|
|
709
724
|
async function resolveProjectMappedImport(projectRoot, importerPath, specifier) {
|
|
710
725
|
return await resolveProjectPathAlias(projectRoot, specifier)
|
|
726
|
+
?? await resolveProjectRootAlias(projectRoot, specifier)
|
|
711
727
|
?? await resolveProjectPackageImportMap(importerPath, specifier);
|
|
712
728
|
}
|
|
713
729
|
|