Skip to content

Commit f661f01

Browse files
authored
build: minify sealed worker artifact (#132125)
1 parent b4833bf commit f661f01

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/infra/tsdown-config.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type TsdownConfigEntry = {
1717
};
1818
entry?: Record<string, string> | string[];
1919
inputOptions?: TsdownInputOptions;
20+
minify?: unknown;
2021
outDir?: string;
2122
plugins?: Array<{ name?: string }>;
2223
};
@@ -94,6 +95,22 @@ function readAgentAuthDiscoverySource(): string {
9495
}
9596

9697
describe("tsdown config", () => {
98+
it("minifies only the sealed deploy worker while preserving runtime names", () => {
99+
const configs = asConfigArray(tsdownConfig);
100+
const deployWorker = configs.find((config) => entryKeys(config).includes("worker/worker"));
101+
const rsyncReceiver = configs.find((config) =>
102+
entryKeys(config).includes("worker/workspace-rsync-receiver"),
103+
);
104+
105+
expect(deployWorker?.minify).toEqual({
106+
codegen: true,
107+
compress: true,
108+
mangle: { keepNames: true },
109+
});
110+
expect(rsyncReceiver?.minify).toBeUndefined();
111+
expect(requireUnifiedDistGraph().minify).toBeUndefined();
112+
});
113+
97114
it.each([
98115
{
99116
exportName: "OPENCLAW_STATE_SCHEMA_SQL",

‎tsdown.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ function workerDeployBuildConfig(): UserConfig {
209209
onlyBundle: false,
210210
},
211211
fixedExtension: false,
212+
minify: { codegen: true, compress: true, mangle: { keepNames: true } },
212213
outExtensions: () => ({ js: ".mjs", dts: ".d.ts" }),
213214
outputOptions: { codeSplitting: false, assetFileNames: "worker/[name][extname]" },
214215
plugins: [createStateSchemaInlinePlugin(), createWorkerDeployBuildPlugin()],

0 commit comments

Comments
 (0)