react-component / react-component/picker

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

Open
#949 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
304
Forks
345
Avg merge
2d 7h
Merged PRs (30d)
7

Description

Bug Report & DX Improvement

When using @rc-component/picker within a pnpm monorepo, the library fails at runtime with the error TypeError: generateConfig.getNow is not a function.
This occurs because the current API design requires consumers to use deep imports to access the necessary generateConfig helpers (e.g., import momentGenerateConfig from 'rc-picker/lib/generate/moment').

These deep imports are not robust and fail to resolve correctly in a strict pnpm environment due to its symlinked node_modules architecture. The bundler cannot find the module, the generateConfig prop becomes undefined, and the component crashes internally.
This issue forces users to enable shamefully-hoist=true in their .npmrc file as a workaround, which negates many of the benefits of using pnpm.

To Reproduce
Set up a pnpm workspace with a host application and a separate library package.
In the library package, import and use an antd DatePicker, which requires passing the generateConfig prop.
Import the required helper via a deep import: import momentGenerateConfig from 'rc-picker/lib/generate/moment';.
Ensure shamefully-hoist is disabled (pnpm's default).
Attempt to run the application. The build or runtime will fail because the deep import cannot be resolved.

Expected behavior
Essential helpers like generateConfig should be part of the library's public API and exportable from the main entry point, eliminating the need for fragile deep imports. This would ensure compatibility with modern, strict package managers like pnpm out of the box.

Proposed Solution & Pull Request
To solve this and improve the developer experience, the generateConfig helpers should be exported from the main index.tsx file.
This allows developers to switch from the brittle deep import:

// Old, fragile way
import momentGenerateConfig from 'rc-picker/lib/generate/moment';

To a robust, top-level import that works with any package manager:

// New, robust way
import { momentGenerateConfig } from '@rc-component/picker';

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the main index.tsx and reproduce the deep-import failure in a pnpm workspace with shamefully-hoist disabled. Done means the generateConfig helpers, including momentGenerateConfig, can be imported from @rc-component/picker's top-level API without relying on deep imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
api, developer-experience
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.