feat: update to jiti v2 · unjs/untyped@6c35c70 · GitHub
Skip to content

Commit 6c35c70

Browse files
committed
feat: update to jiti v2
1 parent c4ede69 commit 6c35c70

4 files changed

Lines changed: 62 additions & 58 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion

pnpm-lock.yaml

Lines changed: 42 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/loader/loader.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { defu } from "defu";
2-
import jiti from "jiti";
3-
import type { JITIOptions } from "jiti";
2+
import { createJiti, type JitiOptions } from "jiti";
43
import { resolveSchema } from "../schema";
5-
import type { Schema } from "../types";
4+
import type { InputObject, Schema } from "../types";
65
import untypedPlugin from "./babel";
76

87
export interface LoaderOptions {
9-
jiti?: JITIOptions;
8+
jiti?: JitiOptions;
109
defaults?: Record<string, any>;
1110
ignoreDefaults?: boolean;
1211
}
@@ -15,21 +14,19 @@ export async function loadSchema(
1514
entryPath: string,
1615
options: LoaderOptions = {},
1716
): Promise<Schema> {
18-
const _jitiRequire = jiti(
17+
const jiti = createJiti(
1918
process.cwd(),
2019
defu(options.jiti, {
21-
esmResolve: true,
2220
interopDefault: true,
2321
transformOptions: {
2422
babel: {
2523
plugins: [[untypedPlugin, { experimentalFunctions: true }]],
2624
},
2725
},
28-
}),
26+
} satisfies JitiOptions),
2927
);
3028

31-
const resolvedEntryPath = _jitiRequire.resolve(entryPath);
32-
const rawSchema = _jitiRequire(resolvedEntryPath);
29+
const rawSchema = await jiti.import(entryPath) as InputObject;
3330
const schema = await resolveSchema(rawSchema, options.defaults, {
3431
ignoreDefaults: options.ignoreDefaults,
3532
});

tsconfig.json

Lines changed: 13 additions & 6 deletions

0 commit comments

Comments
 (0)