Skip to content

feat(csv-parse): expose native browser Web Streams - #535

Draft
Huzaifa-Asif wants to merge 1 commit into
adaltas:masterfrom
Huzaifa-Asif:feat/csv-parse-browser-web-streams
Draft

Huzaifa-Asif wants to merge 1 commit into
adaltas:masterfrom
Huzaifa-Asif:feat/csv-parse-browser-web-streams

Conversation

@Huzaifa-Asif

Copy link
Copy Markdown

Browser users cannot use csv-parse/stream because it imports node:stream/web, and there is no browser Web Streams export. Add csv-parse/browser/esm/stream backed by native browser streams:

import { parse } from "csv-parse/browser/esm/stream";
const response = await fetch("data.csv");
const reader = response.body.pipeThrough(parse({ columns: true })).getReader();

Normalize native Uint8Array chunks before the shared parser buffers them, retain the Buffer polyfill notices, and generate isolated DOM declarations from the existing parser options. Native Web Streams support is required. This is scoped to csv-parse.

Closes #449

Validation on Node24.18.1/macOS and Chrome154:

  • Original browser import fails with ERR_PACKAGE_PATH_NOT_EXPORTED. With the export added but unchanged stream wrapper, the one-byte regression fails in Buffer.concat; all7 focused runtime/type tests pass with normalization.
  • Full package suite:625 passed,3 pending,1 pre-existing failure. Untouched base:618 passed,3 pending,the same failure (group_columns_by_name expects an boolean while source emits a boolean). The full suite is not green.
  • Rollup/type build, package TypeScript checking, ESLint (0errors,3existing warnings), changed-file Prettier and diff checks pass.
  • Legacy test commands exclude the browser-only tests, matching their existing Web Streams exclusions (selection checked on Node24; no Node16 run claimed).
  • The installed tarball passes strict DOM-only TypeScript checks and8 real-browser cases: native fetch bytes, split BOM/Unicode/delimiters, final flush, empty input, errors, record limits and cancellation.

Existing index/sync generated bundles are left out; the build also exposes unrelated base generated-file drift. No full operating-system/runtime matrix is claimed.

AI disclosure: OpenAI Codex researched and implemented this change and ran the local checks. A separate agent reviewed the frozen patch before submission. Human maintainer review is requested; no claim of personal human code review is made.

Expose a browser-native Web Streams entry and normalize native byte chunks. Include DOM-only declarations, focused regressions, browser usage documentation, and existing polyfill notices.

AI-assisted implementation and tests; independently reviewed by a separate agent.
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.

Export stream interface for browsers (esm)

1 participant