Skip to content

[Button]: @uiw/react-* packages import @babel/runtime without declaring it in dependencies #995

Closed

Description

@trackoor

描述错误

The @uiw/react-* component packages are compiled with tsbb build "src/*.{ts,tsx}" --use-babel --cjs cjs, so their published esm/*.js files import @babel/runtime/helpers/* (such as @babel/runtime/helpers/extends) and cjs/*.js files require @babel/runtime/helpers/interopRequireDefault. However, @babel/runtime is only declared in packages/uiw/package.json and is missing from packages/react-*/package.json. Installing a single component package as shown in its README (import Button from '@uiw/react-button') fails at build or import time unless another package happens to install @babel/runtime.

错误复现

mkdir repro && cd repro && npm init -y >/dev/null
npm i @uiw/[email protected] [email protected] [email protected]
node -e "require('@uiw/react-button')"

Actual output in Node.js (import('@uiw/react-button') fails with the same error):

Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
Require stack:
- .../repro/node_modules/@uiw/react-button/cjs/index.js
- .../repro/[eval]

Bundling esm/index.js also fails:

npm i -D esbuild
printf 'import React from "react";\nimport Button from "@uiw/react-button";\nexport default () => <Button type="primary">Hi</Button>;\n' > app.jsx
./node_modules/.bin/esbuild app.jsx --bundle --loader:.css=empty --outfile=out.js
✘ [ERROR] Could not resolve "@babel/runtime/helpers/extends"

    node_modules/@uiw/react-button/esm/index.js:1:21:
      1 │ import _extends from "@babel/runtime/helpers/extends";
        ╵                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "@babel/runtime/helpers/objectWithoutPropertiesLoose"

    node_modules/@uiw/react-button/esm/index.js:2:42:
      2 │ ...esLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
        ╵                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

提供在线重现示例

Not applicable: package dependency / npm install issue; the CodeSandbox template installs the umbrella uiw package, which already declares @babel/runtime.

预期行为

Each @uiw/react-* package whose compiled cjs/ and esm/ output imports @babel/runtime/helpers/* lists @babel/runtime in dependencies (as packages/uiw/package.json already does), so individual component packages work without installing uiw or @babel/runtime separately.

截图

N/A

桌面(请填写以下信息):

  • UIW:@uiw/[email protected] (latest), master (72b5da40)
  • 操作系统:Linux x86_64
  • 浏览器:N/A (Node.js / bundler build)
  • 版本和构建:Node.js v26.13.0, npm 11.20.0, esbuild 0.28.2

智能手机(请填写以下信息):

  • 设备:N/A
  • 操作系统:N/A
  • 浏览器:N/A
  • 版本:N/A

附加上下文

All 59 @uiw/react-* packages under packages/ emit @babel/runtime/helpers/* imports in cjs/ and esm/, while none of their package.json files declare @babel/runtime.

Credit: https://ucsbplse.github.io/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions