@webiny/feature-flags 6.0.0-alpha.5 β 6.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -93
- package/index.d.ts +1 -6
- package/index.js +4 -9
- package/index.js.map +1 -1
- package/package.json +7 -10
package/README.md
CHANGED
|
@@ -1,97 +1,11 @@
|
|
|
1
|
-
#
|
|
2
|
-
[](https://www.npmjs.com/package/@webiny/feature-flags)
|
|
3
|
-
[](https://www.npmjs.com/package/@webiny/feature-flags)
|
|
4
|
-
[](https://github.com/prettier/prettier)
|
|
5
|
-
[](http://makeapullrequest.com)
|
|
1
|
+
# @webiny/feature-flags
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> Itβs **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
π **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
- [Overview](#overview)
|
|
13
|
-
- [Examples](#examples)
|
|
14
|
-
- [Reference](#reference)
|
|
15
|
-
- [Objects](#objects)
|
|
16
|
-
- [`featureFlags`](#featureFlags)
|
|
9
|
+
---
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
npm install --save @webiny/feature-flags
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Or if you prefer yarn:
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
yarn add @webiny/feature-flags
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Overview
|
|
32
|
-
|
|
33
|
-
The `@webiny/feature-flags` exports a single `featureFlags` object which contains all of the feature flags initially set via the Webiny project's `webiny.project.ts` config file, via its `featureFlags` property.
|
|
34
|
-
|
|
35
|
-
For example, given the following `webiny.project.ts` config file;
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
// webiny.project.ts
|
|
39
|
-
export default {
|
|
40
|
-
name: "webiny-js",
|
|
41
|
-
cli: {
|
|
42
|
-
...
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
// Feature flags are defined via a simple JavaScript object.
|
|
46
|
-
featureFlags: {
|
|
47
|
-
myCustomFeatureFlag: false,
|
|
48
|
-
someFeature: { enabled: true, myCustomProperty: 123, thisIsJson: "yes"}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Within both backend and frontend application code, the `featureFlags` object can then be read like so:
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
import { featureFlags } from "@webiny/feature-flags";
|
|
57
|
-
|
|
58
|
-
const useMyCustomFeature = featureFlags.myCustomFeatureFlag;
|
|
59
|
-
|
|
60
|
-
const someOtherFeatureMyCustomProperty = featureFlags.someFeature.myCustomProperty;
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
> **NOTE**
|
|
64
|
-
>
|
|
65
|
-
> Behind the scenes, it's the [Webiny CLI](https://www.webiny.com/docs/core-development-concepts/basics/webiny-cli) that enables the propagation of the `featureFlags` object into the actual applications. As mentioned, the `featureFlags` object can be accessed within both backend and frontend application code.
|
|
66
|
-
|
|
67
|
-
## Examples
|
|
68
|
-
|
|
69
|
-
No additional examples.
|
|
70
|
-
|
|
71
|
-
## Reference
|
|
72
|
-
|
|
73
|
-
### Objects
|
|
74
|
-
|
|
75
|
-
#### `featureFlags`
|
|
76
|
-
|
|
77
|
-
<details>
|
|
78
|
-
<summary>Type Declaration</summary>
|
|
79
|
-
<p>
|
|
80
|
-
|
|
81
|
-
```ts
|
|
82
|
-
declare let featureFlags: Record<string, any>;
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
</p>
|
|
86
|
-
</details>
|
|
87
|
-
|
|
88
|
-
The `featureFlags` object contains all of the feature flags initially set via the Webiny project's `webiny.project.ts` config file, via its `featureFlags` property.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
import { featureFlags } from "@webiny/feature-flags";
|
|
93
|
-
|
|
94
|
-
const useMyCustomFeature = featureFlags.myCustomFeatureFlag;
|
|
95
|
-
|
|
96
|
-
const someOtherFeatureMyCustomProperty = featureFlags.someFeature.myCustomProperty;
|
|
97
|
-
```
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export type FeatureFlags<TFeatureFlags = Record<string, any>> = {
|
|
2
|
-
allowCmsLegacyRichTextInput?: boolean;
|
|
3
|
-
cmsLegacyEntryEditor?: boolean;
|
|
4
|
-
experimentalDynamicPages?: boolean;
|
|
5
|
-
newWatchCommand?: boolean;
|
|
6
|
-
} & TFeatureFlags;
|
|
1
|
+
export type FeatureFlags<TFeatureFlags = Record<string, any>> = {} & TFeatureFlags;
|
|
7
2
|
declare let featureFlags: FeatureFlags;
|
|
8
3
|
export { featureFlags };
|
package/index.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.featureFlags = void 0;
|
|
7
|
-
let featureFlags = exports.featureFlags = {};
|
|
1
|
+
let featureFlags = {};
|
|
8
2
|
|
|
9
3
|
// In API applications.
|
|
10
4
|
if (process.env.WEBINY_FEATURE_FLAGS) {
|
|
11
|
-
|
|
5
|
+
featureFlags = JSON.parse(process.env.WEBINY_FEATURE_FLAGS);
|
|
12
6
|
|
|
13
7
|
// In React applications.
|
|
14
8
|
} else if (process.env.REACT_APP_WEBINY_FEATURE_FLAGS) {
|
|
15
|
-
|
|
9
|
+
featureFlags = JSON.parse(process.env.REACT_APP_WEBINY_FEATURE_FLAGS);
|
|
16
10
|
}
|
|
11
|
+
export { featureFlags };
|
|
17
12
|
|
|
18
13
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["featureFlags","
|
|
1
|
+
{"version":3,"names":["featureFlags","process","env","WEBINY_FEATURE_FLAGS","JSON","parse","REACT_APP_WEBINY_FEATURE_FLAGS"],"sources":["index.ts"],"sourcesContent":["export type FeatureFlags<TFeatureFlags = Record<string, any>> = {} & TFeatureFlags;\n\nlet featureFlags: FeatureFlags = {};\n\n// In API applications.\nif (process.env.WEBINY_FEATURE_FLAGS) {\n featureFlags = JSON.parse(process.env.WEBINY_FEATURE_FLAGS) as FeatureFlags;\n\n // In React applications.\n} else if (process.env.REACT_APP_WEBINY_FEATURE_FLAGS) {\n featureFlags = JSON.parse(process.env.REACT_APP_WEBINY_FEATURE_FLAGS) as FeatureFlags;\n}\n\nexport { featureFlags };\n"],"mappings":"AAEA,IAAIA,YAA0B,GAAG,CAAC,CAAC;;AAEnC;AACA,IAAIC,OAAO,CAACC,GAAG,CAACC,oBAAoB,EAAE;EAClCH,YAAY,GAAGI,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACC,GAAG,CAACC,oBAAoB,CAAiB;;EAE3E;AACJ,CAAC,MAAM,IAAIF,OAAO,CAACC,GAAG,CAACI,8BAA8B,EAAE;EACnDN,YAAY,GAAGI,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACC,GAAG,CAACI,8BAA8B,CAAiB;AACzF;AAEA,SAASN,YAAY","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/feature-flags",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -12,18 +13,14 @@
|
|
|
12
13
|
],
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"devDependencies": {
|
|
15
|
-
"@types/uniqid": "5.3.
|
|
16
|
-
"@webiny/
|
|
17
|
-
"rimraf": "6.
|
|
18
|
-
"typescript": "5.
|
|
16
|
+
"@types/uniqid": "5.3.4",
|
|
17
|
+
"@webiny/build-tools": "6.0.0-rc.0",
|
|
18
|
+
"rimraf": "6.1.3",
|
|
19
|
+
"typescript": "5.9.3"
|
|
19
20
|
},
|
|
20
21
|
"publishConfig": {
|
|
21
22
|
"access": "public",
|
|
22
23
|
"directory": "dist"
|
|
23
24
|
},
|
|
24
|
-
"
|
|
25
|
-
"build": "node ../cli/bin.js run build",
|
|
26
|
-
"watch": "node ../cli/bin.js run watch"
|
|
27
|
-
},
|
|
28
|
-
"gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
|
|
25
|
+
"gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
|
|
29
26
|
}
|