From 499aed7b5948ab2be4c0345d7c35dfb5b0403566 Mon Sep 17 00:00:00 2001 From: Boka Date: Wed, 6 Aug 2025 21:37:46 +0200 Subject: [PATCH 1/2] Update alto.ts to be ESM compatible --- src/instances/alto.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/instances/alto.ts b/src/instances/alto.ts index b6aecb1..ff63d4a 100644 --- a/src/instances/alto.ts +++ b/src/instances/alto.ts @@ -3,6 +3,9 @@ import { defineInstance } from '../instance.js' import { execa } from '../processes/execa.js' import { toArgs } from '../utils.js' +import { fileURLToPath } from 'url'; +import { dirname, resolve as pathResolve } from 'path'; + export type AltoParameters = { /** * API version (used for internal Pimlico versioning compatibility). @@ -251,15 +254,10 @@ export const alto = defineInstance((parameters?: AltoParameters) => { name, port: args.port ?? 3000, async start({ port = args.port ?? 3000 }, options) { - const binary = (() => { - if (args.binary) return [args.binary] - const libPath = ( - 'resolve' in import.meta - ? import.meta.resolve('@pimlico/alto').split('file:')[1] - : require.resolve('@pimlico/alto') - )! - return ['node', resolve(libPath, '../cli/alto.js')] - })() + const __filename = fileURLToPath(import.meta.url); + const __dirname = dirname(__filename); + const altoCliPath = pathResolve(__dirname, '../../../@pimlico/alto/esm/cli/alto.js'); + const binary = ['node', altoCliPath]; await process.start(($) => $`${binary} ${toArgs({ port, ...args })}`, { ...options, From 243df1fd12d32d708d9197a9cfcda9a2c694ede3 Mon Sep 17 00:00:00 2001 From: Boka Date: Tue, 12 Aug 2025 00:08:40 +0200 Subject: [PATCH 2/2] Update alto.ts Improved solution --- src/instances/alto.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/instances/alto.ts b/src/instances/alto.ts index ff63d4a..ca1df40 100644 --- a/src/instances/alto.ts +++ b/src/instances/alto.ts @@ -4,7 +4,6 @@ import { execa } from '../processes/execa.js' import { toArgs } from '../utils.js' import { fileURLToPath } from 'url'; -import { dirname, resolve as pathResolve } from 'path'; export type AltoParameters = { /** @@ -254,9 +253,8 @@ export const alto = defineInstance((parameters?: AltoParameters) => { name, port: args.port ?? 3000, async start({ port = args.port ?? 3000 }, options) { - const __filename = fileURLToPath(import.meta.url); - const __dirname = dirname(__filename); - const altoCliPath = pathResolve(__dirname, '../../../@pimlico/alto/esm/cli/alto.js'); + const altoModuleUrl = await import.meta.resolve('@pimlico/alto/esm/cli/alto.js'); + const altoCliPath = fileURLToPath(altoModuleUrl); const binary = ['node', altoCliPath]; await process.start(($) => $`${binary} ${toArgs({ port, ...args })}`, {