@nitrogql/esbuild-register
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -36,3 +36,3 @@ "use strict"; | ||
function register() { | ||
// ESM loader (>= Node 20.6.0) | ||
// ESM loader (>= Node 20.6.0 or >= 18.19.0) | ||
// @ts-expect-error | ||
@@ -44,3 +44,3 @@ if (nodeModule.register) { | ||
} | ||
// Node.js' loader (>= Node 20.6.0) still depends on Module._resolveFilename, | ||
// Node.js' loader (>= Node 20.6.0 or >= Node 18.19.0) still depends on Module._resolveFilename, | ||
// so we need to patch it as well. | ||
@@ -47,0 +47,0 @@ { |
@@ -15,5 +15,7 @@ "use strict"; | ||
const nodeVersion = process.versions.node.split(".").map((x) => Number(x)); | ||
const nodeSupportsModuleRegisterAPI = nodeVersion[0] > 20 || | ||
(nodeVersion[0] === 20 && nodeVersion[1] >= 6) || | ||
(nodeVersion[0] === 18 && nodeVersion[1] >= 19); | ||
async function runNode(path) { | ||
// >= Node 20.6.0 | ||
if (nodeVersion[0] > 20 || (nodeVersion[0] === 20 && nodeVersion[1] >= 6)) { | ||
if (nodeSupportsModuleRegisterAPI) { | ||
const { stdout } = await (0, node_util_1.promisify)(node_child_process_1.execFile)(process.execPath, ["--import", registerMJS.toString(), path], {}); | ||
@@ -20,0 +22,0 @@ return stdout; |
{ | ||
"name": "@nitrogql/esbuild-register", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Uses esbuild to run TypeScript files directly with Node.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -9,3 +9,3 @@ # `@nitrogql/esbuild-register` | ||
### Node.js >= 20.6.0 | ||
### Node.js >= 20.6.0 or >= 18.19.0 | ||
@@ -16,3 +16,3 @@ ```sh | ||
### Node.js < 20.6.0 | ||
### Node.js < 20.6.0 and < 18.19.0 | ||
@@ -19,0 +19,0 @@ ```sh |
@@ -11,3 +11,3 @@ import * as nodeModule from "node:module"; | ||
export function register() { | ||
// ESM loader (>= Node 20.6.0) | ||
// ESM loader (>= Node 20.6.0 or >= 18.19.0) | ||
// @ts-expect-error | ||
@@ -20,3 +20,3 @@ if (nodeModule.register) { | ||
// Node.js' loader (>= Node 20.6.0) still depends on Module._resolveFilename, | ||
// Node.js' loader (>= Node 20.6.0 or >= Node 18.19.0) still depends on Module._resolveFilename, | ||
// so we need to patch it as well. | ||
@@ -23,0 +23,0 @@ { |
@@ -14,6 +14,9 @@ import path from "node:path"; | ||
]; | ||
const nodeSupportsModuleRegisterAPI = | ||
nodeVersion[0] > 20 || | ||
(nodeVersion[0] === 20 && nodeVersion[1] >= 6) || | ||
(nodeVersion[0] === 18 && nodeVersion[1] >= 19); | ||
export async function runNode(path: string): Promise<string> { | ||
// >= Node 20.6.0 | ||
if (nodeVersion[0] > 20 || (nodeVersion[0] === 20 && nodeVersion[1] >= 6)) { | ||
if (nodeSupportsModuleRegisterAPI) { | ||
const { stdout } = await promisify(execFile)( | ||
@@ -20,0 +23,0 @@ process.execPath, |
Sorry, the diff of this file is not supported yet
139769
2454