Repository navigation
fix(seo): compile and run the published source outside Node - #954
Merged
Merged
Conversation
The package ships `src/`, so an application compiles these files with its own tsconfig and runs them in its own host. `useStrayOwnerDiagnostic` read `process.env.NODE_ENV` with nothing declaring `process`: the package tsconfig pins `types: ["node"]` and hid it, while a browser application has neither the types nor the global, so the file failed to compile and threw a ReferenceError out of every <Head> render wherever nothing substituted the read. The remaining errors were `exactOptionalPropertyTypes` and `noUncheckedIndexedAccess`. `SeoConfig` now admits `undefined` alongside optional, matching what the merge has always done with it, and the two loops that index an array they just measured say so. Behavior is unchanged for an application that already built. The new test pins the production skip, which is the part of the diagnostic the rewritten guard could have dropped.
trueadm
marked this pull request as ready for review
September 5, 2026 17:26
14 of 21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@octanejs/seopublishessrc/, so an application compiles these files with its own tsconfig and runs them in its own host. Both halves were broken.It does not compile without Node types. This is the repo's own consumer project,
scripts/consumer-tsconfigs/seo.json, onmain:The package tsconfig pins
types: ["node"], which hid it in here. And it is not only a type error: a browser has noprocess, so any host that does not substitute the read threw a ReferenceError out of every<Head>render, in place of a development-only check. The reference is now declared locally and guarded withtypeof, followingpackages/lynx/src/core/environment.ts. It stays spelled out asprocess.env.NODE_ENVso bundler defines still fold it.One trade-off worth naming: where a bundler substitutes the value but leaves no
processglobal, the guard reads false and the diagnostic behaves as it does in development, one counter and one effect per owning<Head>. That is the price of not throwing, and it is the arrangement React-ecosystem packages end up in too.It does not compile under
exactOptionalPropertyTypesornoUncheckedIndexedAccess, which plenty of applications turn on:SeoConfig's fields now admitundefinedalongside being optional, which is what they have always meant:applyConfigand the registry merge read each one with an!== undefinedtest, so an absent key and a presentundefinedare the same thing, and<Seo>can go on forwarding its optional props in one expression. The two loops that index an array they just measured say so.Found while building an Octane app. It was shipping a
pnpm patchagainst the published tarball; this is the same fix upstream.Validation
Repo-wide
pnpm typecheckandpnpm testwere not run.pnpm format:checkpnpm typecheckpnpm testtsrx-tsc -p packages/seo/tsconfig.json,vitest run --project "*seo*"(11 files, 105 tests)tsrx-tsc -p scripts/consumer-tsconfigs/seo.jsonnow passes; it fails onmainwith the error aboveexactOptionalPropertyTypesandnoUncheckedIndexedAccessreports nothing from this packageThe no-
processpath has no runtime test.vi.stubGlobal('process', undefined)takes the Vitest worker down with it (Cannot set properties of undefined (setting 'nextTick')), so the crash is covered by the consumer typecheck and by the guard being atypeoftest. The new test pins the other half, the production skip, which the rewritten guard could have dropped silently.Risk / follow-ups
SeoConfigis exported, so the widened fields are a public type change. It only accepts more, and no consumer expression stops compiling.The strict-flag half has no gate.
scripts/consumer-tsconfigs/base.jsonmirrors whatoctane initscaffolds, which leaves both flags off, and turning them on in a package tsconfig pullspackages/octane/srcinto the program, where the same classes of error exist in bulk. A real consumer never sees those, becauseoctanepublishesdistwith declarations behindskipLibCheck, while every@octanejs/*binding publishes source. The header ofscripts/generate-consumer-tsconfigs.mjsalready records that debt against #721; widening those projects is worth doing once core is clean.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Mostly typing and a dev-only diagnostic guard; exported
SeoConfigwidens acceptably, with no intended runtime behavior change for apps that already built.Overview
@octanejs/seoships source, so consumer apps compile it with their own tsconfig and run it in browser hosts. This PR fixes compile-time and runtime failures that only showed up there.useStrayOwnerDiagnosticno longer assumes Node: it declaresprocesslocally and guards withtypeof process !== 'undefined'before readingprocess.env.NODE_ENV, so builds without@types/nodetypecheck and hosts without aprocessglobal stop throwing on every<Head>render. The expression staysprocess.env.NODE_ENVso bundlers can still inline production.Strict TypeScript consumers get type-only fixes:
SeoConfigfields explicitly allowundefined(matching existing!== undefinedmerge semantics underexactOptionalPropertyTypes), and indexed array reads inexpand.ts/registry.tsuse non-null assertions undernoUncheckedIndexedAccess. A test asserts the stray-<Head>diagnostic stays off whenNODE_ENVis production.Reviewed by Cursor Bugbot for commit 5fdad39. Bugbot is set up for automated code reviews on this repo. Configure here.