@intlayer/config
Version:
Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.
41 lines • 901 B
JavaScript
import {
loadEnvFile
} from "./envVariables/loadEnvFile.mjs";
import { ESMxCJSRequire } from "./utils/ESMxCJSHelpers.mjs";
const getSandBoxContext = (envVarOptions, projectRequire = ESMxCJSRequire) => {
let additionalGlobalVar = {};
try {
additionalGlobalVar = {
React: projectRequire("react")
};
} catch (err) {
}
const sandboxContext = {
exports: {
default: {}
},
module: {
exports: {}
},
process: {
...process,
env: {
...process.env,
...loadEnvFile(envVarOptions)
}
},
console,
require: projectRequire,
...additionalGlobalVar
};
Object.getOwnPropertyNames(globalThis).forEach((key) => {
if (!(key in sandboxContext)) {
sandboxContext[key] = globalThis[key];
}
});
return sandboxContext;
};
export {
getSandBoxContext
};
//# sourceMappingURL=getSandboxContext.mjs.map