Summary
react-show-more-text@1.7.2 (published 2026-04-18) ships a rolldown-bundled ESM at dist/index.es.js that calls require("react") through an indirect helper webpack/rspack can't statically rewrite. At runtime the helper falls into its fallback branch and throws, crashing any page that renders <ShowMoreText>.
Likely the same underlying ESM-bundle bug as #78 (which is the Vite-side symptom: does not provide an export named 'default').
Error
Uncaught Error: Calling `require` for "react" in an environment that doesn't expose the `require` function.
See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.
Evidence
Top of the published dist/index.es.js:
import e,{Component as t}from"react";
import r,{PropTypes as n}from"prop-types";
var o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),
i=/* @__PURE__ */(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){
if("undefined"!=typeof require)return require.apply(this,arguments);
throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")
}),
s=/* @__PURE__ */o(e=>{
var t=i("react"), // <-- thrown here in browsers
r=Symbol.for("react.element"),
n=Symbol.for("react.fragment"),
...
The i("react") call (the indirect rolldown CJS shim) is what blows up. Webpack can't see it as a static require("react") and leaves it alone, so the helper's fallback throw is what executes.
Root cause
The rolldown build inlines a CJS copy of react/jsx-runtime into the ESM bundle and re-requires react from inside that inlined copy. react is marked external but react/jsx-runtime is not, so the bundler emits the runtime require shim instead of a real ESM import.
How to reproduce
npm install react-show-more-text@1.7.2 react react-dom in any webpack 5 project (no special config — happens with stock CRA-style setups too).
import ShowMoreText from 'react-show-more-text' and render anywhere.
- Production build, load the page. The chunk containing ShowMoreText throws the error above as soon as the module evaluates.
Suggested fixes (any one)
- Drop the
exports["."].import / module fields in package.json. Consumers fall back to dist/index.cjs.js, which is well-formed.
- In the rolldown config, mark
react/jsx-runtime as external alongside react (or both react/*), so the bundler emits a normal import { jsx } from 'react/jsx-runtime' instead of inlining + re-requiring.
- Ship the ESM by re-emitting through a bundler whose CJS-interop path doesn't require a runtime
require (e.g. tsup with --external react --external react/jsx-runtime).
Workaround for downstream users
Pin to 1.7.1 — it ships only the babel-compiled CJS at lib/ShowMoreText.js and works fine.
Happy to send a PR if helpful — just let me know which approach you'd prefer.
Summary
react-show-more-text@1.7.2(published 2026-04-18) ships a rolldown-bundled ESM atdist/index.es.jsthat callsrequire("react")through an indirect helper webpack/rspack can't statically rewrite. At runtime the helper falls into its fallback branch and throws, crashing any page that renders<ShowMoreText>.Likely the same underlying ESM-bundle bug as #78 (which is the Vite-side symptom:
does not provide an export named 'default').Error
Evidence
Top of the published
dist/index.es.js:The
i("react")call (the indirect rolldown CJS shim) is what blows up. Webpack can't see it as a staticrequire("react")and leaves it alone, so the helper's fallbackthrowis what executes.Root cause
The rolldown build inlines a CJS copy of
react/jsx-runtimeinto the ESM bundle and re-requiresreactfrom inside that inlined copy.reactis marked external butreact/jsx-runtimeis not, so the bundler emits the runtime require shim instead of a real ESMimport.How to reproduce
npm install react-show-more-text@1.7.2 react react-domin any webpack 5 project (no special config — happens with stock CRA-style setups too).import ShowMoreText from 'react-show-more-text'and render anywhere.Suggested fixes (any one)
exports["."].import/modulefields inpackage.json. Consumers fall back todist/index.cjs.js, which is well-formed.react/jsx-runtimeas external alongsidereact(or bothreact/*), so the bundler emits a normalimport { jsx } from 'react/jsx-runtime'instead of inlining + re-requiring.require(e.g. tsup with--external react --external react/jsx-runtime).Workaround for downstream users
Pin to
1.7.1— it ships only the babel-compiled CJS atlib/ShowMoreText.jsand works fine.Happy to send a PR if helpful — just let me know which approach you'd prefer.