drizzle-kit 0.19.2-e313bce → 0.19.2-f1211c0

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.
Files changed (4) hide show
  1. package/index.cjs +6059 -446
  2. package/loader.mjs +15 -25
  3. package/package.json +1 -1
  4. package/utils.js +10831 -10817
package/loader.mjs CHANGED
@@ -2,44 +2,34 @@ import esbuild from "esbuild";
2
2
  import * as path from "path";
3
3
  import { readFileSync } from "fs";
4
4
 
5
- const parse = (it) => {
6
- if (!it) return { drizzle: false };
7
-
8
- if (it.endsWith("__drizzle__")) {
9
- const offset = "file://".length;
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
5
  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
- }
6
+ if (specifier.startsWith("__drizzle__")) {
7
+ if (!specifier.endsWith(".ts")) {
8
+ const url = specifier.slice("__drizzle__".length).toString();
9
+ return nextResolve(url);
10
+ }
21
11
 
22
- if (drizzle) {
23
12
  return {
24
13
  shortCircuit: true,
25
- url: `file://${specifier}`,
14
+ url: specifier,
26
15
  };
27
16
  }
28
17
 
29
- const parsedParent = parse(context.parentURL);
30
- const parentURL = parsedParent.drizzle
31
- ? new URL(`file://${path.resolve(parsedParent.clean)}`)
32
- : context.parentURL;
18
+ const { parentURL: url } = context;
19
+ const parentURL = url?.startsWith("__drizzle__")
20
+ ? new URL(`file://${path.resolve(url.slice("__drizzle__".length))}`)
21
+ : url;
33
22
 
34
23
  // Let Node.js handle all other specifiers.
35
24
  return nextResolve(specifier, { ...context, parentURL });
36
25
  }
37
26
 
38
27
  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")) {
28
+ if (url.startsWith("__drizzle__")) {
29
+
30
+ const path = url.slice("__drizzle__".length).trim();
31
+ const file = readFileSync(path, "utf-8");
32
+ if (path.endsWith(".ts") || path.endsWith(".mts")) {
43
33
  const source = esbuild.transformSync(file, {
44
34
  loader: "ts",
45
35
  format: "esm",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.19.2-e313bce",
3
+ "version": "0.19.2-f1211c0",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",