drizzle-kit 0.20.0-c31f6ba → 0.20.0-ca89eb7

Sign up to get free protection for your applications and to get access to all the features.
package/loader.mjs DELETED
@@ -1,57 +0,0 @@
1
- import esbuild from "esbuild";
2
- import * as path from "path";
3
- import { readFileSync } from "fs";
4
-
5
- const parse = (it) => {
6
- if (!it) return { drizzle: false };
7
-
8
- if (it.endsWith("__drizzle__")) {
9
- const offset = it.startsWith("file://") ? "file://".length : 0;
10
- const clean = it.slice(offset, -"__drizzle__".length);
11
- return { drizzle: true, clean, original: it };
12
- }
13
- return { drizzle: false, clean: it };
14
- };
15
-
16
- export function resolve(specifier, context, nextResolve) {
17
- const { drizzle, clean } = parse(specifier);
18
- if (drizzle && !clean.endsWith(".ts") && !clean.endsWith(".mts")) {
19
- return nextResolve(clean);
20
- }
21
-
22
- if (drizzle) {
23
- return {
24
- shortCircuit: true,
25
- url: `file://${specifier}`,
26
- };
27
- }
28
-
29
- const parsedParent = parse(context.parentURL);
30
- const parentURL = parsedParent.drizzle
31
- ? new URL(`file://${path.resolve(parsedParent.clean)}`)
32
- : context.parentURL;
33
-
34
- // Let Node.js handle all other specifiers.
35
- return nextResolve(specifier, { ...context, parentURL });
36
- }
37
-
38
- export async function load(url, context, defaultLoad) {
39
- const { drizzle, clean } = parse(url);
40
- if (drizzle) {
41
- const file = readFileSync(clean, "utf-8");
42
- if (clean.endsWith(".ts") || clean.endsWith(".mts")) {
43
- const source = esbuild.transformSync(file, {
44
- loader: "ts",
45
- format: "esm",
46
- });
47
- return {
48
- format: "module",
49
- shortCircuit: true,
50
- source: source.code,
51
- };
52
- }
53
- }
54
-
55
- // let Node.js handle all other URLs
56
- return defaultLoad(url, context, defaultLoad);
57
- }