bvaughn / react-resizable-panels

https://react-resizable-panels.vercel.app/
MIT License
3.99k stars 144 forks source link

react-resizable-panels re-exports all react method types. #431

Closed Tenkir closed 4 days ago

Tenkir commented 5 days ago

Context

Currently, it appears that the react-resizable-panels package re-exports all the underlying React method types (like useState, useRef, etc). Presumable this should not be the case, and I made the mistake of auto-importing from this package quite a few times.

The types are coming from react-resizable-panels/dist/declarations/src/vendor/react.d.ts. I suspect this is an issue with the build pipline in use during releases.

Example

image

Version

2.1.6

bvaughn commented 4 days ago

I think you're mistaken. Looking at the latest release, here's what's exported:

CJS:

exports.Panel = Panel;
exports.PanelGroup = PanelGroup;
exports.PanelResizeHandle = PanelResizeHandle;
exports.assert = assert;
exports.disableGlobalCursorStyles = disableGlobalCursorStyles;
exports.enableGlobalCursorStyles = enableGlobalCursorStyles;
exports.getIntersectingRectangle = getIntersectingRectangle;
exports.getPanelElement = getPanelElement;
exports.getPanelElementsForGroup = getPanelElementsForGroup;
exports.getPanelGroupElement = getPanelGroupElement;
exports.getResizeHandleElement = getResizeHandleElement;
exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
exports.intersects = intersects;
exports.setNonce = setNonce;

MJS:

export {
  Panel,
  PanelGroup,
  PanelResizeHandle,
  assert,
  disableGlobalCursorStyles,
  enableGlobalCursorStyles,
  getIntersectingRectangle,
  getPanelElement,
  getPanelElementsForGroup,
  getPanelGroupElement,
  getResizeHandleElement,
  getResizeHandleElementIndex,
  getResizeHandleElementsForGroup,
  getResizeHandlePanelIds,
  intersects,
  setNonce
} from "./react-resizable-panels.browser.cjs.js";

ESM:

export { Panel, PanelGroup, PanelResizeHandle, assert, disableGlobalCursorStyles, enableGlobalCursorStyles, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects, setNonce };

I assume this is some kind of environmental misconfiguration on your side. Sorry :)

Tenkir commented 21 hours ago

I think you're mistaken. Looking at the latest release, here's what's exported:

This is an issue with the type definitions, not the CJS or ESM exports.

I assume this is some kind of environmental misconfiguration on your side. Sorry :)

I'm able to reproduce this issue when cloning this repo and rebuilding.

I also have a minimum reproduction here.

Per the comment in packages/react-resizable-panels/src/vendor/react.ts, I assume this stems from the fix for https://github.com/webpack/webpack/issues/14814.