Files
hyperframes/packages/cli/tsup.config.ts
Jerrai 1116077dab fix(cli): capture treats only 192.0.0.0/24 and 192.0.2.0/24 as reserved, via one shared list (#6853)
* fix(cli): capture's public-address check uses the engine's list; 192.0/16 is not all reserved

Only 192.0.0.0/24 and 192.0.2.0/24 are special-use. The capture proxy blocked all of
192.0.0.0/16, so sites on WordPress VIP (192.0.64.0/18, e.g. nasa.gov at 192.0.66.108)
failed every capture with net::ERR_TUNNEL_CONNECTION_FAILED. isPublicIPv4 now reads the
engine's isBlockedNetworkHost, so capture and asset downloads share one list.

— Jerrai (cutroom-debug)

* refactor(engine): one special-use network list, in a light subpath capture imports

Importing all of @hyperframes/engine into capture's publicNetwork slowed the lookup child's
start-up past publicNetwork.process.test's 6 s mid-lookup exit. The list and
isBlockedNetworkHost move to engine/src/utils/networkPolicy.ts, exported as
@hyperframes/engine/network-policy; urlDownloader and the engine index read it there.

— Jerrai (cutroom-debug)

* test(engine): pin 192.0.0.0/24 and 192.0.2.0/24 blocked, the rest of 192.0/16 public

— Jerrai (cutroom-debug)

* fix(cli): alias the engine's network-policy subpath in the CLI bundle

esbuild's root alias rewrote @hyperframes/engine/network-policy to src/index.ts/network-policy;
the exact-subpath list now carries it. The publicNetwork docstring is cut to keep the file's
comment share under its base.

— Jerrai (cutroom-debug)
2026-10-30 16:21:34 +00:00

117 lines
4.0 KiB
TypeScript

import { defineConfig } from "tsup";
import { resolve } from "node:path";
import { readFileSync } from "node:fs";
import { sourceAliases } from "../../scripts/package-subpaths.mjs";
const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf-8")) as {
version: string;
};
const producerPkg = JSON.parse(
readFileSync(new URL("../producer/package.json", import.meta.url), "utf-8"),
) as { version: string };
export default defineConfig({
entry: {
cli: "src/cli.ts",
fontLocalizeCli: "src/fontLocalizeCli.ts",
runtimeVersion: "src/runtimeVersion.ts",
hangReport: "src/hangReport.ts",
warmCheck: "src/warmCheck.ts",
warmCheckClient: "src/warmCheckClient.ts",
renderSetupWorker: "src/renderSetupWorker.ts",
backgroundChecksWorker: "src/backgroundChecksWorker.ts",
sherpaWorker: "src/whisper/sherpaWorker.ts",
shaderTransitionWorker: "../producer/src/services/shaderTransitionWorker.ts",
api: "src/api.ts",
},
format: ["esm"],
outDir: "dist",
target: "node22",
platform: "node",
bundle: true,
splitting: true,
sourcemap: false,
// Types for the `./api` export only; the other entries are programs, not libraries.
dts: { entry: { api: "src/api.ts" } },
clean: true,
banner: {
js: `import { createRequire as __hf_createRequire } from "node:module";
import { fileURLToPath as __hf_fileURLToPath } from "node:url";
import { dirname as __hf_dirname } from "node:path";
var require = __hf_createRequire(import.meta.url);
var __filename = __hf_fileURLToPath(import.meta.url);
var __dirname = __hf_dirname(__filename);`,
},
external: [
"puppeteer-core",
"undici",
"puppeteer",
"@puppeteer/browsers",
// Native module — its platform binary (@img/sharp-<os>-<arch>) must be
// resolved from node_modules at runtime, never bundled. Loaded lazily by
// the capture pipeline; runtime resolution comes from the `dependencies`
// entry in package.json.
"sharp",
"open",
"hono",
"hono/*",
"@hono/node-server",
"adm-zip",
"esbuild",
"giget",
"postcss",
// aws-lambda transitively pulls @aws-sdk/* + @smithy/* which include
// .browser.js conditional exports esbuild can't bundle cleanly into
// a node binary. Keep it external; the lambda subverb files dynamic-
// import it only when the user runs `hyperframes lambda *`, so the
// CLI's cold start doesn't load it. Runtime resolution comes from
// @hyperframes/aws-lambda being a `dependencies` entry in package.json.
"@hyperframes/aws-lambda",
"@hyperframes/aws-lambda/sdk",
// Same treatment for the GCP adapter: the cloudrun subverb files
// dynamic-import `@hyperframes/gcp-cloud-run/sdk` only when the user runs
// `hyperframes cloudrun *`. Keep it external; runtime resolution comes
// from the `dependencies`/workspace entry, not the bundled CLI.
"@hyperframes/gcp-cloud-run",
"@hyperframes/gcp-cloud-run/sdk",
"@hyperframes/gcp-cloud-run/terraform",
],
noExternal: [
"@hyperframes/core",
"@hyperframes/parsers",
"@hyperframes/studio-server",
"@hyperframes/lint",
"@hyperframes/producer",
"@hyperframes/engine",
"@hyperframes/inspector",
"@clack/prompts",
"@clack/core",
"picocolors",
"linkedom",
"sisteransi",
"is-unicode-supported",
"citty",
],
define: {
__CLI_VERSION__: JSON.stringify(pkg.version),
__PRODUCER_VERSION__: JSON.stringify(producerPkg.version),
},
esbuildOptions(options) {
options.alias = {
// Exact subpaths are generated from the same contracts as package
// exports, avoiding esbuild's root-alias prefix substitution trap.
...sourceAliases(resolve(__dirname, "../producer"), [".", "./distributed"]),
...sourceAliases(resolve(__dirname, "../engine"), [
".",
"./chrome-host-ceiling",
"./chrome-startup",
"./network-policy",
"./shader-transitions",
"./system-memory",
"./wsl-host",
]),
};
options.loader = { ...options.loader, ".browser.js": "text" };
},
});