diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 00000000..a2cb16ce --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,8 @@ +// The library entry retains its existing import-time execution and rejection behaviour. +// This CLI-only boundary reports a concise diagnostic and a nonzero exit status. +try { + await import('./index.js'); +} catch (error) { + console.error(error instanceof Error ? error.message : String(error)); + process.exitCode = 1; +} diff --git a/vite.config.ts b/vite.config.ts index 6f31423a..71fef02f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -52,7 +52,8 @@ const config: ReturnType = defineConfig({ // integration-bundled-binary.test.ts copies only this file into an // isolated tempdir with no node_modules, so every runtime `dependency` // has to be bundled in, not left external. - entry: "src/index.ts", + entry: "src/cli.ts", + outputOptions: { entryFileNames: "index.js", codeSplitting: false }, platform: "node", outDir: "dist/bin", // tsdown auto-enables declaration output repo-wide because @@ -70,7 +71,6 @@ const config: ReturnType = defineConfig({ // binary with no node_modules to resolve sibling chunks from. Keep this // off even when no current dependency lazy-loads: it is what stops the // single-file invariant from depending on which packages happen to. - outputOptions: { codeSplitting: false }, // Preserves the shebang + __filename/__dirname/require ESM-interop // shim scripts/esbuild.mjs's banner used to inject. banner: `#!/usr/bin/env node