Skip to content

Conversation

@fireairforce
Copy link

For: utooland/utoo#2244

append pr for: #63

添加一个运行时函数叫 getPublicPath,用于处理 runtime publicPath 的逻辑,类似于 webpack 的 __webpack_public_path__ 处理: https://webpack.js.org/guides/public-path/#on-the-fly

同时处理静态资源以及 chunk 的 runtime publicPath 逻辑:

静态资源拼接:

image

chunk publicPath:

image

@gemini-code-assist
Copy link

Summary of Changes

Hello @fireairforce, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances Turbopack's ability to handle static assets and chunks by implementing a flexible runtime public path mechanism. This allows the base URL for loading assets to be determined dynamically at runtime, typically by checking globalThis.publicPath, which is crucial for applications deployed to varying environments or behind CDNs. The changes centralize public path resolution and integrate this dynamic behavior directly into the asset generation pipeline.

Highlights

  • Centralized Runtime Public Path: Introduced a new getPublicPath runtime function, accessible via contextPrototype.p(), to centralize the logic for determining the public path for assets and chunks, similar to Webpack's __webpack_public_path__.
  • Dynamic Static Asset URL Generation: Modified the static asset generation process to dynamically prepend the runtime public path to asset URLs when __RUNTIME_PUBLIC_PATH__ is specified, ensuring correct asset loading in various deployment environments.
  • Runtime Context Integration: Integrated the new getPublicPath function into the Turbopack runtime context and registered __turbopack_public_path__ as a new runtime function shortcut, making it available for use in generated code.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@fireairforce
Copy link
Author

umi-next 侧的 pr 我先直接合并了,等后续 bump next.js 的时候我把这些 commit 合并一下,目前主要为了记录一些更改(或许后面可能不需要调整)

Copy link

@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

The pull request introduces a runtime function getPublicPath to handle runtime publicPath logic, similar to webpack's __webpack_public_path__. It addresses static asset and chunk runtime publicPath logic. The changes involve modifying runtime-base.ts, runtime-types.d.ts, runtime-utils.ts, runtime_functions.rs, and ecma.rs to implement this functionality. The review focuses on correctness and potential issues in the implementation.

@fireairforce fireairforce merged commit 62c9270 into utoo Oct 13, 2025
13 of 26 checks passed
@xusd320 xusd320 deleted the static-support-runtime-publicPath branch November 26, 2025 02:42
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.

2 participants