cube-js / cube-js/cube

@cubejs-client/core: package.json is missing @babel/runtime as a declared dependency

Open
#10,952 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

## Summary

`@cubejs-client/core` (every version on npm I checked, latest 1.6.51 included) ships a precompiled CommonJS bundle (`dist/cubejs-client-core.cjs.js`) that calls `require('@babel/runtime/helpers/...')` for 16 different helpers at load time, but the package's `dependencies` block does not declare `@babel/runtime`.

In any consumer environment where `@babel/runtime` is not pulled in as a transitive of some other dependency — e.g. a `pnpm install --prod` (devDeps pruned), a fresh npm install in a clean tree, or yarn 3 PnP — Node throws `MODULE_NOT_FOUND: Cannot find module '@babel/runtime/helpers/'` the moment the consumer references any value (not just types) from `@cubejs-client/core`.

This appears to be the same defect reported in #5670 in 2022 (closed as `question` without a fix). The packaging issue persists across 22 patch releases since.

## Reproduction

```bash
mkdir cubejs-repro && cd cubejs-repro
echo '{"name":"repro","private":true,"dependencies":{"@cubejs-client/core":"^1.6.51"}}' > package.json

# Production install — no devDeps, no incidental hoists.
npm install --omit=dev
node -e "require('@cubejs-client/core')"
```

Output:

```
Error: Cannot find module '@babel/runtime/helpers/toArray'
Require stack:
- .../node_modules/@cubejs-client/core/dist/cubejs-client-core.cjs.js
```

In dev installs, `@babel/runtime` typically gets pulled in as a transitive of some unrelated devDep (in our case, `concurrently → date-fns → @babel/runtime`) and the issue is masked. The first production deploy with a value import of the package surfaces it.

## Compiled requires

```
$ grep -oE "@babel/runtime/helpers/[a-zA-Z]+" \
node_modules/@cubejs-client/core/dist/cubejs-client-core.cjs.js | sort -u
@babel/runtime/helpers/asyncToGenerator
@babel/runtime/helpers/awaitAsyncGenerator
@babel/runtime/helpers/classCallCheck
@babel/runtime/helpers/createClass
@babel/runtime/helpers/defineProperty
@babel/runtime/helpers/getPrototypeOf
@babel/runtime/helpers/inherits
@babel/runtime/helpers/objectWithoutProperties
@babel/runtime/helpers/possibleConstructorReturn
@babel/runtime/helpers/readOnlyError
@babel/runtime/helpers/slicedToArray
@babel/runtime/helpers/toArray
@babel/runtime/helpers/toConsumableArray
@babel/runtime/helpers/typeof
@babel/runtime/helpers/wrapAsyncGenerator
@babel/runtime/helpers/wrapNativeSuper
```

`@cubejs-client/core@1.6.51` `dependencies` (current `npm view`):

```
core-js, cross-fetch, d3-format, d3-time-format, dayjs, ramda,
url-search-params-polyfill, uuid
```

No `@babel/runtime`.

## Expected

`@babel/runtime` is declared as a runtime dependency of `@cubejs-client/core` (or the build is changed so that the compiled output does not require it).

## Suggested fix

The compiled output references `@babel/runtime/helpers/*`, which is the signature of `@babel/plugin-transform-runtime` injecting runtime helpers. Add `@babel/runtime` to `dependencies` in `packages/cubejs-client-core/package.json` (matching the version used at build time, or `^7` as a floor).

Consumers can work around this in pnpm using `pnpm.packageExtensions`:

```yaml
# pnpm-workspace.yaml
packageExtensions:
'@cubejs-client/core':
dependencies:
'@babel/runtime': ^7.22.5
```

…but this should not be necessary; the package's own `package.json` should declare what it requires at runtime.

## Environment

- `@cubejs-client/core`: 1.6.29 (verified same defect in latest 1.6.51 via `npm view`)
- Node: 24.x
- Package manager: pnpm 11 with `pnpm install --prod --frozen-lockfile`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.