-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
126 lines (123 loc) · 3.46 KB
/
Copy pathtsdown.config.ts
File metadata and controls
126 lines (123 loc) · 3.46 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import type { UserConfig } from "tsdown";
import { defineConfig } from "tsdown";
const sharedOptions = {
clean: true,
format: ["esm"],
outputOptions: {
codeSplitting: false,
},
publint: true,
shims: true,
} satisfies UserConfig;
/**
* Every shipped entry, in one place. The unused-dependency check builds all of
* them together so a dependency used by any single entry counts as used.
*/
const entries = {
"cli": "src/cli/index.ts",
"formatter-agents": "src/formatter-agents.ts",
"index": "src/index.ts",
"lint-cli": "src/lint-cli/index.ts",
"lint-ignored": "src/lint-cli/ignored-child.ts",
"oxlint": "src/oxlint/index.ts",
} satisfies Record<string, string>;
export default defineConfig([
{
...sharedOptions,
deps: {
alwaysBundle: [
// https://github.com/antfu/eslint-config-flat-gitignore/issues/18
"eslint-config-flat-gitignore",
// Bundled to ship patches/eslint-plugin-yml.patch
"eslint-plugin-yml",
],
neverBundle: [
/^@typescript-eslint\//,
/^@eslint-react\//,
/^@eslint-community\//,
"zod",
"type-fest",
"eslint-visitor-keys",
"eslint-plugin-erasable-syntax-only",
"cached-factory",
],
onlyBundle: [
"eslint-config-flat-gitignore",
"@eslint/compat",
// eslint-plugin-yml (see alwaysBundle) and its transitive tree
"eslint-plugin-yml",
"@eslint/plugin-kit",
// cspell:disable-next-line
"@ota-meshi/ast-token-store",
"diff-sequences",
"escape-string-regexp",
// cspell:disable-next-line
"levn",
"natural-compare",
"prelude-ls",
"type-check",
],
},
entry: [entries.index],
},
{
...sharedOptions,
// Source the CLI entry directly from the file that runs the yargs
// instance. A barrel (`src/cli.ts`) would tree-shake the top-level
// `void instance.argv` side effect away, emitting an empty
// `dist/cli.mjs`.
entry: { cli: entries.cli },
},
{
...sharedOptions,
// Shipped at dist/formatter-agents.mjs; the isentinel-lint CLI resolves
// this exact path to pass it to `eslint --format`.
entry: { "formatter-agents": entries["formatter-agents"] },
},
{
...sharedOptions,
// The lint runner shells out to the consumer's local eslint/oxlint and
// resolves them at runtime, so its runtime deps stay external.
entry: { "lint-cli": entries["lint-cli"] },
},
{
...sharedOptions,
// Shipped at dist/lint-ignored.mjs; the lint runner spawns this exact
// path to ask the consumer's ESLint which targets it ignores.
entry: { "lint-ignored": entries["lint-ignored"] },
},
{
...sharedOptions,
deps: {
neverBundle: [
/^@typescript-eslint\//,
/^@eslint-react\//,
/^@eslint-community\//,
"zod",
"type-fest",
"eslint-visitor-keys",
"eslint-plugin-erasable-syntax-only",
"cached-factory",
"oxlint",
],
},
entry: { oxlint: entries.oxlint },
},
{
// Dependency-usage check only: unplugin-unused inspects a single
// rolldown graph, so a dependency imported by only one entry looks
// unused to every other entry's build. Bundling all entries at once is
// the only way it sees the whole picture. Nothing here is shipped, so
// the output goes to a cache dir, declarations are skipped, and no
// dependency is bundled - the plugin only needs to read our own
// sources to spot the imports.
clean: true,
deps: { neverBundle: true },
dts: false,
entry: entries,
format: ["esm"],
outDir: "node_modules/.cache/tsdown-unused",
publint: false,
unused: { level: "warning" },
},
]);