32127e54 Dropped apache-arrow from the Elasticsearch client
no ref
Ghost pulls apache-arrow in through @tryghost/logging and @tryghost/metrics,
which both depend on @tryghost/elasticsearch and so on the 8.x Elasticsearch
client. That client requires apache-arrow at module scope, but the only things
that touch it are the ES|QL helpers `toArrowTable` and `toArrowReader` — neither
of which Ghost calls, and neither of which @tryghost/elasticsearch can reach: it
only ever indexes documents.
The 9.x client already fixed this, deferring the require behind a `loadArrow()`
try/catch. We can't take 9.x, because it needs Elasticsearch 9 and our instance
isn't there yet, so the patch backports that: the module-scope require becomes a
lazy `loadArrow()` throwing 9.x's own "Package apache-arrow is required for Arrow
functionality" message, and the two helpers call it on entry. The `.d.ts` import
becomes `import type`, as 9.x has it.
Removing the dependency is the readPackage hook in .pnpmfile.mjs, not the patch —
pnpm resolves from the registry manifest and applies patches afterwards, so a
manifest edit inside the patch changes nothing about what gets installed. That's
the same tool this repo already uses for consolidate's peers, knex's sqlite3 and
the typescript peers on viem/ox/abitype. It deletes the dependency rather than
re-declaring it as the optional peer 9.x has, because autoInstallPeers is on by
default and installs optional peers anyway — and doing so peer-forks
@tryghost/logging and everything above it (elasticsearch, metrics, job-manager,
prometheus-metrics, domain-events, knex-migrator) into `(apache-arrow@21.1.0)`
variants for no benefit.
So the installed package.json still names apache-arrow as a dependency that
isn't there. The try/catch is what makes that safe.
That takes 15 packages and ~15MB out of the install — apache-arrow itself plus
flatbuffers, json-bignum, the command-line-args/usage tree and @types/node 24 —
and the phantom `@75lb/nature` peer disappears from eight packages' transitive
peer lists with them. A process that configures the Elasticsearch log transport
loads 145 fewer modules and measures ~3.3MB less RSS, averaged over three runs
each way with a forced GC.
Both packaging paths were already generic over `patchedDependencies` after the
juice patch landed, so the new patch rides along: pack.mjs copies and validates
every patch the trimmed workspace names, and docker/ghost-dev copies the whole
patches dir. The release archive gets no .pnpmfile.mjs, but its lockfile is
seeded from this one and pnpm reuses the seeded snapshot rather than
re-resolving, so arrow stays out there too — verified by reproducing that step.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013AjXHCDS7EaJmRKmtggwfU 3e2a398a Dropped apache-arrow from the Elasticsearch client
no ref
Ghost pulls apache-arrow in through @tryghost/logging and @tryghost/metrics,
which both depend on @tryghost/elasticsearch and so on the 8.x Elasticsearch
client. That client requires apache-arrow at module scope, but the only things
that touch it are the ES|QL helpers `toArrowTable` and `toArrowReader` — neither
of which Ghost calls, and neither of which @tryghost/elasticsearch can reach: it
only ever indexes documents.
The 9.x client already fixed this, deferring the require behind a `loadArrow()`
try/catch. We can't take 9.x, because it needs Elasticsearch 9 and our instance
isn't there yet, so the patch backports that: the module-scope require becomes a
lazy `loadArrow()` throwing 9.x's own "Package apache-arrow is required for Arrow
functionality" message, and the two helpers call it on entry. The `.d.ts` import
becomes `import type`, as 9.x has it.
Removing the dependency is the readPackage hook in .pnpmfile.mjs, not the patch —
pnpm resolves from the registry manifest and applies patches afterwards, so a
manifest edit inside the patch changes nothing about what gets installed. That's
the same tool this repo already uses for consolidate's peers, knex's sqlite3 and
the typescript peers on viem/ox/abitype. It deletes the dependency rather than
re-declaring it as the optional peer 9.x has, because autoInstallPeers is on by
default and installs optional peers anyway — and doing so peer-forks
@tryghost/logging and everything above it (elasticsearch, metrics, job-manager,
prometheus-metrics, domain-events, knex-migrator) into `(apache-arrow@21.1.0)`
variants for no benefit.
So the installed package.json still names apache-arrow as a dependency that
isn't there. The try/catch is what makes that safe.
That takes 15 packages and ~15MB out of the install — apache-arrow itself plus
flatbuffers, json-bignum, the command-line-args/usage tree and @types/node 24 —
and the phantom `@75lb/nature` peer disappears from eight packages' transitive
peer lists with them. A process that configures the Elasticsearch log transport
loads 145 fewer modules and measures ~3.3MB less RSS, averaged over three runs
each way with a forced GC.
Both packaging paths were already generic over `patchedDependencies` after the
juice patch landed, so the new patch rides along: pack.mjs copies and validates
every patch the trimmed workspace names, and docker/ghost-dev copies the whole
patches dir. The release archive gets no .pnpmfile.mjs, but its lockfile is
seeded from this one and pnpm reuses the seeded snapshot rather than
re-resolving, so arrow stays out there too — verified by reproducing that step.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013AjXHCDS7EaJmRKmtggwfU 584acf90 Dropped apache-arrow from the Elasticsearch client
no ref
Ghost pulls apache-arrow in through @tryghost/logging and @tryghost/metrics,
which both depend on @tryghost/elasticsearch and so on the 8.x Elasticsearch
client. That client requires apache-arrow at module scope, but the only things
that touch it are the ES|QL helpers `toArrowTable` and `toArrowReader` — neither
of which Ghost calls, and neither of which @tryghost/elasticsearch can reach: it
only ever indexes documents.
The 9.x client already fixed this, deferring the require behind a `loadArrow()`
try/catch. We can't take 9.x, because it needs Elasticsearch 9 and our instance
isn't there yet, so the patch backports that: the module-scope require becomes a
lazy `loadArrow()` throwing 9.x's own "Package apache-arrow is required for Arrow
functionality" message, and the two helpers call it on entry. The `.d.ts` import
becomes `import type`, as 9.x has it.
Removing the dependency is the readPackage hook in .pnpmfile.mjs, not the patch —
pnpm resolves from the registry manifest and applies patches afterwards, so a
manifest edit inside the patch changes nothing about what gets installed. That's
the same tool this repo already uses for consolidate's peers, knex's sqlite3 and
the typescript peers on viem/ox/abitype. It deletes the dependency rather than
re-declaring it as the optional peer 9.x has, because autoInstallPeers is on by
default and installs optional peers anyway — and doing so peer-forks
@tryghost/logging and everything above it (elasticsearch, metrics, job-manager,
prometheus-metrics, domain-events, knex-migrator) into `(apache-arrow@21.1.0)`
variants for no benefit.
So the installed package.json still names apache-arrow as a dependency that
isn't there. The try/catch is what makes that safe.
That takes 15 packages and ~15MB out of the install — apache-arrow itself plus
flatbuffers, json-bignum, the command-line-args/usage tree and @types/node 24 —
and the phantom `@75lb/nature` peer disappears from eight packages' transitive
peer lists with them. A process that configures the Elasticsearch log transport
loads 145 fewer modules and measures ~3.3MB less RSS, averaged over three runs
each way with a forced GC.
Both packaging paths were already generic over `patchedDependencies` after the
juice patch landed, so the new patch rides along: pack.mjs copies and validates
every patch the trimmed workspace names, and docker/ghost-dev copies the whole
patches dir. The release archive gets no .pnpmfile.mjs, but its lockfile is
seeded from this one and pnpm reuses the seeded snapshot rather than
re-resolving, so arrow stays out there too — verified by reproducing that step.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013AjXHCDS7EaJmRKmtggwfU 73a5dd19 Dropped apache-arrow from the Elasticsearch client
no ref
Ghost pulls apache-arrow in through @tryghost/logging and @tryghost/metrics,
which both depend on @tryghost/elasticsearch and so on the 8.x Elasticsearch
client. That client requires apache-arrow at module scope, but the only things
that touch it are the ES|QL helpers `toArrowTable` and `toArrowReader` — neither
of which Ghost calls, and neither of which @tryghost/elasticsearch can reach: it
only ever indexes documents.
The 9.x client already fixed this, deferring the require behind a `loadArrow()`
try/catch. We can't take 9.x, because it needs Elasticsearch 9 and our instance
isn't there yet, so the patch backports that: the module-scope require becomes a
lazy `loadArrow()` throwing 9.x's own "Package apache-arrow is required for Arrow
functionality" message, and the two helpers call it on entry. The `.d.ts` import
becomes `import type`, as 9.x has it.
Removing the dependency is the readPackage hook in .pnpmfile.mjs, not the patch —
pnpm resolves from the registry manifest and applies patches afterwards, so a
manifest edit inside the patch changes nothing about what gets installed. That's
the same tool this repo already uses for consolidate's peers, knex's sqlite3 and
the typescript peers on viem/ox/abitype. It deletes the dependency rather than
re-declaring it as the optional peer 9.x has, because autoInstallPeers is on by
default and installs optional peers anyway — and doing so peer-forks
@tryghost/logging and everything above it (elasticsearch, metrics, job-manager,
prometheus-metrics, domain-events, knex-migrator) into `(apache-arrow@21.1.0)`
variants for no benefit.
So the installed package.json still names apache-arrow as a dependency that
isn't there. The try/catch is what makes that safe.
That takes 15 packages and ~15MB out of the install — apache-arrow itself plus
flatbuffers, json-bignum, the command-line-args/usage tree and @types/node 24 —
and the phantom `@75lb/nature` peer disappears from eight packages' transitive
peer lists with them. A process that configures the Elasticsearch log transport
loads 145 fewer modules and measures ~3.3MB less RSS, averaged over three runs
each way with a forced GC.
Both packaging paths were already generic over `patchedDependencies` after the
juice patch landed, so the new patch rides along: pack.mjs copies and validates
every patch the trimmed workspace names, and docker/ghost-dev copies the whole
patches dir. The release archive gets no .pnpmfile.mjs, but its lockfile is
seeded from this one and pnpm reuses the seeded snapshot rather than
re-resolving, so arrow stays out there too — verified by reproducing that step.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013AjXHCDS7EaJmRKmtggwfU