@peers-app/peers-sdk 0.12.3 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -99,6 +99,10 @@ class PackageLoader {
|
|
|
99
99
|
// a fatal native error if passed through to RN's require). We block them here
|
|
100
100
|
// and throw a descriptive JS Error instead, which the surrounding try/catch
|
|
101
101
|
// converts into a warning rather than a process-killing crash.
|
|
102
|
+
//
|
|
103
|
+
// In Node.js / Electron environments these modules ARE available, so we skip
|
|
104
|
+
// the guard and let require pass through normally.
|
|
105
|
+
const isNodeEnvironment = typeof process !== 'undefined' && !!process.versions?.node;
|
|
102
106
|
const NODE_ONLY_MODULES = new Set([
|
|
103
107
|
'child_process', 'fs', 'path', 'os', 'crypto', 'http', 'https',
|
|
104
108
|
'net', 'tls', 'stream', 'buffer', 'util', 'events', 'assert',
|
|
@@ -123,7 +127,7 @@ class PackageLoader {
|
|
|
123
127
|
// external Node modules they need (e.g. child_process, os, path), and the loader
|
|
124
128
|
// should verify they are allowed before granting access. For now we pass through
|
|
125
129
|
// to the underlying require and log a warning so usages remain visible.
|
|
126
|
-
if (NODE_ONLY_MODULES.has(moduleId)) {
|
|
130
|
+
if (!isNodeEnvironment && NODE_ONLY_MODULES.has(moduleId)) {
|
|
127
131
|
// Throw a plain JS Error so the surrounding try/catch can handle it
|
|
128
132
|
// gracefully instead of letting RN's require trigger a native fatal.
|
|
129
133
|
throw new Error(`[PackageLoader] Package "${pkg.name}" required Node.js-only module "${moduleId}" which is not available in this environment`);
|