Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@
],
"main": "./lib/index",
"module": "./es/index",
"types": "./es/index.d.ts",
"exports": {
".": {
"types": "./es/index.d.ts",
"import": "./es/index.js",
"require": "./lib/index.js"
},
"./assets/*": "./assets/*",
"./locale/*": {
"types": "./es/locale/*.d.ts",
"import": "./es/locale/*.js",
"require": "./lib/locale/*.js"
},
"./lib/locale/*": {
"types": "./es/locale/*.d.ts",
"import": "./es/locale/*.js",
"require": "./lib/locale/*.js"
},
"./es/locale/*": {
"types": "./es/locale/*.d.ts",
"import": "./es/locale/*.js",
"require": "./lib/locale/*.js"
}
},
Comment on lines +16 to +38

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In Node.js package resolution, once a package.json defines an "exports" field, do previously published but unlisted subpaths such as "./es/*" or "./lib/*" become inaccessible with ERR_PACKAGE_PATH_NOT_EXPORTED?

💡 Result:

Yes. Once a package.json defines an

Citations:


兼容性:exports 收紧可能导致未声明的 ./es/* / ./lib/* 深路径失效(ERR_PACKAGE_PATH_NOT_EXPORTED)
package.jsonexports(16-38)中只显式暴露了 ".""./assets/*"、以及各类 locale/*。一旦发布了 exports,任何“历史上可访问但未在该映射中列出”的子路径(例如 @rc-component/pagination/es/...@rc-component/pagination/lib/...)都会变成不可导出,从而引发 ERR_PACKAGE_PATH_NOT_EXPORTED——这相当于一次未声明的 breaking change(除非你就是要收敛 API)。

  • 为保持兼容:补上通用的 ./es/*./lib/* 导出(或等价规则)。
  • 若就是有意收敛/破坏兼容:需要按 breaking change 处理(发布策略/变更说明/版本升级)。
建议的兼容性修正
   "exports": {
     ".": {
       "types": "./es/index.d.ts",
       "import": "./es/index.js",
       "require": "./lib/index.js"
     },
     "./assets/*": "./assets/*",
+    "./es/*": {
+      "types": "./es/*.d.ts",
+      "import": "./es/*.js",
+      "require": "./lib/*.js"
+    },
+    "./lib/*": {
+      "types": "./es/*.d.ts",
+      "import": "./es/*.js",
+      "require": "./lib/*.js"
+    },
     "./locale/*": {
       "types": "./es/locale/*.d.ts",
       "import": "./es/locale/*.js",
       "require": "./lib/locale/*.js"
     },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` around lines 16 - 38, The package "exports" mapping currently
only exposes ".", "./assets/*", and locale paths which will block historical
deep imports like "./es/*" and "./lib/*" and cause
ERR_PACKAGE_PATH_NOT_EXPORTED; to fix, restore compatibility by adding general
export entries for "./es/*" and "./lib/*" (or equivalent patterns) to the
"exports" field so those deep paths are explicitly exported, or if you intend a
breaking change, clearly document and version it as a breaking release; target
the "exports" object in package.json and add mappings for "./es/*" and "./lib/*"
(and their types/import/require variations) to match your existing locale
patterns.

"files": [
"assets/*.css",
"assets/*.less",
Expand Down Expand Up @@ -42,11 +66,11 @@
"prepare": "husky"
},
"dependencies": {
"@rc-component/util": "^1.3.0",
"@rc-component/util": "^1.11.1",
"clsx": "^2.1.1"
},
"devDependencies": {
"@rc-component/father-plugin": "^2.0.2",
"@rc-component/father-plugin": "^2.2.0",
"@rc-component/np": "^1.0.3",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^16.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/Options.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import KEYCODE from '@rc-component/util/lib/KeyCode';
import { KeyCode } from '@rc-component/util';
import React from 'react';
import type { PaginationLocale } from './interface';

Expand Down Expand Up @@ -85,7 +85,7 @@ const Options: React.FC<OptionsProps> = (props) => {
if (goInputText === '') {
return;
}
if (e.keyCode === KEYCODE.ENTER || e.type === 'click') {
if (e.keyCode === KeyCode.ENTER || e.type === 'click') {
setGoInputText('');
quickGo?.(getValidValue);
}
Expand Down
10 changes: 6 additions & 4 deletions src/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { clsx } from 'clsx';
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
import KeyCode from '@rc-component/util/lib/KeyCode';
import pickAttrs from '@rc-component/util/lib/pickAttrs';
import warning from '@rc-component/util/lib/warning';
import {
KeyCode,
pickAttrs,
useControlledState,
warning,
} from '@rc-component/util';
import React, { useEffect } from 'react';
import type { PaginationProps } from './interface';
import zhCN from './locale/zh_CN';
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { RenderResult } from '@testing-library/react';
import { render, fireEvent } from '@testing-library/react';
import React from 'react';
import Pagination from '../src';
import { resetWarned } from '@rc-component/util/lib/warning';
import { resetWarned } from '@rc-component/util';
import { sizeChangerRender } from './commonUtil';

describe('Default Pagination', () => {
Expand Down