Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/plugin-dts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,20 @@ export function processSourceEntry(
entryConfig &&
Object.values(entryConfig).every((val) => typeof val === 'string')
) {
return Object.entries(entryConfig as Record<string, string>).map(
const entries = Object.entries(entryConfig as Record<string, string>).map(
([name, path]) => ({
name,
path,
}),
);

if (entries.length === 0) {
throw new Error(
`Can not find a valid entry for ${color.cyan('dts.bundle')} option, please check your entry config.`,
);
}

return entries;
}

throw new Error(
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/integration/dts/bundle/no-entry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "dts-bundle-no-entry-test",
"version": "1.0.0",
"private": true,
"type": "module"
}
19 changes: 19 additions & 0 deletions tests/integration/dts/bundle/no-entry/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from '@rslib/core';
import { generateBundleEsmConfig } from 'test-helper';

export default defineConfig({
lib: [
generateBundleEsmConfig({
bundle: false,
dts: {
bundle: true,
},
}),
],
source: {
entry: {
index: '../__fixtures__/src',
},
tsconfigPath: '../__fixtures__/tsconfig.json',
},
});
15 changes: 15 additions & 0 deletions tests/integration/dts/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,21 @@ describe('dts when bundle: true', () => {

expect([indexEsm, indexCjs, sumEsm, sumCjs]).toMatchSnapshot();
});

test('can not find a valid entry', async () => {
const fixturePath = join(__dirname, 'bundle', 'no-entry');
const { restore } = proxyConsole();

try {
await buildAndGetResults({ fixturePath, type: 'dts' });
} catch (err: any) {
expect(stripAnsi(err.message)).toMatchInlineSnapshot(
`"Can not find a valid entry for dts.bundle option, please check your entry config."`,
);
}

restore();
});
});

describe('dts when build: true', () => {
Expand Down
Loading