Skip to content

Commit 1b509ea

Browse files
authored
fix: emit correct warning message when no entry found in bundleless mode (#1359)
1 parent b416002 commit 1b509ea

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

packages/core/src/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,11 @@ const composeEntryConfig = async (
13441344
});
13451345

13461346
if (resolvedEntryFiles.length === 0) {
1347-
throw new Error(`Cannot find ${resolvedEntryFiles}`);
1347+
const error = new Error(
1348+
`No entry files matching ${entryFiles.map((file) => color.cyan(file)).join(', ')}. Please ensure the entry pattern in ${color.cyan('source.entry')} is correct and points to valid source files.`,
1349+
);
1350+
error.stack = '';
1351+
throw error;
13481352
}
13491353

13501354
const outBase = await resolveOutBase(resolvedEntryFiles);

tests/integration/entry/index.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test('validate entry and throw errors', async () => {
182182
try {
183183
await buildAndGetResults({
184184
fixturePath,
185-
configPath: 'nonExistingFile.config.ts',
185+
configPath: 'bundleNonExistingFile.config.ts',
186186
});
187187
} catch (e) {
188188
errMsg = (e as AggregateError).errors.join('\n\n');
@@ -192,6 +192,19 @@ test('validate entry and throw errors', async () => {
192192
`"Error: Can't resolve the entry "./src/main.ts" at the location <ROOT>/tests/integration/entry/validate/src/main.ts. Please ensure that the file exists."`,
193193
);
194194

195+
try {
196+
await buildAndGetResults({
197+
fixturePath,
198+
configPath: 'bundlelessNonExistingFile.config.ts',
199+
});
200+
} catch (e) {
201+
errMsg = (e as Error).message;
202+
}
203+
204+
expect(stripAnsi(errMsg)).toMatchInlineSnapshot(
205+
`"No entry files matching ./src/non-existing-file.ts, ./non-existing-folder/**/*. Please ensure the entry pattern in source.entry is correct and points to valid source files."`,
206+
);
207+
195208
try {
196209
await buildAndGetResults({
197210
fixturePath,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from '@rslib/core';
2+
import { generateBundleEsmConfig } from 'test-helper';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleEsmConfig({
7+
bundle: false,
8+
source: {
9+
entry: {
10+
index: ['./src/non-existing-file.ts', './non-existing-folder/**/*'],
11+
},
12+
},
13+
}),
14+
],
15+
});

0 commit comments

Comments
 (0)