@parcel/feature-flags 2.12.1-dev.3238 → 2.12.1-dev.3260

Sign up to get free protection for your applications and to get access to all the features.
package/lib/index.js CHANGED
@@ -4,8 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DEFAULT_FEATURE_FLAGS = void 0;
7
+ exports.getFeatureFlag = getFeatureFlag;
8
+ exports.setFeatureFlags = setFeatureFlags;
7
9
  // We need to do these gymnastics as we don't want flow-to-ts to touch DEFAULT_FEATURE_FLAGS,
8
10
  // but we want to export FeatureFlags for Flow
9
11
  const DEFAULT_FEATURE_FLAGS = exports.DEFAULT_FEATURE_FLAGS = {
10
- exampleFeature: false
11
- };
12
+ exampleFeature: false,
13
+ configKeyInvalidation: false,
14
+ parcelV3: false,
15
+ dfsFasterRefactor: false
16
+ };
17
+ let featureFlagValues = {
18
+ ...DEFAULT_FEATURE_FLAGS
19
+ };
20
+ function setFeatureFlags(flags) {
21
+ featureFlagValues = flags;
22
+ }
23
+ function getFeatureFlag(flagName) {
24
+ return featureFlagValues[flagName];
25
+ }
package/lib/types.d.ts CHANGED
@@ -1,4 +1,21 @@
1
1
  export type FeatureFlags = {
2
2
  // This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
3
3
  readonly exampleFeature: boolean;
4
+
5
+ /**
6
+ * Enables content hash based invalidation for config keys used in plugins.
7
+ * This allows Assets not to be invalidated when using
8
+ * `config.getConfigFrom(..., {packageKey: '...'})` and the value itself hasn't changed.
9
+ */
10
+ readonly configKeyInvalidation: boolean;
11
+
12
+ /**
13
+ * Refactors dfsNew to use an iterative approach.
14
+ */
15
+ readonly dfsFasterRefactor: boolean;
16
+
17
+ /**
18
+ * Rust backed requests
19
+ */
20
+ readonly parcelV3: boolean;
4
21
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@parcel/feature-flags",
3
- "version": "2.12.1-dev.3238+7f6b4dbbc",
4
- "description": "Blazing fast, zero configuration web application bundler",
3
+ "version": "2.12.1-dev.3260+339350eb3",
4
+ "description": "Provides internal feature-flags for the parcel codebase.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -24,5 +24,5 @@
24
24
  "engines": {
25
25
  "node": ">= 16.0.0"
26
26
  },
27
- "gitHead": "7f6b4dbbc56a203e0fce8794856c03598c4f6708"
27
+ "gitHead": "339350eb31fd33849cb1efe5fd7ad2cb096319f0"
28
28
  }
package/src/index.js CHANGED
@@ -7,4 +7,17 @@ export type FeatureFlags = _FeatureFlags;
7
7
 
8
8
  export const DEFAULT_FEATURE_FLAGS: FeatureFlags = {
9
9
  exampleFeature: false,
10
+ configKeyInvalidation: false,
11
+ parcelV3: false,
12
+ dfsFasterRefactor: false,
10
13
  };
14
+
15
+ let featureFlagValues: FeatureFlags = {...DEFAULT_FEATURE_FLAGS};
16
+
17
+ export function setFeatureFlags(flags: FeatureFlags) {
18
+ featureFlagValues = flags;
19
+ }
20
+
21
+ export function getFeatureFlag(flagName: $Keys<FeatureFlags>): boolean {
22
+ return featureFlagValues[flagName];
23
+ }
package/src/types.js CHANGED
@@ -3,4 +3,18 @@
3
3
  export type FeatureFlags = {|
4
4
  // This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
5
5
  +exampleFeature: boolean,
6
+ /**
7
+ * Enables content hash based invalidation for config keys used in plugins.
8
+ * This allows Assets not to be invalidated when using
9
+ * `config.getConfigFrom(..., {packageKey: '...'})` and the value itself hasn't changed.
10
+ */
11
+ +configKeyInvalidation: boolean,
12
+ /**
13
+ * Refactors dfsNew to use an iterative approach.
14
+ */
15
+ +dfsFasterRefactor: boolean,
16
+ /**
17
+ * Rust backed requests
18
+ */
19
+ +parcelV3: boolean,
6
20
  |};
@@ -0,0 +1,21 @@
1
+ // @flow strict
2
+ import assert from 'assert';
3
+ import {getFeatureFlag, DEFAULT_FEATURE_FLAGS, setFeatureFlags} from '../src';
4
+
5
+ describe('feature-flag test', () => {
6
+ beforeEach(() => {
7
+ setFeatureFlags(DEFAULT_FEATURE_FLAGS);
8
+ });
9
+
10
+ it('has defaults', () => {
11
+ assert.equal(
12
+ getFeatureFlag('exampleFeature'),
13
+ DEFAULT_FEATURE_FLAGS.exampleFeature,
14
+ );
15
+ });
16
+
17
+ it('can override', () => {
18
+ setFeatureFlags({...DEFAULT_FEATURE_FLAGS, exampleFeature: true});
19
+ assert.equal(getFeatureFlag('exampleFeature'), true);
20
+ });
21
+ });