Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 10 additions & 3 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1019,11 +1019,18 @@ const composeEntryConfig = async (

for (const file of resolvedEntryFiles) {
const entryName = getEntryName(file);

if (resolvedEntries[entryName]) {
logger.warn(
`duplicate entry: ${entryName}, this may lead to the incorrect output, please rename the file`,
);
calcLcp &&
logger.warn(
`Duplicate entry ${color.cyan(entryName)} from ${color.cyan(
path.relative(root, file),
)} and ${color.cyan(
path.relative(root, resolvedEntries[entryName]),
)}, which may lead to the incorrect output, please rename the file.`,
);
}

resolvedEntries[entryName] = file;
}
}
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/entry/duplicate/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "entry-duplicate-test",
"version": "1.0.0",
"private": true,
"type": "module"
}
10 changes: 10 additions & 0 deletions tests/integration/entry/duplicate/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from '@rslib/core';
import { generateBundleEsmConfig } from 'test-helper';

export default defineConfig({
lib: [
generateBundleEsmConfig({
bundle: false,
}),
],
});
3 changes: 3 additions & 0 deletions tests/integration/entry/duplicate/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.red {
color: red;
}
3 changes: 3 additions & 0 deletions tests/integration/entry/duplicate/src/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.counter-text {
font-size: 50px;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/integration/entry/duplicate/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = 'foo';
20 changes: 19 additions & 1 deletion tests/integration/entry/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'node:path';
import stripAnsi from 'strip-ansi';
import { buildAndGetResults, queryContent } from 'test-helper';
import { buildAndGetResults, proxyConsole, queryContent } from 'test-helper';
import { expect, test } from 'vitest';

test('default entry', async () => {
Expand Down Expand Up @@ -168,3 +168,21 @@
`"The source.entry configuration should be an object, but received string: ./src/**. Checkout https://lib.rsbuild.dev/config/rsbuild/source#sourceentry for more details."`,
);
});

test('duplicate entry in bundleless mode', async () => {
const { logs, restore } = proxyConsole();
const fixturePath = join(__dirname, 'duplicate');
await buildAndGetResults({ fixturePath });

const logStrings = logs.map((log) => stripAnsi(log));

expect(
logStrings.some((log) =>
log.includes(
'Duplicate entry index from src/index.ts and src/index.svg, which may lead to the incorrect output, please rename the file.',
),
),
).toBe(true);

Check failure on line 185 in tests/integration/entry/index.test.ts

View workflow job for this annotation

GitHub Actions / integration-e2e (18, windows-latest)

integration/entry/index.test.ts > duplicate entry in bundleless mode

AssertionError: expected false to be true // Object.is equality - Expected + Received - true + false ❯ integration/entry/index.test.ts:185:5

restore();
});
Loading