diff --git a/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift b/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift index c5eed713..dceb100f 100644 --- a/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift +++ b/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift @@ -206,12 +206,14 @@ public class JSObject: Equatable { /// This allows access to the global properties and global names by accessing the `JSObject` returned. public static var global: JSObject { return _global } - // `JSObject` storage itself is immutable, and use of `JSObject.global` from other - // threads maintains the same semantics as `globalThis` in JavaScript. + #if compiler(>=5.10) @LazyThreadLocal(initialize: { return JSObject(id: _JS_Predef_Value_Global) }) private static var _global: JSObject + #else + private static let _global = JSObject(id: _JS_Predef_Value_Global) + #endif deinit { assertOnOwnerThread(hint: "deinitializing")