@atlaspack/feature-flags 2.14.1-dev.11 → 2.14.1-dev.123

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/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # @atlaspack/feature-flags
2
2
 
3
+ ## 2.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#582](https://github.com/atlassian-labs/atlaspack/pull/582) [`f4da1e1`](https://github.com/atlassian-labs/atlaspack/commit/f4da1e120e73eeb5e8b8927f05e88f04d6148c7b) Thanks [@matt-koko](https://github.com/matt-koko)! - Export DEFAULT_FEATURE_FLAGS so it will be included in the associate type declaration file and able to be imported elsewhere.
8
+
9
+ This will enable patterns like:
10
+
11
+ ```
12
+ import type { FeatureFlags } from '@atlaspack/feature-flags';
13
+ import { DEFAULT_FEATURE_FLAGS } from '@atlaspack/feature-flags';
14
+ ```
15
+
16
+ ### Patch Changes
17
+
18
+ - [#503](https://github.com/atlassian-labs/atlaspack/pull/503) [`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818) Thanks [@JakeLane](https://github.com/JakeLane)! - Fix conditional bundling reporter when condition is reused
19
+
20
+ ## 2.15.1
21
+
22
+ ### Patch Changes
23
+
24
+ - [#551](https://github.com/atlassian-labs/atlaspack/pull/551) [`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b) Thanks [@yamadapc](https://github.com/yamadapc)! - Log request tracker invalidation counts on start-up
25
+
26
+ ## 2.15.0
27
+
28
+ ### Minor Changes
29
+
30
+ - [#547](https://github.com/atlassian-labs/atlaspack/pull/547) [`a1773d2`](https://github.com/atlassian-labs/atlaspack/commit/a1773d2a62d0ef7805ac7524621dcabcc1afe929) Thanks [@benjervis](https://github.com/benjervis)! - Add a feature flag for resolving the configuration for `@atlaspack/bundler-default` from CWD, rather than exclusively from the project root.
31
+
32
+ ## 2.14.4
33
+
34
+ ### Patch Changes
35
+
36
+ - [#542](https://github.com/atlassian-labs/atlaspack/pull/542) [`e0f5337`](https://github.com/atlassian-labs/atlaspack/commit/e0f533757bd1019dbd108a04952c87da15286e09) Thanks [@yamadapc](https://github.com/yamadapc)! - Add feature-flagged option to use rayon thread-pool to optimize inline requires
37
+
38
+ ## 2.14.3
39
+
40
+ ### Patch Changes
41
+
42
+ - [#511](https://github.com/atlassian-labs/atlaspack/pull/511) [`11d6f16`](https://github.com/atlassian-labs/atlaspack/commit/11d6f16b6397dee2f217167e5c98b39edb63f7a7) Thanks [@yamadapc](https://github.com/yamadapc)! - Clean-up dylib worker threads segmentation fault bug fix feature-flag
43
+
44
+ ## 2.14.2
45
+
46
+ ### Patch Changes
47
+
48
+ - [#494](https://github.com/atlassian-labs/atlaspack/pull/494) [`9b85d3e`](https://github.com/atlassian-labs/atlaspack/commit/9b85d3e645b10bd027eed2304afc970a5ba40062) Thanks [@JakeLane](https://github.com/JakeLane)! - When conditionalBundlingReporterDuplicateFix is enabled, avoid duplicated writes to the descriptor and logging
49
+
50
+ - [#510](https://github.com/atlassian-labs/atlaspack/pull/510) [`17b9579`](https://github.com/atlassian-labs/atlaspack/commit/17b9579484eced0ed8f23e2aba6d23b3c7238c39) Thanks [@yamadapc](https://github.com/yamadapc)! - Add unused feature-flag for cache rework changes
51
+
52
+ - [#512](https://github.com/atlassian-labs/atlaspack/pull/512) [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f) Thanks [@yamadapc](https://github.com/yamadapc)! - Remove LMDB cache back-end
53
+
54
+ ## 2.14.1
55
+
56
+ ### Patch Changes
57
+
58
+ - [#388](https://github.com/atlassian-labs/atlaspack/pull/388) [`4aab060`](https://github.com/atlassian-labs/atlaspack/commit/4aab0605c0d4ee8e0dcc3ffa1162eae5b360b677) Thanks [@yamadapc](https://github.com/yamadapc)! - Set LMDB.js Lite as the default cache back-end
59
+
60
+ - [#420](https://github.com/atlassian-labs/atlaspack/pull/420) [`e1422ad`](https://github.com/atlassian-labs/atlaspack/commit/e1422ad0a801faaa4bc4f1023bed042ffe236e9b) Thanks [@JakeLane](https://github.com/JakeLane)! - Support async script runtime in conditional bundling
61
+
62
+ - [#478](https://github.com/atlassian-labs/atlaspack/pull/478) [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b) Thanks [@yamadapc](https://github.com/yamadapc)! - The first attempt at Version Packages didn't include the built artifacts.
63
+ This has hopefully been fixed, so this change will force those packages to re-release.
64
+
3
65
  ## 2.14.0
4
66
 
5
67
  ### Minor Changes
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@atlaspack/unified/feature-flags';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('@atlaspack/unified/feature-flags');
package/index.js.flow ADDED
@@ -0,0 +1,3 @@
1
+ // @flow
2
+
3
+ export * from '@atlaspack/unified/src/feature-flags/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/feature-flags",
3
- "version": "2.14.1-dev.11+633800dee",
3
+ "version": "2.14.1-dev.123+5a11f33c5",
4
4
  "description": "Provides internal feature-flags for the atlaspack codebase.",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -10,16 +10,11 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/atlassian-labs/atlaspack.git"
12
12
  },
13
- "main": "lib/index.js",
14
- "source": "src/index.js",
15
- "types": "lib/types.d.ts",
16
- "scripts": {
17
- "build-ts": "mkdir -p lib && flow-to-ts src/types.js > lib/types.d.ts",
18
- "check-ts": "tsc --noEmit lib/types.d.ts"
19
- },
20
- "engines": {
21
- "node": ">= 16.0.0"
22
- },
13
+ "main": "index.js",
14
+ "types": "types.d.ts",
23
15
  "type": "commonjs",
24
- "gitHead": "633800dee24b76fed158966a802c0ea5dcab65d5"
16
+ "dependencies": {
17
+ "@atlaspack/unified": "2.14.2-dev.3834+5a11f33c5"
18
+ },
19
+ "gitHead": "5a11f33c51ff74d1cf8d4b72cfa0fda833aa980a"
25
20
  }
package/lib/index.js DELETED
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DEFAULT_FEATURE_FLAGS = void 0;
7
- exports.getFeatureFlag = getFeatureFlag;
8
- exports.getFeatureFlagValue = getFeatureFlagValue;
9
- exports.runWithConsistencyCheck = runWithConsistencyCheck;
10
- exports.setFeatureFlags = setFeatureFlags;
11
- // We need to do these gymnastics as we don't want flow-to-ts to touch DEFAULT_FEATURE_FLAGS,
12
- // but we want to export FeatureFlags for Flow
13
- const DEFAULT_FEATURE_FLAGS = exports.DEFAULT_FEATURE_FLAGS = {
14
- exampleConsistencyCheckFeature: 'OLD',
15
- exampleFeature: false,
16
- atlaspackV3: false,
17
- useWatchmanWatcher: false,
18
- importRetry: false,
19
- fixQuadraticCacheInvalidation: 'OLD',
20
- useLmdbJsLite: false,
21
- conditionalBundlingApi: false,
22
- vcsMode: 'OLD',
23
- loadableSideEffects: false,
24
- reduceResolverStringCreation: false,
25
- inlineBundlesSourceMapFixes: false,
26
- conditionalBundlingNestedRuntime: false,
27
- patchProjectPaths: false,
28
- inlineStringReplacementPerf: false
29
- };
30
- let featureFlagValues = {
31
- ...DEFAULT_FEATURE_FLAGS
32
- };
33
- function setFeatureFlags(flags) {
34
- featureFlagValues = flags;
35
- }
36
- function getFeatureFlag(flagName) {
37
- const value = featureFlagValues[flagName];
38
- return value === true || value === 'NEW';
39
- }
40
- function getFeatureFlagValue(flagName) {
41
- return featureFlagValues[flagName];
42
- }
43
- /**
44
- * Run a function with a consistency check.
45
- */
46
- function runWithConsistencyCheck(flag, oldFn, newFn, diffFn, report) {
47
- const value = featureFlagValues[flag];
48
- if (!value || value === false || value === 'OLD') {
49
- return oldFn();
50
- }
51
- if (value === true || value === 'NEW') {
52
- return newFn();
53
- }
54
- const oldStartTime = performance.now();
55
- const oldResult = oldFn();
56
- const oldExecutionTimeMs = performance.now() - oldStartTime;
57
- const newStartTime = performance.now();
58
- const newResult = newFn();
59
- const newExecutionTimeMs = performance.now() - newStartTime;
60
- const diff = diffFn(oldResult, newResult);
61
- report({
62
- isDifferent: diff.isDifferent,
63
- oldExecutionTimeMs,
64
- newExecutionTimeMs,
65
- custom: diff.custom
66
- }, oldResult, newResult);
67
- if (value === 'NEW_AND_CHECK') {
68
- return newResult;
69
- }
70
- return oldResult;
71
- }
package/lib/types.d.ts DELETED
@@ -1,78 +0,0 @@
1
- export type FeatureFlags = {
2
- // This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
3
- readonly exampleFeature: boolean;
4
- readonly exampleConsistencyCheckFeature: ConsistencyCheckFeatureFlagValue;
5
-
6
- /**
7
- * Rust backed requests
8
- */
9
- readonly atlaspackV3: boolean;
10
-
11
- /**
12
- * Use node.js implementation of @parcel/watcher watchman backend
13
- */
14
- readonly useWatchmanWatcher: boolean;
15
-
16
- /**
17
- * Configure runtime to enable retriable dynamic imports
18
- */
19
- importRetry: boolean;
20
-
21
- /**
22
- * Enable Rust based LMDB wrapper library
23
- */
24
- useLmdbJsLite: boolean;
25
-
26
- /**
27
- * Fixes quadratic cache invalidation issue
28
- */
29
- fixQuadraticCacheInvalidation: ConsistencyCheckFeatureFlagValue;
30
-
31
- /**
32
- * Enables an experimental "conditional bundling" API - this allows the use of `importCond` syntax
33
- * in order to have (consumer) feature flag driven bundling. This feature is very experimental,
34
- * and requires server-side support.
35
- */
36
- conditionalBundlingApi: boolean;
37
-
38
- /**
39
- * Enable VCS mode. Expected values are:
40
- * - OLD - default value, return watchman result
41
- * - NEW_AND_CHECK - Return VCS result but still call watchman
42
- * - NEW: Return VCS result, but don't call watchman
43
- */
44
- vcsMode: ConsistencyCheckFeatureFlagValue;
45
-
46
- /**
47
- * Enable scanning for the presence of loadable to determine side effects
48
- */
49
- loadableSideEffects: boolean;
50
-
51
- /**
52
- * Enable performance optimization for the resolver specifier to_string
53
- * conversions
54
- */
55
- reduceResolverStringCreation: boolean;
56
-
57
- /**
58
- * Fixes source maps for inline bundles
59
- */
60
- inlineBundlesSourceMapFixes: boolean;
61
-
62
- /**
63
- * Enable nested loading of bundles in the runtime with conditional bundling
64
- */
65
- conditionalBundlingNestedRuntime: boolean;
66
-
67
- /** Enable patch project paths. This will patch the project paths to be relative to the project root.
68
- * This feature is experimental and should not be used in production. It will used to test downloadble cache artefacts.
69
- */
70
- patchProjectPaths: boolean;
71
-
72
- /**
73
- * Enables optimized inline string replacement perf for the packager.
74
- * Used heavily for inline bundles.
75
- */
76
- inlineStringReplacementPerf: boolean;
77
- };
78
- export type ConsistencyCheckFeatureFlagValue = "NEW" | "OLD" | "NEW_AND_CHECK" | "OLD_AND_CHECK";
package/lib/types.js DELETED
@@ -1 +0,0 @@
1
- "use strict";
package/src/index.js DELETED
@@ -1,106 +0,0 @@
1
- // @flow strict
2
-
3
- import type {FeatureFlags as _FeatureFlags} from './types';
4
- // We need to do these gymnastics as we don't want flow-to-ts to touch DEFAULT_FEATURE_FLAGS,
5
- // but we want to export FeatureFlags for Flow
6
- export type FeatureFlags = _FeatureFlags;
7
-
8
- export const DEFAULT_FEATURE_FLAGS: FeatureFlags = {
9
- exampleConsistencyCheckFeature: 'OLD',
10
- exampleFeature: false,
11
- atlaspackV3: false,
12
- useWatchmanWatcher: false,
13
- importRetry: false,
14
- fixQuadraticCacheInvalidation: 'OLD',
15
- useLmdbJsLite: false,
16
- conditionalBundlingApi: false,
17
- vcsMode: 'OLD',
18
- loadableSideEffects: false,
19
- reduceResolverStringCreation: false,
20
- inlineBundlesSourceMapFixes: false,
21
- conditionalBundlingNestedRuntime: false,
22
- patchProjectPaths: false,
23
- inlineStringReplacementPerf: false,
24
- };
25
-
26
- let featureFlagValues: FeatureFlags = {...DEFAULT_FEATURE_FLAGS};
27
-
28
- export function setFeatureFlags(flags: FeatureFlags) {
29
- featureFlagValues = flags;
30
- }
31
-
32
- export function getFeatureFlag(flagName: $Keys<FeatureFlags>): boolean {
33
- const value = featureFlagValues[flagName];
34
- return value === true || value === 'NEW';
35
- }
36
-
37
- export function getFeatureFlagValue(
38
- flagName: $Keys<FeatureFlags>,
39
- ): boolean | string | number {
40
- return featureFlagValues[flagName];
41
- }
42
-
43
- export type DiffResult<CustomDiagnostic> = {|
44
- isDifferent: boolean,
45
- custom: CustomDiagnostic,
46
- |};
47
-
48
- export type Diagnostic<CustomDiagnostic> = {|
49
- isDifferent: boolean,
50
- oldExecutionTimeMs: number,
51
- newExecutionTimeMs: number,
52
- custom: CustomDiagnostic,
53
- |};
54
-
55
- /**
56
- * Run a function with a consistency check.
57
- */
58
- export function runWithConsistencyCheck<Result, CustomDiagnostic>(
59
- flag: string,
60
- oldFn: () => Result,
61
- newFn: () => Result,
62
- diffFn: (
63
- oldResult: Result,
64
- newResult: Result,
65
- ) => DiffResult<CustomDiagnostic>,
66
- report: (
67
- diagnostic: Diagnostic<CustomDiagnostic>,
68
- oldResult: Result,
69
- newResult: Result,
70
- ) => void,
71
- ): Result {
72
- const value = featureFlagValues[flag];
73
- if (!value || value === false || value === 'OLD') {
74
- return oldFn();
75
- }
76
- if (value === true || value === 'NEW') {
77
- return newFn();
78
- }
79
-
80
- const oldStartTime = performance.now();
81
- const oldResult = oldFn();
82
- const oldExecutionTimeMs = performance.now() - oldStartTime;
83
-
84
- const newStartTime = performance.now();
85
- const newResult = newFn();
86
- const newExecutionTimeMs = performance.now() - newStartTime;
87
-
88
- const diff = diffFn(oldResult, newResult);
89
-
90
- report(
91
- {
92
- isDifferent: diff.isDifferent,
93
- oldExecutionTimeMs,
94
- newExecutionTimeMs,
95
- custom: diff.custom,
96
- },
97
- oldResult,
98
- newResult,
99
- );
100
-
101
- if (value === 'NEW_AND_CHECK') {
102
- return newResult;
103
- }
104
-
105
- return oldResult;
106
- }
package/src/types.js DELETED
@@ -1,73 +0,0 @@
1
- // @flow strict
2
-
3
- export type FeatureFlags = {|
4
- // This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
5
- +exampleFeature: boolean,
6
- +exampleConsistencyCheckFeature: ConsistencyCheckFeatureFlagValue,
7
- /**
8
- * Rust backed requests
9
- */
10
- +atlaspackV3: boolean,
11
- /**
12
- * Use node.js implementation of @parcel/watcher watchman backend
13
- */
14
- +useWatchmanWatcher: boolean,
15
- /**
16
- * Configure runtime to enable retriable dynamic imports
17
- */
18
- importRetry: boolean,
19
- /**
20
- * Enable Rust based LMDB wrapper library
21
- */
22
- useLmdbJsLite: boolean,
23
- /**
24
- * Fixes quadratic cache invalidation issue
25
- */
26
- fixQuadraticCacheInvalidation: ConsistencyCheckFeatureFlagValue,
27
- /**
28
- * Enables an experimental "conditional bundling" API - this allows the use of `importCond` syntax
29
- * in order to have (consumer) feature flag driven bundling. This feature is very experimental,
30
- * and requires server-side support.
31
- */
32
- conditionalBundlingApi: boolean,
33
- /**
34
- * Enable VCS mode. Expected values are:
35
- * - OLD - default value, return watchman result
36
- * - NEW_AND_CHECK - Return VCS result but still call watchman
37
- * - NEW: Return VCS result, but don't call watchman
38
- */
39
- vcsMode: ConsistencyCheckFeatureFlagValue,
40
- /**
41
- * Enable scanning for the presence of loadable to determine side effects
42
- */
43
- loadableSideEffects: boolean,
44
- /**
45
- * Enable performance optimization for the resolver specifier to_string
46
- * conversions
47
- */
48
- reduceResolverStringCreation: boolean,
49
- /**
50
- * Fixes source maps for inline bundles
51
- */
52
- inlineBundlesSourceMapFixes: boolean,
53
- /**
54
- * Enable nested loading of bundles in the runtime with conditional bundling
55
- */
56
- conditionalBundlingNestedRuntime: boolean,
57
- /** Enable patch project paths. This will patch the project paths to be relative to the project root.
58
- * This feature is experimental and should not be used in production. It will used to test downloadble cache artefacts.
59
- */
60
- patchProjectPaths: boolean,
61
-
62
- /**
63
- * Enables optimized inline string replacement perf for the packager.
64
- * Used heavily for inline bundles.
65
- */
66
- inlineStringReplacementPerf: boolean,
67
- |};
68
-
69
- export type ConsistencyCheckFeatureFlagValue =
70
- | 'NEW'
71
- | 'OLD'
72
- | 'NEW_AND_CHECK'
73
- | 'OLD_AND_CHECK';
@@ -1,105 +0,0 @@
1
- // @flow strict
2
- import assert from 'assert';
3
- import {
4
- getFeatureFlag,
5
- DEFAULT_FEATURE_FLAGS,
6
- setFeatureFlags,
7
- runWithConsistencyCheck,
8
- } from '../src';
9
- import sinon from 'sinon';
10
-
11
- describe('feature-flag test', () => {
12
- beforeEach(() => {
13
- setFeatureFlags(DEFAULT_FEATURE_FLAGS);
14
- });
15
-
16
- it('has defaults', () => {
17
- assert.equal(
18
- getFeatureFlag('exampleFeature'),
19
- DEFAULT_FEATURE_FLAGS.exampleFeature,
20
- );
21
- });
22
-
23
- it('can override', () => {
24
- setFeatureFlags({...DEFAULT_FEATURE_FLAGS, exampleFeature: true});
25
- assert.equal(getFeatureFlag('exampleFeature'), true);
26
- });
27
-
28
- describe('consistency checks', () => {
29
- it('runs the old function if the flag is off', () => {
30
- setFeatureFlags({
31
- ...DEFAULT_FEATURE_FLAGS,
32
- exampleConsistencyCheckFeature: 'OLD',
33
- });
34
- const result = runWithConsistencyCheck(
35
- 'exampleConsistencyCheckFeature',
36
- () => 'old',
37
- () => 'new',
38
- sinon.spy(),
39
- sinon.spy(),
40
- );
41
- assert.equal(result, 'old');
42
- });
43
-
44
- it('runs the new function if the flag is on', () => {
45
- setFeatureFlags({
46
- ...DEFAULT_FEATURE_FLAGS,
47
- exampleConsistencyCheckFeature: 'NEW',
48
- });
49
- const result = runWithConsistencyCheck(
50
- 'exampleConsistencyCheckFeature',
51
- () => 'old',
52
- () => 'new',
53
- sinon.spy(),
54
- sinon.spy(),
55
- );
56
- assert.equal(result, 'new');
57
- });
58
-
59
- it('diffs old and new values if there is a diff value', () => {
60
- setFeatureFlags({
61
- ...DEFAULT_FEATURE_FLAGS,
62
- exampleConsistencyCheckFeature: 'OLD_AND_CHECK',
63
- });
64
- const reportSpy = sinon.spy();
65
- const result = runWithConsistencyCheck(
66
- 'exampleConsistencyCheckFeature',
67
- () => 'old',
68
- () => 'new',
69
- () => ({isDifferent: false, custom: 'diff'}),
70
- reportSpy,
71
- );
72
-
73
- assert.equal(result, 'old');
74
- sinon.assert.calledWith(reportSpy, {
75
- isDifferent: false,
76
- oldExecutionTimeMs: sinon.match.number,
77
- newExecutionTimeMs: sinon.match.number,
78
- custom: 'diff',
79
- });
80
- });
81
-
82
- it('diffs old and new values if there is a diff new value', () => {
83
- setFeatureFlags({
84
- ...DEFAULT_FEATURE_FLAGS,
85
- exampleConsistencyCheckFeature: 'NEW_AND_CHECK',
86
- });
87
- const reportSpy = sinon.spy();
88
- const result = runWithConsistencyCheck(
89
- 'exampleConsistencyCheckFeature',
90
- () => 'old',
91
- () => 'new',
92
- () => ({isDifferent: true, custom: 'diff'}),
93
- reportSpy,
94
- );
95
-
96
- assert.equal(result, 'new');
97
- sinon.assert.calledWith(reportSpy, {
98
- isDifferent: true,
99
- oldExecutionTimeMs: sinon.match.number,
100
- newExecutionTimeMs: sinon.match.number,
101
- custom: 'diff',
102
- });
103
- });
104
- });
105
- });