Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ChALkeR
Copy link
Contributor

@ChALkeR ChALkeR commented Oct 9, 2025

This removes 24% of the lines in worker.js

Before and after:

   11638 pnpm/dist.0/worker.js
    8853 pnpm/dist.1/worker.js

See https://github.com/ndjson/ndjson.js/blob/master/index.js, the whole dep is trivial

  1. Only parse was used here, so 2 other deps were not needed at all
  2. An updated version of split2 is zero-dep

It's heavily used: https://www.npmjs.com/package/split2?activeTab=versions
Though drops Node.js <12: https://github.com/mcollina/split2/releases/tag/v4.0.0 😉

@zkochan zkochan requested a review from Copilot October 9, 2025 14:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Replaces the ndjson dependency with split2 by inlining the ndjson parsing functionality, reducing bundle size by 24% (from 11,638 to 8,853 lines in worker.js).

  • Removes ndjson dependency and adds split2 dependency
  • Creates custom ndjsonParse.ts module with only the parse functionality needed
  • Updates import statements in streamParser.ts to use the new custom module

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Updates catalog dependencies, removing ndjson and adding split2
packages/logger/src/streamParser.ts Updates import to use custom ndjson parse module
packages/logger/src/ndjsonParse.ts New custom implementation of ndjson parse functionality
packages/logger/package.json Updates package dependencies from ndjson to split2
.changeset/small-gifts-wonder.md Documents the change for release notes
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (row) return JSON.parse(row)
} catch (e) {
if (opts.strict) {
this.emit('error', new Error(`Could not parse row ${row.slice(0, 50)}...`))
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message truncates the row at 50 characters but doesn't indicate if truncation occurred. Consider adding a conditional indicator like '...' only when the row is actually longer than 50 characters.

Suggested change
this.emit('error', new Error(`Could not parse row ${row.slice(0, 50)}...`))
this.emit('error', new Error(`Could not parse row ${row.length > 50 ? row.slice(0, 50) + '...' : row}`))

Copilot uses AI. Check for mistakes.
}
}

return split(parseRow, opts)
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opts parameter passed to split() contains strict: true which may not be a valid option for split2. The strict option was used in the parseRow function but split2 may not recognize this option.

Suggested change
return split(parseRow, opts)
return split(parseRow)

Copilot uses AI. Check for mistakes.
@zkochan zkochan merged commit b9effa2 into pnpm:main Oct 9, 2025
10 checks passed
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.

2 participants