Is the module that owns meta (pass import.meta) the process entry point,
i.e. was it started with node <file> rather than imported? Use it to guard
the "connect the real provider" block so botmesh dev (and your tests) can
import the factory without connecting to a real transport.
Uses import.meta.main when the runtime provides it (Node >= 22.18 / 24.2)
and otherwise compares the module's real path with process.argv[1].
Caveat: process managers that import() your file from their own wrapper
(e.g. pm2 in ESM mode) make this false; point them at a tiny start file that
imports the factory and starts it instead.
Is the module that owns
meta(passimport.meta) the process entry point, i.e. was it started withnode <file>rather than imported? Use it to guard the "connect the real provider" block sobotmesh dev(and your tests) can import the factory without connecting to a real transport.Uses
import.meta.mainwhen the runtime provides it (Node >= 22.18 / 24.2) and otherwise compares the module's real path withprocess.argv[1].Caveat: process managers that
import()your file from their own wrapper (e.g. pm2 in ESM mode) make thisfalse; point them at a tiny start file that imports the factory and starts it instead.