fix(webworker): expose Node process identity
This commit is contained in:
1 parent
ba54d722a1
commit
8f88a6f207
2 files changed
+6
-1
No files matched your search
@@ -2,7 +2,8 @@
|
||||
* The `process` global the worker needs before any VFS module runs. Cordis
|
||||
* reads `process.env` and `process.versions.node` while the Loader is
|
||||
* constructed, and `cordis.yml` keeps its `!!js process.*` expressions, so the
|
||||
* configuration bytes stay identical to the Node deployment.
|
||||
* configuration bytes stay identical to the Node deployment. Third-party Node
|
||||
* packages use the presence of `process.title` to avoid browser-only globals.
|
||||
* @module @deepseek-ai/dsh-experimental-webworker-runtime/src/node/globals/process
|
||||
*/
|
||||
import { requireActiveModuleLoader } from '../../module-system/module-loader.ts'
|
||||
@@ -23,6 +24,8 @@ export interface ProcessShim {
|
||||
readonly env: Record<string, string>
|
||||
readonly argv: string[]
|
||||
readonly execArgv: string[]
|
||||
/** Node process identity used by dependencies for environment detection. */
|
||||
readonly title: string
|
||||
/**
|
||||
* Node 22 `process.getBuiltinModule`: the worker's module proxy for a
|
||||
* builtin id (`fs`, `node:fs`), or undefined for anything else — it never
|
||||
@@ -86,6 +89,7 @@ export function installProcessGlobal(options: ProcessShimOptions): ProcessShim {
|
||||
env: { ...options.env },
|
||||
argv: [...(options.argv ?? ['node', 'dsh-webworker'])],
|
||||
execArgv: [],
|
||||
title: 'dsh-webworker',
|
||||
platform: 'linux',
|
||||
arch: 'x64',
|
||||
pid: 1,
|
||||
|
||||
@@ -19,6 +19,7 @@ describe('process shim', () => {
|
||||
const shim = installProcessGlobal({ cwd: '/dsh', env: { DSH_HOME: '/dsh/home' } })
|
||||
expect(shim.cwd()).toBe('/dsh')
|
||||
expect(shim.env.DSH_HOME).toBe('/dsh/home')
|
||||
expect(shim.title).toBe('dsh-webworker')
|
||||
// "0.0.0" keeps the vendored Loader off Node internals so the worker owns
|
||||
// the module seam.
|
||||
expect(shim.versions.node).toBe('0.0.0')
|
||||
|
||||
Reference in new issue
Block a user