Skip to content

feat(pack): modularizeImport support skip type import#2710

Merged
xusd320 merged 2 commits into
nextfrom
support-type-check
Mar 18, 2026
Merged

feat(pack): modularizeImport support skip type import#2710
xusd320 merged 2 commits into
nextfrom
support-type-check

Conversation

@fireairforce

Copy link
Copy Markdown
Member

Summary

modularizeImport transform support skip type import.

Test Plan

updated.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 enhances the modularizeImport transformation to properly support TypeScript files. By integrating a pre-processing step that removes type-only imports, the system avoids incorrect modularization of type declarations, ensuring better compatibility and correctness for projects utilizing TypeScript and this optimization. The changes are validated with an updated test case that now includes React syntax.

Highlights

  • Modularize Imports for TypeScript: The modularizeImport transform now correctly handles TypeScript files by stripping type-only imports before applying modularization, preventing issues with type references.
  • TypeScript File Detection: A new utility function is_typescript_like_file was introduced to identify TypeScript, TSX, MJS, and CJS files based on their extensions.
  • Updated Test Case: An existing test case for modularize_imports was updated to use a .tsx file, include React components, and verify that type-only imports are correctly skipped, resolving previous module not found errors.
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.

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.

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

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.

Code Review

This pull request enhances the modularizeImport transform to correctly handle type-only imports in TypeScript files. By running a TypeScript transform pass with verbatim_module_syntax: false before the main modularization logic, it effectively strips out type-only imports, preventing them from being processed as runtime dependencies. This resolves issues where modularizeImport would attempt to create invalid import paths for types. The changes are well-targeted, and the accompanying test case effectively demonstrates the fix. I've kept the suggestion to improve the file type detection logic for better robustness and readability.

Comment thread crates/pack-core/src/shared/transforms/modularize_imports.rs
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

📊 Performance Benchmark Report (with-antd)

Utoopack Performance Report

Report ID: utoopack_performance_report_20260318_104553
Generated: 2026-03-18 10:45:53
Trace File: trace_antd.json (0.6GB, 1.74M spans)
Test Project: examples/with-antd


Executive Summary

Metric Value Assessment
Total Wall Time 14,977.4 ms Baseline
Total Thread Work (de-duped) 51,633.1 ms Non-overlapping busy time
Effective Parallelism 3.4x thread_work / wall_time
Working Threads 5 Threads with actual spans
Thread Utilization 68.9% 🆗 Average
Total Spans 1,742,933 All B/E + X events
Meaningful Spans (>= 10us) 649,748 (37.3% of total)
Tracing Noise (< 10us) 1,093,185 (62.7% of total)

Build Phase Timeline

Shows when each build phase is active and how much CPU it consumes.
Self-Time is the time spent exclusively in that phase (excluding children).

Phase Spans Inclusive (ms) Self-Time (ms) Wall Range (ms)
Resolve 146,562 9,129.6 7,329.9 10,786.5
Parse 12,407 2,815.8 2,510.5 14,785.8
Analyze 378,501 37,250.7 28,386.3 14,227.9
Chunk 29,358 3,105.4 2,909.9 11,921.2
Codegen 69,253 5,135.3 3,849.0 12,017.0
Emit 75 76.7 38.2 11,958.7
Other 13,592 2,379.9 2,051.8 14,977.4

Workload Distribution by Diagnostic Tier

Category Spans Inclusive (ms) % Work Self-Time (ms) % Self
P0: Scheduling & Resolution 534,830 48,048.3 93.1% 37,083.8 71.8%
P1: I/O & Heavy Tasks 3,317 204.6 0.4% 166.1 0.3%
P2: Architecture (Locks/Memory) 0 0.0 0.0% 0.0 0.0%
P3: Asset Pipeline 109,847 11,065.0 21.4% 9,278.1 18.0%
P4: Bridge/Interop 0 0.0 0.0% 0.0 0.0%
Other 1,754 575.4 1.1% 547.8 1.1%

Top 20 Tasks by Self-Time

Self-time is the exclusive duration: time spent in the task itself, not in sub-tasks.
This is the most accurate indicator of where CPU cycles are actually spent.

Self (ms) Inclusive (ms) Count Avg Self (us) P95 Self (ms) Max Self (ms) % Work Task Name Top Caller
18,406.9 20,938.3 235,635 78.1 0.1 51.4 35.6% module write all entrypoints to disk (1%)
5,086.4 6,843.9 40,401 125.9 0.2 267.3 9.9% analyze ecmascript module process module (73%)
3,708.8 4,065.7 68,519 54.1 0.1 18.5 7.2% internal resolving resolving (29%)
3,593.7 5,036.5 77,329 46.5 0.0 37.5 7.0% resolving module (34%)
3,285.5 7,825.9 81,009 40.6 0.1 31.8 6.4% process module module (16%)
2,103.5 2,193.1 9,015 233.3 0.6 47.2 4.1% parse ecmascript analyze ecmascript module (27%)
2,087.7 2,251.8 16,481 126.7 0.3 139.1 4.0% chunking write all entrypoints to disk (0%)
1,930.1 3,216.3 27,477 70.2 0.2 51.3 3.7% code generation chunking (7%)
1,582.5 1,582.5 39,694 39.9 0.1 17.9 3.1% precompute code generation code generation (29%)
1,466.2 1,760.0 10,821 135.5 0.0 337.6 2.8% write all entrypoints to disk None (0%)
1,417.2 1,417.2 18,046 78.5 0.3 158.0 2.7% compute async module info chunking (0%)
786.1 786.7 12,678 62.0 0.1 69.5 1.5% compute async chunks write all entrypoints to disk (0%)
496.0 514.6 1,514 327.6 0.9 22.6 1.0% webpack loader parse css (11%)
336.5 336.5 2,082 161.6 0.4 20.3 0.7% generate source map code generation (96%)
306.6 522.1 864 354.8 0.7 39.5 0.6% parse css module (6%)
109.1 109.1 1,357 80.4 0.0 26.0 0.2% compute binding usage info write all entrypoints to disk (0%)
100.2 100.2 2,509 39.9 0.1 4.5 0.2% read file parse ecmascript (85%)
64.3 64.3 2,018 31.9 0.0 10.0 0.1% collect mergeable modules compute merged modules (0%)
37.9 44.5 1,017 37.2 0.1 3.1 0.1% async reference write all entrypoints to disk (0%)
37.6 37.6 36 1045.0 5.5 12.5 0.1% write file apply effects (100%)

Critical Path Analysis

The longest sequential dependency chains that determine wall-clock time.
Focus on reducing the depth of these chains to improve parallelism.

Rank Self-Time (ms) Depth Path
1 267.4 2 process module → analyze ecmascript module
2 67.7 2 code generation → generate source map
3 63.2 2 process module → analyze ecmascript module
4 57.6 2 process module → analyze ecmascript module
5 57.5 2 code generation → generate source map

Batching Candidates

High-volume tasks dominated by a single parent. If the parent can batch them,
it drastically reduces scheduler overhead.

Task Name Count Top Caller (Attribution) Avg Self P95 Self Total Self
analyze ecmascript module 40,401 process module (73%) 125.9 us 0.20 ms 5,086.4 ms

Duration Distribution

Range Count Percentage
<10us 1,093,185 62.7%
10us-100us 613,773 35.2%
100us-1ms 27,641 1.6%
1ms-10ms 7,611 0.4%
10ms-100ms 715 0.0%
>100ms 8 0.0%

Action Items

  1. [P0] Focus on tasks with the highest Self-Time — these are where CPU cycles are actually spent.
  2. [P0] Use Batching Candidates to identify callers that should use try_join or reduce #[turbo_tasks::function] granularity.
  3. [P1] Check Build Phase Timeline for phases with disproportionate wall range vs. self-time (= serialization).
  4. [P1] Inspect P95 Self (ms) for heavy monolith tasks. Focus on long-tail outliers, not averages.
  5. [P1] Review Critical Paths — reducing the longest chain depth directly improves wall-clock time.
  6. [P2] If Thread Utilization < 60%, investigate scheduling gaps (lock contention or deep dependency chains).

Report generated by Utoopack Performance Analysis Agent

@xusd320 xusd320 merged commit 83a3175 into next Mar 18, 2026
21 checks passed
@xusd320 xusd320 deleted the support-type-check branch March 18, 2026 11:04
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