Skip to content

feat(pack): Support auto public path in UtooPack#2953

Open
xusd320 wants to merge 1 commit into
nextfrom
xusd320/utoopack-public-path-auto
Open

feat(pack): Support auto public path in UtooPack#2953
xusd320 wants to merge 1 commit into
nextfrom
xusd320/utoopack-public-path-auto

Conversation

@xusd320
Copy link
Copy Markdown
Contributor

@xusd320 xusd320 commented May 15, 2026

Summary

  • add UtooPack support for output.publicPath: "auto"
  • map the new config value to a Turbopack runtime marker and avoid treating it as a literal dev/HTML prefix
  • add a public_path/auto snapshot fixture and refresh affected runtime snapshots
  • update the next.js submodule pointer to include the Turbopack runtime support from feat(turbopack): Support auto public path in Turbopack runtime next.js#149

Why

The existing default publicPath behavior resolves to /, while publicPath: "runtime" reads globalThis.publicPath. This adds a webpack-compatible "auto" mode for deployments where chunks and assets should resolve relative to the current runtime script URL.

Validation

  • cargo run -p pack-schema
  • UPDATE=1 cargo test -p pack-tests public_path -- --nocapture
  • cargo test -p pack-tests public_path -- --nocapture
  • npm run build --workspace @utoo/pack-shared
  • npm run build:js --workspace @utoo/pack
  • cargo fmt
  • cargo clippy --all-targets -- -D warnings --no-deps
  • git diff --check
  • git -C next.js diff --check

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements an 'auto' public path feature, which enables the runtime to automatically determine the base URL for assets based on the source of the executing script. The changes span the core configuration logic in Rust, the TypeScript build plugins, and the ECMAScript runtime. Feedback from the review points out that the string matching for the 'runtime' and 'auto' configuration keywords should be improved to handle trailing slashes, ensuring that user-provided values like 'auto/' are correctly identified as special modes rather than literal paths.

Comment on lines +1672 to 1676
match public_path.as_str() {
"runtime" => return Ok(Vc::cell("__RUNTIME_PUBLIC_PATH__".into())),
"auto" => return Ok(Vc::cell("__AUTO_PUBLIC_PATH__".into())),
_ => {}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation of computed_public_path handles the special values "runtime" and "auto" before enforcing a trailing slash. This is correct as these are internal markers. However, if a user provides "auto/" or "runtime/" in their configuration, they will fall through to the default case and be returned as literal paths with a trailing slash (e.g., "auto/"), which is likely not the intended behavior. Consider normalizing the input by trimming trailing slashes before matching against these keywords to be more resilient to user input.

Comment on lines +6 to +10
function normalizeHtmlPublicPath(globalPublicPath: string | undefined): string {
return globalPublicPath === "runtime" || globalPublicPath === "auto"
? ""
: (globalPublicPath ?? "");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The normalizeHtmlPublicPath function correctly returns an empty string for "runtime" and "auto" modes, which is appropriate for static HTML injection where assets are typically co-located. However, similar to the Rust implementation, it only matches exact strings. If a user provides "auto/" in their configuration, it will return "auto/", leading to broken URLs like auto//main.js during asset injection. Consider using a more robust check or normalizing the input string.

References
  1. Ensure that configuration keywords are handled consistently and resiliently across different parts of the codebase. (link)

@xusd320 xusd320 changed the title [codex] Support auto public path in UtooPack feat(pack): Support auto public path in UtooPack May 18, 2026
@xusd320 xusd320 marked this pull request as ready for review May 18, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant