From 44da6d2e9067d5ac4464b6e89872701254266694 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 14 Apr 2026 03:17:46 +0100 Subject: [PATCH] build: prune runtime dependency type declarations --- scripts/stage-bundled-plugin-runtime-deps.mjs | 2 +- test/scripts/stage-bundled-plugin-runtime-deps.test.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/stage-bundled-plugin-runtime-deps.mjs b/scripts/stage-bundled-plugin-runtime-deps.mjs index 419e690c4a9..68b1abc4fbf 100644 --- a/scripts/stage-bundled-plugin-runtime-deps.mjs +++ b/scripts/stage-bundled-plugin-runtime-deps.mjs @@ -62,7 +62,7 @@ function dependencyVersionSatisfied(spec, installedVersion) { return semverSatisfies(installedVersion, spec, { includePrerelease: false }); } -const defaultStagedRuntimeDepGlobalPruneSuffixes = [".map"]; +const defaultStagedRuntimeDepGlobalPruneSuffixes = [".d.ts", ".map"]; const defaultStagedRuntimeDepPruneRules = new Map([ // Type declarations only; runtime resolves through lib/es entrypoints. ["@larksuiteoapi/node-sdk", { paths: ["types"] }], diff --git a/test/scripts/stage-bundled-plugin-runtime-deps.test.ts b/test/scripts/stage-bundled-plugin-runtime-deps.test.ts index 9b5d7d8f857..1363a19cf3b 100644 --- a/test/scripts/stage-bundled-plugin-runtime-deps.test.ts +++ b/test/scripts/stage-bundled-plugin-runtime-deps.test.ts @@ -189,7 +189,7 @@ describe("stageBundledPluginRuntimeDeps", () => { ).toBe("module.exports = 'transitive';\n"); }); - it("removes source maps from staged runtime dependencies", () => { + it("removes global non-runtime suffixes from staged runtime dependencies", () => { const { pluginDir, repoRoot } = createBundledPluginFixture({ packageJson: { name: "@openclaw/fixture-plugin", @@ -206,11 +206,13 @@ describe("stageBundledPluginRuntimeDeps", () => { "utf8", ); fs.writeFileSync(path.join(directDir, "index.js"), "module.exports = 1;\n", "utf8"); + fs.writeFileSync(path.join(directDir, "index.d.ts"), "export {};\n", "utf8"); fs.writeFileSync(path.join(directDir, "index.js.map"), '{ "version": 3 }\n', "utf8"); stageBundledPluginRuntimeDeps({ cwd: repoRoot }); expect(fs.existsSync(path.join(pluginDir, "node_modules", "direct", "index.js"))).toBe(true); + expect(fs.existsSync(path.join(pluginDir, "node_modules", "direct", "index.d.ts"))).toBe(false); expect(fs.existsSync(path.join(pluginDir, "node_modules", "direct", "index.js.map"))).toBe( false, );