Skip to content

Commit fd144bb

Browse files
authored
feat: experimental web support (#200)
Signed-off-by: Todd Baert <[email protected]>
1 parent ce7c4ad commit fd144bb

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is the JavaScript implementation of [OpenFeature](https://openfeature.dev),
1010

1111
We support multiple data types for flags (numbers, strings, booleans, objects) as well as hooks, which can alter the lifecycle of a flag evaluation.
1212

13-
This library is intended to be used in server-side contexts and has not been evaluated for use client-side or on mobile devices.
13+
**This library is intended to be used in server-side contexts and has only experimental support for web usage.**
1414

1515
## Installation
1616

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@
3636
"dist/"
3737
],
3838
"exports": {
39-
"node": {
40-
"import": "./dist/esm/index.js",
41-
"require": "./dist/cjs/index.js",
42-
"default": "./dist/esm/index.js"
43-
}
39+
"import": "./dist/esm/index.js",
40+
"require": "./dist/cjs/index.js",
41+
"default": "./dist/cjs/index.js"
4442
},
4543
"devDependencies": {
4644
"@types/jest": "^28.1.4",

src/open-feature.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const GLOBAL_OPENFEATURE_API_KEY = Symbol.for('@openfeature/js.api');
99
type OpenFeatureGlobal = {
1010
[GLOBAL_OPENFEATURE_API_KEY]?: OpenFeatureAPI;
1111
};
12-
const _global = global as OpenFeatureGlobal;
12+
const _globalThis = globalThis as OpenFeatureGlobal;
1313

1414
class OpenFeatureAPI implements GlobalApi {
1515
private _provider: Provider = NOOP_PROVIDER;
@@ -18,13 +18,13 @@ class OpenFeatureAPI implements GlobalApi {
1818
private _logger: Logger = new DefaultLogger();
1919

2020
static getInstance(): OpenFeatureAPI {
21-
const globalApi = _global[GLOBAL_OPENFEATURE_API_KEY];
21+
const globalApi = _globalThis[GLOBAL_OPENFEATURE_API_KEY];
2222
if (globalApi) {
2323
return globalApi;
2424
}
2525

2626
const instance = new OpenFeatureAPI();
27-
_global[GLOBAL_OPENFEATURE_API_KEY] = instance;
27+
_globalThis[GLOBAL_OPENFEATURE_API_KEY] = instance;
2828
return instance;
2929
}
3030

0 commit comments

Comments
 (0)