ensureBrowserProcess
Ensures the bundle runs against a process global that browser-targeting packages recognize.
Serialized into the emitted banner, so it never runs in the builder process — but it is an ordinary function here, so it is unit-tested directly rather than by evaluating the banner text.
Fills in the keys MISSING from a host-provided
processrather than replacing or skipping it. Obsidian Mobile exposes a partialprocess, and the whole-object guards this replaced (if (globalThis.process) { return; }/globalThisRecord['process'] ??= …) took that as “already shimmed”, sobrowsernever landed. The bundleddebugpackage then selected its Node entry point, which callsrequire('util').deprecate()at module top level, and on mobile the patchedrequirereturns{}— so the plugin threw before itsonloadran.A real Node or Electron
processis left completely untouched.process.versions.nodeis the signal for it, and — unlikeglobalThis.app.isMobile— it is self-contained, so it also holds in the Node CLI bundles this banner is emitted into, where no Obsidianappexists.
Import:
import { ensureBrowserProcess } from 'obsidian-dev-utils/script-utils/bundlers/esbuild-impl/preprocess-plugin';Signature:
function ensureBrowserProcess(): voidReturns: void