drizzle-kit 0.18.1-1be6e92 → 0.18.1-2ed41af

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 (2) hide show
  1. package/loader.mjs +39 -0
  2. package/package.json +1 -1
package/loader.mjs ADDED
@@ -0,0 +1,39 @@
1
+ import esbuild from "esbuild";
2
+ import { readFileSync } from "fs";
3
+
4
+ export function resolve(specifier, context, nextResolve) {
5
+ if (specifier.startsWith("drizzle://")) {
6
+ if (!specifier.endsWith(".ts")) {
7
+ const url = specifier.slice("drizzle://".length).toString();
8
+ return nextResolve(url);
9
+ }
10
+ return {
11
+ shortCircuit: true,
12
+ url: specifier,
13
+ };
14
+ }
15
+
16
+ // Let Node.js handle all other specifiers.
17
+ return nextResolve(specifier);
18
+ }
19
+
20
+ export async function load(url, context, defaultLoad) {
21
+ if (url.startsWith("drizzle://")) {
22
+ const path = url.slice("drizzle://".length).trim();
23
+ const file = readFileSync(path, "utf-8");
24
+ if (path.endsWith(".ts") || path.endsWith(".mts")) {
25
+ const source = esbuild.transformSync(file, {
26
+ loader: "ts",
27
+ format: "esm",
28
+ });
29
+ return {
30
+ format: "module",
31
+ shortCircuit: true,
32
+ source: source.code,
33
+ };
34
+ }
35
+ }
36
+
37
+ // let Node.js handle all other URLs
38
+ return defaultLoad(url, context, defaultLoad);
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.18.1-1be6e92",
3
+ "version": "0.18.1-2ed41af",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",