Skip to content

Conversation

@DanielChutkowskiJMMJ
Copy link

@DanielChutkowskiJMMJ DanielChutkowskiJMMJ commented Nov 18, 2025

This PR exports the generateConfig helpers (momentGenerateConfig, dayjsGenerateConfig, etc.) from the main package entry point.

This change allows consumers to use a robust, top-level import:
import { momentGenerateConfig } from '@rc-component/picker';

This is necessary to fix module resolution failures in strict package managers like pnpm, which cannot reliably handle the current deep-import pattern (rc-picker/lib/generate/moment).

Closes #949

Summary by CodeRabbit

发布说明

  • 新功能
    • 新增四个日期库生成配置的公开导出:Moment、Day.js、Date-fns 和 Luxon,方便用户直接使用这些配置与日期选择组件集成。
    • 将通用的配置类型(GenerateConfig)公开导出,便于类型安全的自定义与扩展。
    • 核心日期选择组件(Picker、RangePicker、PickerPanel)对外可见性保持不变,仅扩展了公共 API。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 18, 2025

@DanielChutkowskiJMMJ is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

将四个 generateConfig(dateFnsGenerateConfig、dayjsGenerateConfig、luxonGenerateConfig、momentGenerateConfig)及类型 GenerateConfigsrc/generate 通过主入口导出,并在 src/generate/index.ts 中为四个实现添加对应的 re-export,消除对深层导入的依赖;未修改运行时逻辑。

Changes

Cohort / File(s) 变更摘要
主入口导出扩展
src/index.tsx
新增导入并导出:dateFnsGenerateConfigdayjsGenerateConfigluxonGenerateConfigmomentGenerateConfig 与类型 GenerateConfig;将原先的聚合导出替换为包含这些项的显式导出列表。
generate 模块 re-export
src/generate/index.ts
为四个具体实现添加 re-export:export { default as dateFnsGenerateConfig } from './dateFns'export { default as dayjsGenerateConfig } from './dayjs'export { default as luxonGenerateConfig } from './luxon'export { default as momentGenerateConfig } from './moment'

Sequence Diagram(s)

sequenceDiagram
  participant Consumer as 使用方
  participant PackageIndex as `@rc-component/picker` (index)
  participant GenerateIndex as src/generate
  participant Impl as date/moment/dayjs/luxon 模块

  Note over Consumer,PackageIndex `#D5F5E3`: 顶层导入替代深层导入
  Consumer->>PackageIndex: import { momentGenerateConfig } from '@rc-component/picker'
  PackageIndex->>GenerateIndex: 请求 re-export 的 symbol
  GenerateIndex->>Impl: 转发到具体实现模块 (./moment)
  Impl-->>GenerateIndex: 返回默认导出配置对象
  GenerateIndex-->>PackageIndex: 提供配置对象
  PackageIndex-->>Consumer: 返回配置对象
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 分钟

  • 评审重点:
    • 确认 src/generate/* 各实现的默认导出名称与 re-export 匹配。
    • 校验 GenerateConfig 类型路径与导出声明正确、无命名冲突。
    • 测试顶层导入在常见包管理器(npm/pnpm/yarn)下解析正常。

"🐰 四路配置来相会,
主入口处不再藏,
pnpm 旅途少了坑,
深层导入成旧章,
小兔欢跳写新行! 🥕"

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确概括了主要改动:导出generateConfig以修复pnpm模块解析问题。
Linked Issues check ✅ Passed PR的代码改动完全满足#949中的所有编码要求:将generateConfig及其四个实现从生成文件导出到主入口点。
Out of Scope Changes check ✅ Passed 所有改动均直接对应#949的目标,未发现超出范围或无关的代码修改。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26e3328 and 745bdd1.

📒 Files selected for processing (1)
  • src/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/index.tsx

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @DanielChutkowskiJMMJ, 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 resolves module resolution issues, particularly for strict package managers like pnpm, by making several generateConfig helper functions directly exportable from the main package entry point. This modification simplifies import paths for consumers, allowing for more robust and straightforward module resolution.

Highlights

  • Module Export: The generateConfig helper functions (momentGenerateConfig, dayjsGenerateConfig, dateFnsGenerateConfig, and luxonGenerateConfig) are now directly exported from the main package entry point (src/index.tsx).
  • Improved Import Paths: Consumers can now use a robust, top-level import pattern, such as import { momentGenerateConfig } from '@rc-component/picker';, simplifying how these helpers are accessed.
  • Pnpm Module Resolution Fix: This change specifically addresses and fixes module resolution failures encountered in strict package managers like pnpm, which previously struggled with deep-import patterns.
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

This pull request correctly exports the generateConfig helpers from the main package entry point to resolve module resolution issues with pnpm. The change is straightforward and effective. I've included a couple of suggestions to enhance code modularity and maintainability by introducing a barrel file for the generator configurations and alphabetically sorting the exports.

src/index.tsx Outdated
Comment on lines 34 to 37
import momentGenerateConfig from './generate/moment';
import dayjsGenerateConfig from './generate/dayjs';
import dateFnsGenerateConfig from './generate/dateFns';
import luxonGenerateConfig from './generate/luxon';
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve modularity and keep the main entry point (src/index.tsx) cleaner, consider creating a barrel file (src/generate/index.ts) to aggregate all generateConfig exports. This centralizes the generator configurations and simplifies imports.

You would first create src/generate/index.ts with the following content:

export { default as dateFnsGenerateConfig } from './dateFns';
export { default as dayjsGenerateConfig } from './dayjs';
export { default as luxonGenerateConfig } from './luxon';
export { default as momentGenerateConfig } from './moment';

Then, you can simplify the imports in this file as suggested.

import {
  dateFnsGenerateConfig,
  dayjsGenerateConfig,
  luxonGenerateConfig,
  momentGenerateConfig,
} from './generate';

Comment on lines 39 to 47
export {
Picker,
RangePicker,
PickerPanel,
momentGenerateConfig,
dayjsGenerateConfig,
dateFnsGenerateConfig,
luxonGenerateConfig,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and better readability, it's good practice to keep exports sorted alphabetically. This makes it easier to locate specific exports as the list grows.

export {
  dateFnsGenerateConfig,
  dayjsGenerateConfig,
  luxonGenerateConfig,
  momentGenerateConfig,
  Picker,
  PickerPanel,
  RangePicker,
};

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e3723b and e7e1f2f.

📒 Files selected for processing (1)
  • src/index.tsx (1 hunks)
🔇 Additional comments (1)
src/index.tsx (1)

34-37: 所有导入模块路径和导出已验证正确。

验证结果:

  • ✅ 四个生成配置文件均存在:src/generate/moment.tsdayjs.tsdateFns.tsluxon.ts
  • ✅ 每个模块都正确导出:export default generateConfig;
  • ✅ 导入语句正确使用默认导入语法,路径正确
  • ✅ 导出语句正确使用命名导出,将四个配置暴露为公共API
  • ✅ 无循环依赖或其他问题

Comment on lines 39 to 47
export {
Picker,
RangePicker,
PickerPanel,
momentGenerateConfig,
dayjsGenerateConfig,
dateFnsGenerateConfig,
luxonGenerateConfig,
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

导出结构正确,解决了 pnpm 深层导入问题。考虑同时导出 GenerateConfig 类型。

这些导出正确地解决了 issue #949 中提到的 pnpm 模块解析问题。将 generateConfig 助手函数作为公共 API 的一部分导出,使用户可以使用稳定的顶级导入:import { momentGenerateConfig } from '@rc-component/picker';,而不是容易出错的深层导入。

但是,TypeScript 用户可能还需要 GenerateConfig 类型来正确地对他们的代码进行类型检查。建议验证 GenerateConfig 类型是否已经导出,如果没有,考虑在类型导出块(第 48-56 行)中添加它。

运行以下脚本检查 GenerateConfig 类型是否已导出:


🏁 Script executed:

#!/bin/bash
# 描述:检查 GenerateConfig 类型定义和导出

# 查找 GenerateConfig 类型定义
echo "=== 查找 GenerateConfig 类型定义 ==="
rg -n "type\s+GenerateConfig|interface\s+GenerateConfig" --type ts --type tsx

# 检查当前的类型导出
echo -e "\n=== 检查 src/index.tsx 中的类型导出 ==="
cat src/index.tsx | sed -n '/export type {/,/};/p'

# 搜索 GenerateConfig 在导出语句中的使用
echo -e "\n=== 检查 GenerateConfig 是否已被导出 ==="
rg -n "export.*GenerateConfig" src/index.tsx

Length of output: 272


🏁 Script executed:

#!/bin/bash
# 重新搜索 GenerateConfig 类型定义,使用正确的文件类型

echo "=== 搜索 GenerateConfig 类型定义 ==="
rg -n "type\s+GenerateConfig|interface\s+GenerateConfig" --type typescript

echo -e "\n=== 检查 GenerateConfig 在源代码中的使用 ==="
rg -n "GenerateConfig" --type typescript -B2 -A2

echo -e "\n=== 查看 src/index.tsx 的完整导出 ==="
cat src/index.tsx | tail -20

Length of output: 486


🏁 Script executed:

#!/bin/bash
# 搜索 GenerateConfig 类型定义,不使用 --type 标志

echo "=== 查找包含 GenerateConfig 的文件 ==="
fd -e ts -e tsx | head -30 | xargs grep -l "GenerateConfig" 2>/dev/null | head -10

echo -e "\n=== 在找到的文件中搜索 GenerateConfig 定义 ==="
fd -e ts -e tsx -x grep -n "type.*GenerateConfig\|interface.*GenerateConfig\|export.*GenerateConfig" {} \; 2>/dev/null | head -20

echo -e "\n=== 查找 generateConfig 函数的定义 ==="
fd -e ts -e tsx -x grep -n "GenerateConfig\|generateConfig" {} \; 2>/dev/null | grep -E "(export|function|const).*[Gg]enerate" | head -20

Length of output: 2789


🏁 Script executed:

#!/bin/bash
# 查找 GenerateConfig 的导出位置

echo "=== 查找 GenerateConfig 的定义文件 ==="
find src -name "*.ts" -o -name "*.tsx" | xargs grep -l "export type GenerateConfig" 2>/dev/null

echo -e "\n=== 查看 GenerateConfig 的完整定义 ==="
find src -name "*.ts" -o -name "*.tsx" | xargs grep -A5 "export type GenerateConfig" 2>/dev/null | head -20

Length of output: 442


导出结构正确,建议添加 GenerateConfig 类型导出。

这些导出正确地解决了 issue #949 中提到的 pnpm 模块解析问题。将 generateConfig 助手函数作为公共 API 的一部分导出,使用户可以使用稳定的顶级导入:import { momentGenerateConfig } from '@rc-component/picker';,而不是容易出错的深层导入。

验证确认 GenerateConfig 类型定义于 src/generate/index.ts 中,但尚未在 src/index.tsx 的类型导出块中导出。建议在第 48-56 行的类型导出中添加 GenerateConfig,以便 TypeScript 用户能够正确地为使用这些 generateConfig 对象的代码进行类型注解。

🤖 Prompt for AI Agents
In src/index.tsx around lines 39 to 47 (and the type export block at ~48-56),
the runtime exports include the various generateConfig helpers but the
GenerateConfig TypeScript type from src/generate/index.ts is not re-exported;
update the type export block to include GenerateConfig by importing/
re-exporting it from src/generate/index.ts (add GenerateConfig to the named type
exports) so consumers can type-annotate generateConfig objects via top-level
imports.

and export of GenerateConfig type
@DanielChutkowskiJMMJ
Copy link
Author

DanielChutkowskiJMMJ commented Nov 18, 2025

@zombieJ, @afc163, @meet-student, @divyeshagrawal, could you please take a look when you have a moment? 🙂

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.

[Bug / DX]: Deep imports for generateConfig are incompatible with pnpm and break module resolution

1 participant