Reproduction link or steps
Reproduction link: https://github.com/romain-trotard/rolldownCjsTsTsxRepro
See lib/from-ts.js and lib/from-tsx.js files
What is expected?
I would expect both cjs generated files to be the same, with :
let mock_cjs = require("mock-cjs");
mock_cjs = require_chunk.__toESM(mock_cjs);
What is actually happening?
But currently only the cjs generated file for tsx has:
let mock_cjs = require("mock-cjs");
mock_cjs = require_chunk.__toESM(mock_cjs);
node lib/from-tsx.cjs works
The cjs generated file for the ts file contains:
let mock_cjs = require("mock-cjs");
mock_cjs = require_chunk.__toESM(mock_cjs, 1);
which causes mock_cjs.default.div to be undefined in this case
node lib/from-ts.cjs fails
System Info
System:
OS: macOS 26.5.1
CPU: (10) arm64 Apple M1 Pro
Memory: 545.19 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 26.3.0 - /Users/romain.trotard/.volta/tools/image/node/26.3.0/bin/node
Yarn: 1.19.0 - /Users/romain.trotard/.volta/tools/image/yarn/1.19.0/bin/yarn
npm: 11.16.0 - /Users/romain.trotard/.volta/tools/image/node/26.3.0/bin/npm
pnpm: 10.12.4 - /Users/romain.trotard/.volta/bin/pnpm
bun: 1.3.3 - /Users/romain.trotard/.bun/bin/bun
Browsers:
Chrome: 148.0.7778.216
Firefox: 148.0
Safari: 26.5
npmPackages:
rolldown: ^1.1.0 => 1.1.0
Any additional comments?
I found this issue when working with styled-components library.
Reproduction link or steps
Reproduction link: https://github.com/romain-trotard/rolldownCjsTsTsxRepro
See
lib/from-ts.jsandlib/from-tsx.jsfilesWhat is expected?
I would expect both cjs generated files to be the same, with :
What is actually happening?
But currently only the cjs generated file for
tsxhas:The cjs generated file for the
tsfile contains:which causes
mock_cjs.default.divto beundefinedin this caseSystem Info
System: OS: macOS 26.5.1 CPU: (10) arm64 Apple M1 Pro Memory: 545.19 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 26.3.0 - /Users/romain.trotard/.volta/tools/image/node/26.3.0/bin/node Yarn: 1.19.0 - /Users/romain.trotard/.volta/tools/image/yarn/1.19.0/bin/yarn npm: 11.16.0 - /Users/romain.trotard/.volta/tools/image/node/26.3.0/bin/npm pnpm: 10.12.4 - /Users/romain.trotard/.volta/bin/pnpm bun: 1.3.3 - /Users/romain.trotard/.bun/bin/bun Browsers: Chrome: 148.0.7778.216 Firefox: 148.0 Safari: 26.5 npmPackages: rolldown: ^1.1.0 => 1.1.0Any additional comments?
I found this issue when working with
styled-componentslibrary.