mirror of
https://github.com/openclaw/openclaw.git
synced 2026-09-28 14:12:28 +08:00
* test: prepare bounded TypeScript child probes Prepare native test children through the invocation-owned compiler before their existing deadlines. Preserve module boundaries for import guards and script entry detection, and keep source-loader contracts explicit. Retain native process isolation, worker lifetimes, assertions, and deadlines. Cover MTS declaration selection in the existing compiler fixture. Also declare the generated fallback plugin fixture as ESM and remove one unused internal script export. * test: prepare remaining worker and tooling fixtures Keep installed tooling at its native package location so prepared probes retain native bindings and relative assets. Preserve existing child deadlines, assertions, and source-layout contracts. * test: assert native CLI delegation before option rejection * test: preserve sparse prepared fixture entry contracts * test: mark prepared budget fixtures as ES modules * test: preserve serialized fixture inputs under type-aware lint * test: prepare sparse wrapper and report fixtures * test: prepare remaining CLI wrapper children * test: complete bounded child fixture preparation
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { build } from "tsdown";
|
|
|
|
export async function prepareCopiedSourceModules(
|
|
root: string,
|
|
entries: string[],
|
|
{ externalModules = {} }: { externalModules?: Readonly<Record<string, URL>> } = {},
|
|
) {
|
|
const { bundles } = await build({
|
|
config: false,
|
|
cwd: root,
|
|
root,
|
|
entry: entries,
|
|
outDir: root,
|
|
unbundle: true,
|
|
format: "esm",
|
|
platform: "node",
|
|
dts: false,
|
|
clean: false,
|
|
treeshake: false,
|
|
...(Object.keys(externalModules).length
|
|
? {
|
|
plugins: [
|
|
{
|
|
name: "copied-fixture-external-modules",
|
|
resolveId(id: string) {
|
|
const target = externalModules[id];
|
|
return target ? { id: target.href, external: "absolute" as const } : null;
|
|
},
|
|
},
|
|
],
|
|
}
|
|
: {}),
|
|
deps: {
|
|
alwaysBundle: (id) =>
|
|
id.startsWith("@openclaw/") &&
|
|
!id.startsWith("@openclaw/fs-safe") &&
|
|
!id.startsWith("@openclaw/proxyline"),
|
|
neverBundle(id, importer) {
|
|
if (externalModules[id]) {
|
|
return false;
|
|
}
|
|
if (/^(?:vitest|vite|tsdown|rolldown|esbuild|typescript)(?:\/|$)/u.test(id)) {
|
|
return true;
|
|
}
|
|
if (!importer || !id.startsWith(".")) {
|
|
return false;
|
|
}
|
|
const target = path.resolve(path.dirname(importer), id);
|
|
// Sparse wrapper fixtures intentionally omit lazy application modules.
|
|
// Leave those imports unresolved; taking that branch must still fail.
|
|
return ![target, target.replace(/\.js$/u, ".ts"), target.replace(/\.mjs$/u, ".mts")].some(
|
|
(candidate) => fs.existsSync(candidate),
|
|
);
|
|
},
|
|
},
|
|
outExtensions: () => ({ js: ".js" }),
|
|
outputOptions: { entryFileNames: "[name].js", chunkFileNames: "[name].js" },
|
|
logLevel: "silent",
|
|
});
|
|
for (const bundle of bundles) {
|
|
await bundle[Symbol.asyncDispose]();
|
|
}
|
|
}
|