mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 10:14:01 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
// Tsdown config tests protect package artifact build contracts.
|
|
import fs from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
import config from "../../tsdown.config.ts";
|
|
|
|
const configs = Array.isArray(config) ? config : [config];
|
|
|
|
type TsdownConfig = (typeof configs)[number];
|
|
type OutExtensions = NonNullable<TsdownConfig["outExtensions"]>;
|
|
|
|
describe("tsdown config", () => {
|
|
it.each(["tsdown.config.ts", "tsdown.ai.config.ts"])(
|
|
"keeps %s free of runtime imports from tsdown",
|
|
(configPath) => {
|
|
const source = fs.readFileSync(configPath, "utf8");
|
|
expect(source).not.toMatch(/^import(?!\s+type\b).*from ["']tsdown["'];?$/mu);
|
|
},
|
|
);
|
|
|
|
it("enables declaration output explicitly for package artifact builds", () => {
|
|
expect(configs).not.toHaveLength(0);
|
|
expect(configs.map((entry) => entry.dts)).toEqual(configs.map(() => true));
|
|
});
|
|
|
|
it("keeps node package artifacts on the declared js and dts extensions", () => {
|
|
const nodePackageConfigs = configs.filter((entry) => entry.fixedExtension === false);
|
|
expect(nodePackageConfigs).not.toHaveLength(0);
|
|
|
|
const context = {
|
|
format: "es",
|
|
options: {},
|
|
pkgType: "module",
|
|
} as Parameters<OutExtensions>[0];
|
|
|
|
for (const entry of nodePackageConfigs) {
|
|
expect(entry.outExtensions?.(context)).toEqual({ js: ".js", dts: ".d.ts" });
|
|
}
|
|
});
|
|
});
|