Skip to content

Commit e91eea3

Browse files
authored
Fix rsbuild Plugin (#1227)
1 parent 7a2c991 commit e91eea3

File tree

7 files changed

+16
-5
lines changed

7 files changed

+16
-5
lines changed

packages/knip/fixtures/plugins/rsbuild/entry-2.ts

Whitespace-only changes.

packages/knip/fixtures/plugins/rsbuild/entry-3.ts

Whitespace-only changes.

packages/knip/fixtures/plugins/rsbuild/entry-4.ts

Whitespace-only changes.

packages/knip/fixtures/plugins/rsbuild/rsbuild.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { pluginReact } from '@rsbuild/plugin-react';
44
export default defineConfig({
55
plugins: [pluginReact()],
66
source: {
7-
entry: 'entry.ts',
7+
entry: {
8+
entry1: 'entry-1.ts',
9+
entry2: ['entry-2.ts'],
10+
entry3: { import: 'entry-3.ts' },
11+
entry4: { import: ['entry-4.ts'] },
12+
},
813
},
914
});

packages/knip/src/plugins/rsbuild/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ const config = ['rsbuild*.config.{mjs,ts,js,cjs,mts,cts}'];
1616
const resolveConfig: ResolveConfig<RsbuildConfig> = async config => {
1717
const inputs = new Set<Input>();
1818
if (config.source?.entry) {
19-
if (Array.isArray(config.source.entry)) for (const entry of config.source.entry) inputs.add(toEntry(entry));
20-
if (typeof config.source.entry === 'string') inputs.add(toEntry(config.source.entry));
19+
for (const entry of Object.values(config.source.entry)) {
20+
if (typeof entry === 'string') inputs.add(toEntry(entry));
21+
else if (Array.isArray(entry)) for (const e of entry) inputs.add(toEntry(e));
22+
else {
23+
if (typeof entry.import === 'string') inputs.add(toEntry(entry.import));
24+
else if (Array.isArray(entry.import)) for (const e of entry.import) inputs.add(toEntry(e));
25+
}
26+
}
2127
}
2228
return Array.from(inputs);
2329
};

packages/knip/test/plugins/rsbuild.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('Find dependencies with the rsbuild plugin', async () => {
1616
assert.deepEqual(counters, {
1717
...baseCounters,
1818
binaries: 1,
19-
processed: 2,
20-
total: 2,
19+
processed: 5,
20+
total: 5,
2121
});
2222
});

0 commit comments

Comments
 (0)