Skip to content

fix: ship csv-parse stream cjs export#490

Open
YfengJ wants to merge 1 commit into
adaltas:masterfrom
YfengJ:codex/fix-csv-parse-stream-cjs-export
Open

fix: ship csv-parse stream cjs export#490
YfengJ wants to merge 1 commit into
adaltas:masterfrom
YfengJ:codex/fix-csv-parse-stream-cjs-export

Conversation

@YfengJ

@YfengJ YfengJ commented Jun 19, 2026

Copy link
Copy Markdown

Summary

csv-parse declares a CommonJS export target for csv-parse/stream:

"./stream": {
  "require": {
    "types": "./dist/cjs/stream.d.cts",
    "default": "./dist/cjs/stream.cjs"
  }
}

However, the package currently ships only index and sync files under dist/cjs, so CommonJS consumers hit MODULE_NOT_FOUND when using require("csv-parse/stream").

This PR makes the declared CommonJS stream subpath real by:

  • adding a Rollup CJS build for lib/stream.js
  • copying lib/stream.d.ts to dist/cjs/stream.d.cts during build:ts
  • adding a regression test that loads the exact exports["./stream"].require.default target from package.json

Runtime source code and public API behavior are unchanged; this aligns the published files with the package export map.

Validation

  • Watched the new regression test fail before the fix with missing dist/cjs/stream.cjs
  • npm run build
  • npx mocha 'test/api.stream.cjs_export.js'
  • Full package test in a temporary no-space path because the existing samples test path handling breaks when the checkout path contains %20: npm test -> 608 passing, 3 pending
  • npm pack --ignore-scripts --json ., verified the tarball contains:
    • package/dist/cjs/stream.cjs
    • package/dist/cjs/stream.d.cts
  • Required the packed CJS stream file and verified parse is exported
  • npx eslint packages/csv-parse/rollup.config.js packages/csv-parse/test/api.stream.cjs_export.js
  • git diff --check

Note: the full npm run lint:check --workspace csv-parse currently fails on unrelated existing lint issues in test/api.sync.ts and test/api.web_stream.ts, plus existing pending-test warnings. The files touched by this PR pass eslint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant