trpc-gen-python 0.1.2 → 0.1.3

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/dist/bin.js +8 -7
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -2,19 +2,20 @@
2
2
  import { spawn } from "child_process";
3
3
  import { dirname, join } from "path";
4
4
  import { fileURLToPath } from "url";
5
- import { createRequire } from "module";
6
5
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
- const require = createRequire(import.meta.url);
8
6
  // Resolve tsx loader path using Node's module resolution
9
- // This works regardless of where npm installs dependencies
7
+ // tsx's main export points to loader.mjs, so resolving 'tsx' gives us the loader
10
8
  let tsxLoader;
11
9
  try {
12
- // Try to resolve tsx from this package's dependencies
13
- tsxLoader = require.resolve("tsx/dist/loader.mjs");
10
+ // Use import.meta.resolve (ESM native way)
11
+ const tsxUrl = await import.meta.resolve("tsx");
12
+ tsxLoader = fileURLToPath(tsxUrl);
14
13
  }
15
14
  catch {
16
- // Fallback: look in node_modules relative to this file
17
- tsxLoader = join(__dirname, "..", "node_modules", "tsx", "dist", "loader.mjs");
15
+ // Fallback for older Node versions or if resolution fails
16
+ // Try looking in parent node_modules (flat npm structure)
17
+ const parentNodeModules = join(__dirname, "..", "..", "tsx", "dist", "loader.mjs");
18
+ tsxLoader = parentNodeModules;
18
19
  }
19
20
  const cliPath = join(__dirname, "cli.js");
20
21
  const child = spawn(process.execPath, ["--import", tsxLoader, cliPath, ...process.argv.slice(2)], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trpc-gen-python",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Generate Python (Pydantic + httpx) clients from tRPC routers",
5
5
  "type": "module",
6
6
  "main": "./dist/bin.js",