Skip to content

feat(pack): support optimization.removeUnusedExports & codegen modules without module graph#2239

Merged
fireairforce merged 2 commits intonextfrom
feat-2214
Oct 10, 2025
Merged

feat(pack): support optimization.removeUnusedExports & codegen modules without module graph#2239
fireairforce merged 2 commits intonextfrom
feat-2214

Conversation

@fireairforce
Copy link
Contributor

@fireairforce fireairforce commented Oct 10, 2025

Summary

新增一个配置 optimization.removeUnusedExports 用于移除未使用到的导出。该配置在 production 场景下默认开启,dev 场景下默认为 false。

同时 apply turbopack 底层的 export_usage 变更: vercel/next.js#81238

用于节省在 modules 生成时候的内存占用。

Test Plan

参考快照测试的变更

@gemini-code-assist
Copy link
Contributor

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!

此拉取请求引入了一个新的优化功能,允许用户配置是否移除未使用的导出,从而减小最终打包体积。此功能通过在生产环境中默认启用,而在开发环境中默认禁用,以平衡开发效率和生产性能。同时,它还包含了对 Turbopack 核心导出使用分析机制的底层更新,确保了优化逻辑的正确性和效率。

Highlights

  • 新配置项: 新增 optimization.removeUnusedExports 配置,用于移除未使用的导出。此配置在生产环境下默认开启,开发环境下默认关闭。
  • Turbopack集成: 集成了 Turbopack 底层的 export_usage 变更,以支持更精细的导出使用分析。
  • 重构Chunking Context参数: 重构了 ClientChunkingContextLibraryChunkingContext 的创建函数,将多个参数封装到新的 ClientChunkingContextOptionsLibraryChunkingContextOptions 结构体中,提高了代码的可读性和可维护性,并加入了 export_usage 字段。
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.

Copy link
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

这个 PR 引入了一个很有价值的优化(removeUnusedExports),用于移除未使用的导出,这有助于减小生产环境下的包体积。实现看起来很可靠,并且默认行为(生产环境开启,开发环境关闭)是合理的。将函数参数重构为专门的 Options 结构体(如 ClientChunkingContextOptionsLibraryChunkingContextOptions)的做法,对于代码清晰度和可维护性来说是一个巨大的改进,尤其是在 turbo_tasks 框架中。

我提出了一些关于次要重构的建议,以提高代码的清晰度并遵循 Rust 的惯用写法。总的来说,这是一个很棒的贡献。

@fireairforce fireairforce merged commit 8c082c1 into next Oct 10, 2025
18 of 19 checks passed
@fireairforce fireairforce deleted the feat-2214 branch October 10, 2025 09:23
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