fix(server): start the production bundle again (#7)
The bundled server crashed at startup with "Named export 'utils' not found": ssh2 is CommonJS and Node's ESM loader does not expose `utils` as a named export. Vitest resolves the module differently, so the unit tests passed. Import ssh2 through its default export instead. New test builds the bundle with the package's own esbuild command and starts it with Node until /api/health answers.
This commit is contained in:
@@ -14,7 +14,9 @@ import {
|
||||
realpath,
|
||||
} from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { utils } from "ssh2";
|
||||
// ssh2 is CommonJS: Node's ESM loader cannot see `utils` as a named export (see test/bundle.test.ts).
|
||||
import ssh2 from "ssh2";
|
||||
const { utils } = ssh2;
|
||||
import type {
|
||||
HostCredentialInput,
|
||||
HostCredentialMetadata,
|
||||
|
||||
@@ -2,7 +2,9 @@ import { readFile, writeFile, rename, rm } from "node:fs/promises";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import path from "node:path";
|
||||
import { parseDocument, isSeq, isMap } from "yaml";
|
||||
import { utils } from "ssh2";
|
||||
// ssh2 is CommonJS: Node's ESM loader cannot see `utils` as a named export (see test/bundle.test.ts).
|
||||
import ssh2 from "ssh2";
|
||||
const { utils } = ssh2;
|
||||
import {
|
||||
shellQuote,
|
||||
type HostActionRequest,
|
||||
|
||||
Reference in New Issue
Block a user