Reproduction link or steps
Four files:
package.json
{ "type": "module", "devDependencies": { "rolldown": "1.0.0-rc.16" } }
v4.ts
export default function v4() { return "uuid-here"; }
index.ts
export { default as v4 } from "./v4.js";
rolldown.config.ts
import { defineConfig } from "rolldown";
export default defineConfig({
input: "./index.ts",
output: { format: "cjs", dir: "dist" },
});
Run:
npm install
npx rolldown -c
node -e 'const { v4 } = require("./dist/index.cjs"); console.log(typeof v4); v4();'
Output:
object
TypeError: v4 is not a function
What is expected?
require("./dist/index.cjs").v4 should be the function (the default export of v4.ts), matching the ESM emit and the .d.cts types which declare v4 as a function.
Expected emitted CJS:
exports.v4 = require_v4.default;
What is actually happening?
require("./dist/index.cjs").v4 resolves to the module wrapper { default: [Function v4] }. Calling it throws TypeError: v4 is not a function.
Actual emitted CJS:
const require_v4 = require("./v4.cjs");
exports.v4 = require_v4; // ← namespace wrapper, not the default value
ESM emit is correct; only the CJS path mishandles the default specifier in re-exports. Hit in production by @langchain/core@1.1.42+ — see langchain-ai/langchainjs#10827.
System Info
System:
OS: macOS 26.4.1
CPU: (14) arm64 Apple M4 Max
Memory: 271.16 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.13.0 - /Users/arnavgupta/.nvm/versions/node/v24.13.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 11.8.0 - /Users/arnavgupta/.nvm/versions/node/v24.13.0/bin/npm
pnpm: 10.14.0 - /opt/homebrew/bin/pnpm
Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 147.1.89.145
Chrome: 147.0.7727.138
Safari: 26.4
npmPackages:
rolldown: 1.0.0-rc.16
Any additional comments?
The issue is causing a langchain bug too
langchain-ai/langchainjs#10827.
Reproduction link or steps
Four files:
package.json{ "type": "module", "devDependencies": { "rolldown": "1.0.0-rc.16" } }v4.ts
index.ts
rolldown.config.ts
Run:
npm install npx rolldown -c node -e 'const { v4 } = require("./dist/index.cjs"); console.log(typeof v4); v4();'Output:
What is expected?
require("./dist/index.cjs").v4should be the function (the default export ofv4.ts), matching the ESM emit and the.d.ctstypes which declarev4as a function.Expected emitted CJS:
What is actually happening?
require("./dist/index.cjs").v4resolves to the module wrapper{ default: [Function v4] }. Calling it throwsTypeError: v4 is not a function.Actual emitted CJS:
System Info
System: OS: macOS 26.4.1 CPU: (14) arm64 Apple M4 Max Memory: 271.16 MB / 36.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.13.0 - /Users/arnavgupta/.nvm/versions/node/v24.13.0/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 11.8.0 - /Users/arnavgupta/.nvm/versions/node/v24.13.0/bin/npm pnpm: 10.14.0 - /opt/homebrew/bin/pnpm Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman Browsers: Brave Browser: 147.1.89.145 Chrome: 147.0.7727.138 Safari: 26.4 npmPackages: rolldown: 1.0.0-rc.16Any additional comments?
The issue is causing a langchain bug too
langchain-ai/langchainjs#10827.