drizzle-kit 0.18.1-c8247c5 → 0.18.1-c862e6a

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.
package/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env -S node --loader drizzle-kit/loader.mjs -r esbuild-register --no-warnings
1
+ #!/usr/bin/env -S node --loader drizzle-kit/loader.mjs --no-warnings
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -16702,7 +16702,7 @@ var init_mysqlImports = __esm({
16702
16702
  const schemas = [];
16703
16703
  for (let i = 0; i < imports.length; i++) {
16704
16704
  const it = imports[i];
16705
- const i0 = await import(it);
16705
+ const i0 = await import(`drizzle://${it}`);
16706
16706
  const i0values = Object.values(i0);
16707
16707
  i0values.forEach((t) => {
16708
16708
  if (t instanceof import_mysql_core.MySqlTable) {
@@ -17112,7 +17112,7 @@ var init_pgImports = __esm({
17112
17112
  const schemas = [];
17113
17113
  for (let i = 0; i < imports.length; i++) {
17114
17114
  const it = imports[i];
17115
- const i0 = await import(it);
17115
+ const i0 = await import(`drizzle://${it}`);
17116
17116
  const i0values = Object.values(i0);
17117
17117
  i0values.forEach((t) => {
17118
17118
  if ((0, import_pg_core.isPgEnum)(t)) {
@@ -17637,7 +17637,7 @@ var init_sqliteImports = __esm({
17637
17637
  const enums = [];
17638
17638
  for (let i = 0; i < imports.length; i++) {
17639
17639
  const it = imports[i];
17640
- const i0 = await import(it);
17640
+ const i0 = await import(`drizzle://${it}`);
17641
17641
  const i0values = Object.values(i0);
17642
17642
  i0values.forEach((t) => {
17643
17643
  if (t instanceof import_sqlite_core.SQLiteTable) {
@@ -46419,16 +46419,22 @@ var assertPackages = async (...pkgs) => {
46419
46419
  };
46420
46420
  var requiredApiVersion = 4;
46421
46421
  var assertOrmCoreVersion = async () => {
46422
- const { compatibilityVersion } = await import("drizzle-orm/version");
46423
- if (compatibilityVersion && compatibilityVersion === requiredApiVersion)
46424
- return;
46425
- if (!compatibilityVersion || compatibilityVersion < requiredApiVersion) {
46426
- console.log(
46427
- "This version of drizzle-kit requires newer version of drizzle-orm\nPlease update drizzle-orm package to the latest version \u{1F44D}"
46428
- );
46429
- } else {
46422
+ try {
46423
+ const { compatibilityVersion } = await import("drizzle-orm/version");
46424
+ if (compatibilityVersion && compatibilityVersion === requiredApiVersion)
46425
+ return;
46426
+ if (!compatibilityVersion || compatibilityVersion < requiredApiVersion) {
46427
+ console.log(
46428
+ "This version of drizzle-kit requires newer version of drizzle-orm\nPlease update drizzle-orm package to the latest version \u{1F44D}"
46429
+ );
46430
+ } else {
46431
+ console.log(
46432
+ "This version of drizzle-kit is outdated\nPlease update drizzle-kit package to the latest version \u{1F44D}"
46433
+ );
46434
+ }
46435
+ } catch (e) {
46430
46436
  console.log(
46431
- "This version of drizzle-kit is outdated\nPlease update drizzle-kit package to the latest version \u{1F44D}"
46437
+ "Please install latest version of drizzle-orm"
46432
46438
  );
46433
46439
  }
46434
46440
  process.exit(1);
@@ -46495,10 +46501,10 @@ var package_default = {
46495
46501
  ]
46496
46502
  },
46497
46503
  dependencies: {
46504
+ "@esbuild-kit/esm-loader": "^2.5.5",
46498
46505
  camelcase: "^7.0.1",
46499
46506
  chalk: "^5.2.0",
46500
46507
  commander: "^9.4.1",
46501
- "esbuild-register": "^3.4.2",
46502
46508
  glob: "^8.1.0",
46503
46509
  hanji: "^0.0.5",
46504
46510
  "json-diff": "0.9.0",
@@ -46720,10 +46726,8 @@ var drizzleConfigFromFile = async (configPath) => {
46720
46726
  process.exit(1);
46721
46727
  }
46722
46728
  console.log(source_default.grey(`Reading config file '${path3}'`));
46723
- const required = await import(path3);
46729
+ const required = await import(`drizzle://${path3}`);
46724
46730
  const content = required.default ?? required;
46725
- console.log(required);
46726
- console.log(required.default);
46727
46731
  const res = mySqlCliConfigSchema.safeParse(content);
46728
46732
  if (!res.success) {
46729
46733
  console.error(res.error);
@@ -46752,7 +46756,7 @@ var readDrizzleConfig = async (configPath) => {
46752
46756
  process.exit(1);
46753
46757
  }
46754
46758
  console.log(source_default.grey(`Reading config file '${path3}'`));
46755
- const required = await import(path3);
46759
+ const required = await import(`drizzle://${path3}`);
46756
46760
  const content = required.default ?? required;
46757
46761
  return content;
46758
46762
  };
package/loader.mjs CHANGED
@@ -1,13 +1,47 @@
1
- const extensionsRegex = /\.(ts|tsx|mts|cts)$/
1
+ import esbuild from "esbuild";
2
+ import * as path from "path";
3
+ import { readFileSync } from "fs";
4
+
5
+ export function resolve(specifier, context, nextResolve) {
6
+ if (specifier.startsWith("drizzle://")) {
7
+ if (!specifier.endsWith(".ts")) {
8
+ const url = specifier.slice("drizzle://".length).toString();
9
+ return nextResolve(url);
10
+ }
2
11
 
3
- export async function load(url, context, defaultLoad) {
4
- if (extensionsRegex.test(url)) {
5
- const { source } = await defaultLoad(url, { ...context, format: 'module' })
6
12
  return {
7
- ...context,
8
- source: source,
13
+ shortCircuit: true,
14
+ url: specifier,
15
+ };
16
+ }
17
+
18
+ const { parentURL: url } = context;
19
+ const parentURL = url?.startsWith("drizzle://")
20
+ ? new URL(`file://${path.resolve(url.slice("drizzle://".length))}`)
21
+ : url;
22
+
23
+ // Let Node.js handle all other specifiers.
24
+ return nextResolve(specifier, { ...context, parentURL });
25
+ }
26
+
27
+ export async function load(url, context, defaultLoad) {
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")) {
33
+ const source = esbuild.transformSync(file, {
34
+ loader: "ts",
35
+ format: "esm",
36
+ });
37
+ return {
38
+ format: "module",
39
+ shortCircuit: true,
40
+ source: source.code,
41
+ };
9
42
  }
10
43
  }
44
+
11
45
  // let Node.js handle all other URLs
12
- return defaultLoad(url, context, defaultLoad)
13
- }
46
+ return defaultLoad(url, context, defaultLoad);
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.18.1-c8247c5",
3
+ "version": "0.18.1-c862e6a",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
@@ -47,10 +47,10 @@
47
47
  ]
48
48
  },
49
49
  "dependencies": {
50
+ "@esbuild-kit/esm-loader": "^2.5.5",
50
51
  "camelcase": "^7.0.1",
51
52
  "chalk": "^5.2.0",
52
53
  "commander": "^9.4.1",
53
- "esbuild-register": "^3.4.2",
54
54
  "glob": "^8.1.0",
55
55
  "hanji": "^0.0.5",
56
56
  "json-diff": "0.9.0",
package/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env -S node --loader @esbuild-kit/esm-loader --no-warnings
1
+ #!/usr/bin/env -S node --loader @esbuild-kit/esm-loader --no-warnings
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;