-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsup.config.ts
62 lines (56 loc) · 1.58 KB
/
tsup.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { readFile } from "node:fs/promises";
import { resolve } from "node:path";
import { defineConfig } from "tsup";
const getLocalDeps = async (
packagePath: string,
done: Set<string> = new Set()
): Promise<string[]> => {
if (done.has(packagePath)) {
return [];
}
// eslint-disable-next-line fp/no-unused-expression -- Being mutable on purpose
done.add(packagePath);
const { dependencies = {}, devDependencies = {} } = JSON.parse(
await readFile(packagePath, {
encoding: "utf8",
})
) as {
dependencies?: { [dependency: string]: string };
devDependencies?: { [devDependencies: string]: string };
};
const localDependencies = Object.keys({
...dependencies,
...devDependencies,
})
.filter((dep) => dep.startsWith("@standard-configs/"))
.map((dep) => dep.replace("@standard-configs/", ""));
return [
...new Set([
...localDependencies.map((dep) => `../${dep}/src`),
...(
await Promise.all(
localDependencies.map(async (dep) =>
getLocalDeps(
resolve(process.cwd(), "..", dep, "package.json"),
done
)
)
)
).flat(),
]),
];
};
export default defineConfig(
async ({
// HACK If the cli options are defined, tsup refuses to let me override them. So I'm using `--no-dts` so I can define `--watch`
dts,
}) => ({
entry: ["src/index.ts"],
dts: true,
skipNodeModulesBundle: true,
watch:
dts === false
? [".", ...(await getLocalDeps(resolve(process.cwd(), "package.json")))]
: false,
})
);