Skip to content

fix(tiptap): guard the process.env read in useEditor - #1501

Closed
aleclarson wants to merge 1 commit into
octanejs:mainfrom
aleclarson:fix/tiptap-process-env-guard
Closed

aleclarson wants to merge 1 commit into
octanejs:mainfrom
aleclarson:fix/tiptap-process-env-guard

Conversation

@aleclarson

@aleclarson aleclarson commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Guard the bare process.env.NODE_ENV read in useEditor so source consumers without a process global (or Node types) can compile the package.

Why

  • The package ships sources for consumers to compile with their own toolchain. A program without types: ["node"] fails typecheck on the bare process reference, and a non-Node runtime (embedded JS engines, e.g. NativeScript V8) throws at evaluation.
  • Found while wiring @octanejs/tiptap into a NativeScript app: the mobile program has no Node globals.

Changes

  • src/useEditor.ts: const isDev = typeof process === 'undefined' || process.env?.NODE_ENV !== 'production'; — absent process reads as development, keeping dev-time checks when the env cannot be consulted.

Validation

  • pnpm format:files (changed files unchanged)
  • pnpm typecheck:files (tsrx-tsc, clean)
  • targeted tests: vitest run --project tiptap --project tiptap-ssr --project tiptap-pristine --project tiptap-upstream --project tiptap-differential — 25 files / 45 tests pass
  • pnpm format:check (not run — repo-wide)
  • pnpm test (not run — repo-wide)

Risk / follow-ups

  • One-line semantic change inside a useEditor constant; parity with upstream @tiptap/react's dev-gate behavior preserved where process exists.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Single guarded constant for dev detection; production behavior unchanged when process is present, with dev-mode warnings possible when process is absent.

Overview
@octanejs/tiptap ships source for downstream toolchains; this patch makes useEditor safe when there is no Node process global or Node typings.

isDev no longer reads process.env.NODE_ENV unconditionally. It uses typeof process === 'undefined' || process.env?.NODE_ENV !== 'production', so missing process avoids typecheck/runtime failures (e.g. NativeScript) while still treating non-production builds as dev when env is available. SSR/Next.js dev warnings that depend on isDev behave the same when process exists. A patch changeset records the release.

Reviewed by Cursor Bugbot for commit 5cbb702. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 1, 2026
@aleclarson
aleclarson marked this pull request as ready for review October 1, 2026 15:39
@aleclarson aleclarson closed this Oct 1, 2026
aleclarson added a commit to octane-xplat/octane-xplat that referenced this pull request Oct 1, 2026
…iptap patch

PR octanejs/octane#1501 (process.env guard) was closed upstream; the
patched source should not diverge in runtime behavior. The patch now only
adds a module-local process declaration for typecheck and keeps the
Context merge, which is being upstreamed as octanejs/octane#1502.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant