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
16 changes: 16 additions & 0 deletions e2e/cases/assets/filename-conflict-hint/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expect, rspackTest } from '@e2e/helper';

rspackTest(
'should print output.filename hints as expected',
async ({ build }) => {
const rsbuild = await build({
catchBuildError: true,
});

expect(rsbuild.buildError).toBeTruthy();

await rsbuild.expectLog(
'You may need to adjust output.filename configuration to prevent name conflicts.',
);
},
);
10 changes: 10 additions & 0 deletions e2e/cases/assets/filename-conflict-hint/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from '@rsbuild/core';

export default defineConfig({
output: {
filename: {
image: 'image.png',
},
dataUriLimit: 0,
},
});
4 changes: 4 additions & 0 deletions e2e/cases/assets/filename-conflict-hint/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import icon from '@e2e/assets/icon.png';
import image from '@e2e/assets/image.png';

console.log(icon, image);
13 changes: 13 additions & 0 deletions packages/core/src/helpers/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ function hintUnknownFiles(message: string): string {
return message;
}

const hintAssetsConflict = (message: string): string => {
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Inconsistent function declaration style. The function hintAssetsConflict uses arrow function syntax with const, while hintUnknownFiles (line 85) uses traditional function declaration. For consistency within the file, consider changing to: function hintAssetsConflict(message: string): string {

Copilot uses AI. Check for mistakes.
const hint = 'Multiple assets emit different content to the same filename';

if (message.indexOf(hint) === -1) {
return message;
}

const extraMessage = `You may need to adjust ${color.yellow('output.filename')} configuration to prevent name conflicts. (See ${color.yellow('https://rsbuild.rs/config/output/filename')})`;
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The long message string on line 151 exceeds typical line length conventions, making it harder to read and maintain. Consider breaking it into multiple lines or using string concatenation for better readability.

Suggested change
const extraMessage = `You may need to adjust ${color.yellow('output.filename')} configuration to prevent name conflicts. (See ${color.yellow('https://rsbuild.rs/config/output/filename')})`;
const extraMessage =
`You may need to adjust ${color.yellow('output.filename')} configuration to prevent name conflicts. `
+ `(See ${color.yellow('https://rsbuild.rs/config/output/filename')})`;

Copilot uses AI. Check for mistakes.

return `${message}\n${extraMessage}`;
};

/**
* Add node polyfill tip when failed to resolve node built-in modules.
*/
Expand Down Expand Up @@ -250,6 +262,7 @@ export function formatStatsError(stats: StatsError): string {

message = hintUnknownFiles(message);
message = hintNodePolyfill(message);
message = hintAssetsConflict(message);

let lines = message.split('\n');

Expand Down
Loading