Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-women-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"varlock": patch
---

fix runtime env code to not assume process (or shim) exists - for sveltekit
5 changes: 3 additions & 2 deletions packages/varlock/src/runtime/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ let varlockInjectedProcessEnvKeys: Array<string> | undefined;
export function initVarlockEnv(opts?: {
allowFail?: boolean,
}) {
debug('⚡️ INIT VARLOCK ENV!', initializedEnv, !!(globalThis as any).__varlockLoadedEnv, processExists && !!process.env.__VARLOCK_ENV);
debug('⚡️ INIT VARLOCK ENV!', initializedEnv, !!(globalThis as any).__varlockLoadedEnv, !!globalThis.process?.env.__VARLOCK_ENV);

// normally we can just bail if we detect we are in the browser
// however when front-end related tests, it may appear that we are in the browser but it is not
if (isBrowser && !process.env.__VARLOCK_ENV) {
// also some frameworks inject a process polyfill, others do not
if (isBrowser && !globalThis.process?.env.__VARLOCK_ENV) {
initializedEnv = true;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/varlock/src/runtime/lib/debug.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
export function debug(...args: Array<any>) {
if (!process.env.DEBUG_VARLOCK) return;
if (!globalThis.process?.env.DEBUG_VARLOCK) return;
console.log(...args);
}