Skip to content

Commit

Permalink
Support a deprecated module resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed Jun 8, 2024
1 parent 540cfc8 commit d6d1d35
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@feature-sliced/filesystem",
"version": "2.2.3",
"version": "2.2.4",
"description": "A set of utilities for locating and working with FSD roots in the file system.",
"scripts": {
"build": "tsup src/index.ts --dts --format esm,cjs --clean",
Expand Down
8 changes: 6 additions & 2 deletions src/resolve-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export function resolveImport(

const imperfectKeys = {
module: ts.ModuleKind,
moduleResolution: ts.ModuleResolutionKind,
moduleResolution: {
...ts.ModuleResolutionKind,
node: ts.ModuleResolutionKind.Node10,
},
moduleDetection: ts.ModuleDetectionKind,
newLine: ts.NewLineKind,
target: ts.ScriptTarget,
Expand Down Expand Up @@ -90,7 +93,8 @@ export interface ImperfectCompilerOptions
module?: ts.ModuleKind | keyof typeof ts.ModuleKind;
moduleResolution?:
| ts.ModuleResolutionKind
| keyof typeof ts.ModuleResolutionKind;
| keyof typeof ts.ModuleResolutionKind
| "node";
moduleDetection?:
| ts.ModuleDetectionKind
| keyof typeof ts.ModuleDetectionKind;
Expand Down
23 changes: 23 additions & 0 deletions src/specs/resolve-import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,26 @@ test("Basic", () => {
),
).toBe("src/shared/ui/index.ts");
});

test("With deprecated moduleResolution: node", () => {
const tsCompilerOptions = {
moduleResolution: "node" as const,
baseUrl: ".",
paths: {
"~/*": ["./src/*"],
},
};

function fileExists(path: string) {
return path === "src/shared/ui/index.ts";
}

expect(
resolveImport(
"~/shared/ui",
"src/pages/home/ui/HomePage.tsx",
tsCompilerOptions,
fileExists,
),
).toBe("src/shared/ui/index.ts");
});

0 comments on commit d6d1d35

Please sign in to comment.