Skip to content

Commit d6d1d35

Browse files
committed
Support a deprecated module resolution
1 parent 540cfc8 commit d6d1d35

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@feature-sliced/filesystem",
3-
"version": "2.2.3",
3+
"version": "2.2.4",
44
"description": "A set of utilities for locating and working with FSD roots in the file system.",
55
"scripts": {
66
"build": "tsup src/index.ts --dts --format esm,cjs --clean",

src/resolve-import.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export function resolveImport(
5656

5757
const imperfectKeys = {
5858
module: ts.ModuleKind,
59-
moduleResolution: ts.ModuleResolutionKind,
59+
moduleResolution: {
60+
...ts.ModuleResolutionKind,
61+
node: ts.ModuleResolutionKind.Node10,
62+
},
6063
moduleDetection: ts.ModuleDetectionKind,
6164
newLine: ts.NewLineKind,
6265
target: ts.ScriptTarget,
@@ -90,7 +93,8 @@ export interface ImperfectCompilerOptions
9093
module?: ts.ModuleKind | keyof typeof ts.ModuleKind;
9194
moduleResolution?:
9295
| ts.ModuleResolutionKind
93-
| keyof typeof ts.ModuleResolutionKind;
96+
| keyof typeof ts.ModuleResolutionKind
97+
| "node";
9498
moduleDetection?:
9599
| ts.ModuleDetectionKind
96100
| keyof typeof ts.ModuleDetectionKind;

src/specs/resolve-import.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,26 @@ test("Basic", () => {
2323
),
2424
).toBe("src/shared/ui/index.ts");
2525
});
26+
27+
test("With deprecated moduleResolution: node", () => {
28+
const tsCompilerOptions = {
29+
moduleResolution: "node" as const,
30+
baseUrl: ".",
31+
paths: {
32+
"~/*": ["./src/*"],
33+
},
34+
};
35+
36+
function fileExists(path: string) {
37+
return path === "src/shared/ui/index.ts";
38+
}
39+
40+
expect(
41+
resolveImport(
42+
"~/shared/ui",
43+
"src/pages/home/ui/HomePage.tsx",
44+
tsCompilerOptions,
45+
fileExists,
46+
),
47+
).toBe("src/shared/ui/index.ts");
48+
});

0 commit comments

Comments
 (0)