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
5 changes: 4 additions & 1 deletion packages/core/src/helpers/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export const getPublicPathFromCompiler = (

if (typeof publicPath === 'string') {
// 'auto' is a magic value in Rspack and behave like `publicPath: ""`
if (publicPath === 'auto') {
// Empty string is a valid value representing a relative path and should be preserved
// This is important for server targets (node) to enable relative paths for worker_threads
// See: https://github.com/web-infra-dev/rsbuild/issues/6539
if (publicPath === 'auto' || publicPath === '') {
return '';
}
return publicPath.endsWith('/') ? publicPath : `${publicPath}/`;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/helpers/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const formatPublicPath = (
withSlash = true,
): string => {
// 'auto' is a magic value in Rspack and we should not add trailing slash
if (publicPath === 'auto') {
// Empty string is a valid value representing a relative path and should be preserved (important for node targets)
if (publicPath === 'auto' || publicPath === '') {
return publicPath;
}

Expand Down
Loading