react-scan 0.5.6+ fails on Rspack: named export from react-grab/package.json

Author: QiRainingCreated Jul 22, 2026Updated Jul 25, 2026

Description

[email protected] fails to build with Rsbuild/Rspack because its published ESM bundle uses a named import from a JSON module:

import { version as REACT_GRAB_VERSION } from "react-grab/package.json";

Rspack treats react-grab/package.json as a default-exporting JSON module, so the named version export cannot be linked.

Reproduction

import { scan } from "react-scan";

scan({
  enabled: true,
});

Then run an Rsbuild production build.

Environment A

  • react-scan: 0.5.7
  • react-grab: 0.1.37
  • @rsbuild/core: 2.0.5
  • @rspack/core: 2.0.2
  • React: 18.3.1
  • Node.js: 20.19.6
  • pnpm: 10.12.1

Environment B

I also reproduced after upgrading the complete bundler pair:

  • react-scan: 0.5.7
  • @rsbuild/core: 2.1.7
  • @rspack/core: 2.1.5
  • React: 18.3.1
  • Node.js: 20.19.6
  • pnpm: 10.12.1

Actual behavior

ESModulesLinkingError: Can't import the named export 'version'
(imported as 'REACT_GRAB_VERSION') from default-exporting module
(only default export is available)

File: react-scan/dist/index.mjs

Import trace:

src/index.tsx
src/bootstrap.tsx
src/App.tsx
react-scan/dist/index.mjs

Expected behavior

Importing scan from react-scan should build successfully with current Rsbuild/Rspack.

Regression range

Upgrading Rspack from 2.0.2 to 2.1.5 does not resolve the error.

Suggested fix

Avoid emitting a named JSON import in the published ESM bundle. For example, use a default JSON import and read .version, or preferably inject the react-grab version as a string during the react-scan build so consumers do not need to bundle react-grab/package.json.

Thank you.