From b586f878765bdfb490110db5fe4580116d835548 Mon Sep 17 00:00:00 2001 From: Monica Date: Tue, 26 Nov 2024 17:09:32 +1100 Subject: [PATCH] V3: Fix environment checks (#229) --- .../atlaspack-v3/worker/compat/environment.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/core/core/src/atlaspack-v3/worker/compat/environment.js b/packages/core/core/src/atlaspack-v3/worker/compat/environment.js index cc04528a4..78e667a50 100644 --- a/packages/core/core/src/atlaspack-v3/worker/compat/environment.js +++ b/packages/core/core/src/atlaspack-v3/worker/compat/environment.js @@ -50,34 +50,35 @@ export class Environment implements IEnvironment { this.unstableSingleFileOutput = false; } - // TODO isBrowser(): boolean { - return true; + return ( + this.context === 'browser' || + this.isWorker() || + this.isWorklet() || + this.context === 'electron-renderer' + ); } - // TODO isNode(): boolean { - return false; + return this.context === 'node' || this.isElectron(); } - // TODO isElectron(): boolean { - return false; + return ( + this.context === 'electron-main' || this.context === 'electron-renderer' + ); } - // TODO isWorker(): boolean { - return false; + return this.context === 'web-worker' || this.context === 'service-worker'; } - // TODO isWorklet(): boolean { - return false; + return this.context === 'worklet'; } - // TODO isIsolated(): boolean { - return false; + return this.isWorker() || this.isWorklet(); } // TODO