mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-11 19:09:20 +00:00
* fix(build): ship NodeNext-resolvable declarations from every package tsc copies relative specifiers verbatim, so packages whose sources use bundler-style extensionless imports (core, inspector) published .d.ts files that a module/moduleResolution nodenext consumer cannot resolve. Core already rewrote its emitted JavaScript for this, but not its declarations. Move that rewrite to scripts/rewrite-relative-import-extensions.mjs, make it cover .d.ts too (adding .js or /index.js, and failing the build when a declaration import has no declaration), and run it after every tsc emit: core, engine, sdk, producer, aws-lambda, gcp-cloud-run and inspector. verify:packed-manifests now typechecks the clean packed consumer with skipLibCheck false and type-only imports of every typed subpath, so an unresolvable import inside a published declaration fails the gate and is attributed to its package. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(ci): allow the moved core rewrite-esm-extensions script deletion Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * ci: rebuild the edit-accuracy bench when the import-extension rewriter changes The package builds now run scripts/rewrite-relative-import-extensions.mjs, so main's edit_accuracy paths filter has to include it (check-edit-accuracy-filter test). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
53 lines
2.4 KiB
JavaScript
53 lines
2.4 KiB
JavaScript
// Builds the inspector for Node and for the page. Bun runs the TypeScript sources directly (package.json "bun").
|
|
import { execFileSync } from "node:child_process";
|
|
import { copyFileSync, readFileSync, rmSync } from "node:fs";
|
|
import { createRequire } from "node:module";
|
|
import { build } from "esbuild";
|
|
import { rewriteRelativeImportExtensions } from "../../scripts/rewrite-relative-import-extensions.mjs";
|
|
|
|
const at = (path) => new URL(path, import.meta.url).pathname;
|
|
const { dependencies } = JSON.parse(readFileSync(at("./package.json"), "utf8"));
|
|
// Declared dependencies stay imports; the workspace's own sources (core, parsers) are bundled in.
|
|
const external = Object.keys(dependencies).filter((name) => !name.startsWith("@hyperframes/"));
|
|
// Bundled CommonJS dependencies call require(); an ES module has none until the banner defines it.
|
|
const banner = {
|
|
js: 'import { createRequire } from "node:module"; const require = createRequire(import.meta.url);',
|
|
};
|
|
const node = { bundle: true, platform: "node", format: "esm", target: "node22", external, banner };
|
|
|
|
await Promise.all([
|
|
build({ ...node, entryPoints: [at("./src/live.ts")], outfile: at("./dist/live.js") }),
|
|
build({ ...node, entryPoints: [at("./src/service.ts")], outfile: at("./dist/service.js") }),
|
|
build({
|
|
...node,
|
|
entryPoints: [at("./src/server.ts")],
|
|
outfile: at("./dist/server.js"),
|
|
banner: { js: `#!/usr/bin/env node\n${banner.js}` },
|
|
plugins: [
|
|
{
|
|
name: "external-service",
|
|
setup(build) {
|
|
build.onResolve({ filter: /^\.\/service$/ }, () => ({
|
|
path: "./service.js",
|
|
external: true,
|
|
}));
|
|
},
|
|
},
|
|
],
|
|
}),
|
|
build({
|
|
entryPoints: [at("./src/liveRuntime.ts")],
|
|
outfile: at("./dist/inspection.js"),
|
|
bundle: true,
|
|
platform: "browser",
|
|
format: "iife",
|
|
}),
|
|
]);
|
|
// Declarations keep the packages/ layout under dist/types, so their relative imports still resolve once packed.
|
|
rmSync(at("./dist/types"), { recursive: true, force: true });
|
|
const tsc = createRequire(import.meta.url).resolve("typescript/bin/tsc");
|
|
execFileSync(process.execPath, [tsc, "-p", at("./tsconfig.types.json")], { stdio: "inherit" });
|
|
// tsc emits declarations for TypeScript only; the element map's JavaScript ships its own.
|
|
copyFileSync(at("./src/elementMap.d.ts"), at("./dist/types/inspector/src/elementMap.d.ts"));
|
|
rewriteRelativeImportExtensions(at("./dist/types"));
|