-
-
Notifications
You must be signed in to change notification settings - Fork 336
fix(resolve): Export generateConfig to fix pnpm module resolution #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(resolve): Export generateConfig to fix pnpm module resolution #950
Conversation
|
@DanielChutkowskiJMMJ is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
|
Note Other AI code review bot(s) detectedCodeRabbit 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)及类型 Changes
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: 返回配置对象
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 分钟
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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.
Example instruction:
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. Comment |
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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
| import momentGenerateConfig from './generate/moment'; | ||
| import dayjsGenerateConfig from './generate/dayjs'; | ||
| import dateFnsGenerateConfig from './generate/dateFns'; | ||
| import luxonGenerateConfig from './generate/luxon'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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';
| export { | ||
| Picker, | ||
| RangePicker, | ||
| PickerPanel, | ||
| momentGenerateConfig, | ||
| dayjsGenerateConfig, | ||
| dateFnsGenerateConfig, | ||
| luxonGenerateConfig, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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
📒 Files selected for processing (1)
src/index.tsx(1 hunks)
🔇 Additional comments (1)
src/index.tsx (1)
34-37: 所有导入模块路径和导出已验证正确。验证结果:
- ✅ 四个生成配置文件均存在:
src/generate/moment.ts、dayjs.ts、dateFns.ts、luxon.ts- ✅ 每个模块都正确导出:
export default generateConfig;- ✅ 导入语句正确使用默认导入语法,路径正确
- ✅ 导出语句正确使用命名导出,将四个配置暴露为公共API
- ✅ 无循环依赖或其他问题
| export { | ||
| Picker, | ||
| RangePicker, | ||
| PickerPanel, | ||
| momentGenerateConfig, | ||
| dayjsGenerateConfig, | ||
| dateFnsGenerateConfig, | ||
| luxonGenerateConfig, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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.tsxLength 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 -20Length 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 -20Length 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 -20Length 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
|
@zombieJ, @afc163, @meet-student, @divyeshagrawal, could you please take a look when you have a moment? 🙂 |
This PR exports the
generateConfighelpers (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
发布说明
✏️ Tip: You can customize this high-level summary in your review settings.