@atlaspack/feature-flags 2.21.0 → 2.23.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaspack/feature-flags
2
2
 
3
+ ## 2.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#745](https://github.com/atlassian-labs/atlaspack/pull/745) [`f6b3f22`](https://github.com/atlassian-labs/atlaspack/commit/f6b3f2276c7e417580b49c4879563aab51f156b1) Thanks [@matt-koko](https://github.com/matt-koko)! - Use ATLASPACK_BUILD_ENV instead of NODE_ENV to determine if Atlaspack is being run in the context of Atlaspack tests.
8
+
9
+ ## 2.22.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#741](https://github.com/atlassian-labs/atlaspack/pull/741) [`73dd7ba`](https://github.com/atlassian-labs/atlaspack/commit/73dd7baab69456ef2f6e4a0cc7dbb04f407eb148) Thanks [@matt-koko](https://github.com/matt-koko)! - combine FeatureFlags and DEFAULT_FEATURE_FLAGS into one object
14
+
3
15
  ## 2.21.0
4
16
 
5
17
  ### Minor Changes
package/lib/index.js CHANGED
@@ -12,35 +12,132 @@ exports.setFeatureFlags = setFeatureFlags;
12
12
 
13
13
  const CONSISTENCY_CHECK_VALUES = exports.CONSISTENCY_CHECK_VALUES = Object.freeze(['NEW', 'OLD', 'NEW_AND_CHECK', 'OLD_AND_CHECK']);
14
14
  const DEFAULT_FEATURE_FLAGS = exports.DEFAULT_FEATURE_FLAGS = {
15
- exampleConsistencyCheckFeature: 'OLD',
15
+ // This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
16
16
  exampleFeature: false,
17
+ exampleConsistencyCheckFeature: 'OLD',
18
+ /**
19
+ * Rust backed requests
20
+ */
17
21
  atlaspackV3: false,
22
+ /**
23
+ * Use node.js implementation of @parcel/watcher watchman backend
24
+ */
18
25
  useWatchmanWatcher: false,
26
+ /**
27
+ * Configure runtime to enable retriable dynamic imports
28
+ */
19
29
  importRetry: false,
30
+ /**
31
+ * Fixes quadratic cache invalidation issue
32
+ */
20
33
  fixQuadraticCacheInvalidation: 'OLD',
34
+ /**
35
+ * Enables an experimental "conditional bundling" API - this allows the use of `importCond` syntax
36
+ * in order to have (consumer) feature flag driven bundling. This feature is very experimental,
37
+ * and requires server-side support.
38
+ */
21
39
  conditionalBundlingApi: false,
40
+ /**
41
+ * Enable VCS mode. Expected values are:
42
+ * - OLD - default value, return watchman result
43
+ * - NEW_AND_CHECK - Return VCS result but still call watchman
44
+ * - NEW: Return VCS result, but don't call watchman
45
+ */
22
46
  vcsMode: 'OLD',
47
+ /**
48
+ * Refactor cache to:
49
+ * - Split writes into multiple entries
50
+ * - Remove "large file blob" writes
51
+ * - Reduce size of the caches by deduplicating data
52
+ */
53
+ cachePerformanceImprovements: process.env.ATLASPACK_BUILD_ENV === 'test',
54
+ /**
55
+ * Deduplicates environments across cache / memory entities
56
+ */
57
+ environmentDeduplication: false,
58
+ /**
59
+ * Enable scanning for the presence of loadable to determine side effects
60
+ */
23
61
  loadableSideEffects: false,
62
+ /**
63
+ * Enable performance optimization for the resolver specifier to_string
64
+ * conversions
65
+ */
24
66
  reduceResolverStringCreation: false,
67
+ /**
68
+ * Add verbose metrics for request tracker invalidation.
69
+ * Default to true as it's a monitoring change. Can be turned off if necessary.
70
+ */
71
+ verboseRequestInvalidationStats: true,
72
+ /**
73
+ * Fixes source maps for inline bundles
74
+ */
25
75
  inlineBundlesSourceMapFixes: false,
76
+ /** Enable patch project paths. This will patch the project paths to be relative to the project root.
77
+ * This feature is experimental and should not be used in production. It will used to test downloadble cache artefacts.
78
+ */
26
79
  patchProjectPaths: false,
27
- cachePerformanceImprovements: process.env.NODE_ENV === 'test',
28
- environmentDeduplication: false,
80
+ /**
81
+ * Enables optimized inline string replacement perf for the packager.
82
+ * Used heavily for inline bundles.
83
+ */
29
84
  inlineStringReplacementPerf: false,
30
- // Default to true as it's a monitoring change. Can be turned off if necessary.
31
- verboseRequestInvalidationStats: true,
85
+ /**
86
+ * Enable resolution of bundler config starting from the CWD
87
+ */
32
88
  resolveBundlerConfigFromCwd: false,
89
+ /**
90
+ * Enable a setting that allows for more assets to be scope hoisted, if
91
+ * they're safe to do so.
92
+ */
33
93
  applyScopeHoistingImprovement: false,
94
+ /**
95
+ * Enable a change where a constant module only have the namespacing object added in bundles where it is required
96
+ */
34
97
  inlineConstOptimisationFix: false,
98
+ /**
99
+ * Improves/fixes HMR behaviour by:
100
+ * - Fixing HMR behaviour with lazy bundle edges
101
+ * - Moving the functionality of the react-refresh runtime into the react-refresh-wrap transformer
102
+ */
35
103
  hmrImprovements: false,
36
- unusedComputedPropertyFix: process.env.NODE_ENV === 'test',
37
- emptyFileStarRexportFix: process.env.NODE_ENV === 'test',
104
+ /**
105
+ * Fixes a bug where imported objects that are accessed with non-static
106
+ * properties (e.g. `CONSTANTS['api_' + endpoint`]) would not be recognised as
107
+ * being used, and thus not included in the bundle.
108
+ */
109
+ unusedComputedPropertyFix: process.env.ATLASPACK_BUILD_ENV === 'test',
110
+ /**
111
+ * Fixes an issue where star re-exports of empty files (usually occurring in compiled typescript libraries)
112
+ * could cause exports to undefined at runtime.
113
+ */
114
+ emptyFileStarRexportFix: process.env.ATLASPACK_BUILD_ENV === 'test',
115
+ /**
116
+ * Enables the new packaging progress CLI experience
117
+ */
38
118
  cliProgressReportingImprovements: false,
39
- supportWebpackChunkName: process.env.NODE_ENV === 'test',
119
+ /**
120
+ * Adds support for `webpackChunkName` comments in dynamic imports.
121
+ * Imports with the same `webpackChunkName` will be bundled together.
122
+ */
123
+ supportWebpackChunkName: process.env.ATLASPACK_BUILD_ENV === 'test',
124
+ /**
125
+ * Enable a change to the conditional bundling loader to use a fallback bundle loading if the expected scripts aren't found
126
+ *
127
+ * Split into two flags, to allow usage in the dev or prod packagers separately
128
+ */
40
129
  condbDevFallbackDev: false,
41
130
  condbDevFallbackProd: false,
42
- incrementalBundlingVersioning: process.env.NODE_ENV === 'test',
43
- inlineIsolatedScripts: process.env.NODE_ENV === 'test'
131
+ /**
132
+ * Enable the new incremental bundling versioning logic which determines whether
133
+ * a full bundling pass is required based on the AssetGraph's bundlingVersion.
134
+ */
135
+ incrementalBundlingVersioning: process.env.ATLASPACK_BUILD_ENV === 'test',
136
+ /**
137
+ * Allow for the use of `data-atlaspack-isolated` on script tags in HTML to produce
138
+ * inline scripts that are build as "isolated" bundles.
139
+ */
140
+ inlineIsolatedScripts: process.env.ATLASPACK_BUILD_ENV === 'test'
44
141
  };
45
142
  let featureFlagValues = {
46
143
  ...DEFAULT_FEATURE_FLAGS
@@ -1,14 +1,16 @@
1
- export type FeatureFlags = {
2
- readonly exampleFeature: boolean;
3
- readonly exampleConsistencyCheckFeature: ConsistencyCheckFeatureFlagValue;
1
+ export type ConsistencyCheckFeatureFlagValue = (typeof CONSISTENCY_CHECK_VALUES)[number];
2
+ export declare const CONSISTENCY_CHECK_VALUES: ReadonlyArray<string>;
3
+ export declare const DEFAULT_FEATURE_FLAGS: {
4
+ exampleFeature: boolean;
5
+ exampleConsistencyCheckFeature: ConsistencyCheckFeatureFlagValue;
4
6
  /**
5
7
  * Rust backed requests
6
8
  */
7
- readonly atlaspackV3: boolean;
9
+ atlaspackV3: boolean;
8
10
  /**
9
11
  * Use node.js implementation of @parcel/watcher watchman backend
10
12
  */
11
- readonly useWatchmanWatcher: boolean;
13
+ useWatchmanWatcher: boolean;
12
14
  /**
13
15
  * Configure runtime to enable retriable dynamic imports
14
16
  */
@@ -51,7 +53,8 @@ export type FeatureFlags = {
51
53
  */
52
54
  reduceResolverStringCreation: boolean;
53
55
  /**
54
- * Add verbose metrics for request tracker invalidation
56
+ * Add verbose metrics for request tracker invalidation.
57
+ * Default to true as it's a monitoring change. Can be turned off if necessary.
55
58
  */
56
59
  verboseRequestInvalidationStats: boolean;
57
60
  /**
@@ -124,9 +127,7 @@ export type FeatureFlags = {
124
127
  */
125
128
  inlineIsolatedScripts: boolean;
126
129
  };
127
- export type ConsistencyCheckFeatureFlagValue = (typeof CONSISTENCY_CHECK_VALUES)[number];
128
- export declare const CONSISTENCY_CHECK_VALUES: ReadonlyArray<string>;
129
- export declare const DEFAULT_FEATURE_FLAGS: FeatureFlags;
130
+ export type FeatureFlags = typeof DEFAULT_FEATURE_FLAGS;
130
131
  export declare function setFeatureFlags(flags: FeatureFlags): void;
131
132
  export declare function getFeatureFlag(flagName: keyof FeatureFlags): boolean;
132
133
  export declare function getFeatureFlagValue(flagName: keyof FeatureFlags): boolean | string | number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/feature-flags",
3
- "version": "2.21.0",
3
+ "version": "2.23.0",
4
4
  "description": "Provides internal feature-flags for the atlaspack codebase.",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -12,12 +12,13 @@
12
12
  },
13
13
  "main": "./lib/index.js",
14
14
  "source": "./src/index.ts",
15
- "types": "./lib/index.d.ts",
15
+ "types": "./lib/types/index.d.ts",
16
16
  "scripts": {
17
- "check-ts": "tsc --emitDeclarationOnly --rootDir src"
17
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
18
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
18
19
  },
19
20
  "engines": {
20
21
  "node": ">= 16.0.0"
21
22
  },
22
23
  "type": "commonjs"
23
- }
24
+ }
package/src/index.ts CHANGED
@@ -1,36 +1,46 @@
1
1
  // Converted from Flow to TypeScript
2
2
 
3
- export type FeatureFlags = {
3
+ export type ConsistencyCheckFeatureFlagValue =
4
+ (typeof CONSISTENCY_CHECK_VALUES)[number];
5
+
6
+ export const CONSISTENCY_CHECK_VALUES: ReadonlyArray<string> = Object.freeze([
7
+ 'NEW',
8
+ 'OLD',
9
+ 'NEW_AND_CHECK',
10
+ 'OLD_AND_CHECK',
11
+ ]);
12
+
13
+ export const DEFAULT_FEATURE_FLAGS = {
4
14
  // This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
5
- readonly exampleFeature: boolean;
6
- readonly exampleConsistencyCheckFeature: ConsistencyCheckFeatureFlagValue;
15
+ exampleFeature: false,
16
+ exampleConsistencyCheckFeature: 'OLD' as ConsistencyCheckFeatureFlagValue,
7
17
 
8
18
  /**
9
19
  * Rust backed requests
10
20
  */
11
- readonly atlaspackV3: boolean;
21
+ atlaspackV3: false,
12
22
 
13
23
  /**
14
24
  * Use node.js implementation of @parcel/watcher watchman backend
15
25
  */
16
- readonly useWatchmanWatcher: boolean;
26
+ useWatchmanWatcher: false,
17
27
 
18
28
  /**
19
29
  * Configure runtime to enable retriable dynamic imports
20
30
  */
21
- importRetry: boolean;
31
+ importRetry: false,
22
32
 
23
33
  /**
24
34
  * Fixes quadratic cache invalidation issue
25
35
  */
26
- fixQuadraticCacheInvalidation: ConsistencyCheckFeatureFlagValue;
36
+ fixQuadraticCacheInvalidation: 'OLD' as ConsistencyCheckFeatureFlagValue,
27
37
 
28
38
  /**
29
39
  * Enables an experimental "conditional bundling" API - this allows the use of `importCond` syntax
30
40
  * in order to have (consumer) feature flag driven bundling. This feature is very experimental,
31
41
  * and requires server-side support.
32
42
  */
33
- conditionalBundlingApi: boolean;
43
+ conditionalBundlingApi: false,
34
44
 
35
45
  /**
36
46
  * Enable VCS mode. Expected values are:
@@ -38,7 +48,7 @@ export type FeatureFlags = {
38
48
  * - NEW_AND_CHECK - Return VCS result but still call watchman
39
49
  * - NEW: Return VCS result, but don't call watchman
40
50
  */
41
- vcsMode: ConsistencyCheckFeatureFlagValue;
51
+ vcsMode: 'OLD' as ConsistencyCheckFeatureFlagValue,
42
52
 
43
53
  /**
44
54
  * Refactor cache to:
@@ -46,154 +56,114 @@ export type FeatureFlags = {
46
56
  * - Remove "large file blob" writes
47
57
  * - Reduce size of the caches by deduplicating data
48
58
  */
49
- cachePerformanceImprovements: boolean;
59
+ cachePerformanceImprovements: process.env.ATLASPACK_BUILD_ENV === 'test',
50
60
 
51
61
  /**
52
62
  * Deduplicates environments across cache / memory entities
53
63
  */
54
- environmentDeduplication: boolean;
64
+ environmentDeduplication: false,
55
65
 
56
66
  /**
57
67
  * Enable scanning for the presence of loadable to determine side effects
58
68
  */
59
- loadableSideEffects: boolean;
69
+ loadableSideEffects: false,
60
70
 
61
71
  /**
62
72
  * Enable performance optimization for the resolver specifier to_string
63
73
  * conversions
64
74
  */
65
- reduceResolverStringCreation: boolean;
75
+ reduceResolverStringCreation: false,
66
76
 
67
77
  /**
68
- * Add verbose metrics for request tracker invalidation
78
+ * Add verbose metrics for request tracker invalidation.
79
+ * Default to true as it's a monitoring change. Can be turned off if necessary.
69
80
  */
70
- verboseRequestInvalidationStats: boolean;
81
+ verboseRequestInvalidationStats: true,
71
82
 
72
83
  /**
73
84
  * Fixes source maps for inline bundles
74
85
  */
75
- inlineBundlesSourceMapFixes: boolean;
86
+ inlineBundlesSourceMapFixes: false,
76
87
 
77
88
  /** Enable patch project paths. This will patch the project paths to be relative to the project root.
78
89
  * This feature is experimental and should not be used in production. It will used to test downloadble cache artefacts.
79
90
  */
80
- patchProjectPaths: boolean;
91
+ patchProjectPaths: false,
81
92
 
82
93
  /**
83
94
  * Enables optimized inline string replacement perf for the packager.
84
95
  * Used heavily for inline bundles.
85
96
  */
86
- inlineStringReplacementPerf: boolean;
97
+ inlineStringReplacementPerf: false,
87
98
 
88
99
  /**
89
100
  * Enable resolution of bundler config starting from the CWD
90
101
  */
91
- resolveBundlerConfigFromCwd: boolean;
102
+ resolveBundlerConfigFromCwd: false,
92
103
 
93
104
  /**
94
105
  * Enable a setting that allows for more assets to be scope hoisted, if
95
106
  * they're safe to do so.
96
107
  */
97
- applyScopeHoistingImprovement: boolean;
108
+ applyScopeHoistingImprovement: false,
98
109
 
99
110
  /**
100
111
  * Enable a change where a constant module only have the namespacing object added in bundles where it is required
101
112
  */
102
- inlineConstOptimisationFix: boolean;
113
+ inlineConstOptimisationFix: false,
103
114
 
104
115
  /**
105
116
  * Improves/fixes HMR behaviour by:
106
117
  * - Fixing HMR behaviour with lazy bundle edges
107
118
  * - Moving the functionality of the react-refresh runtime into the react-refresh-wrap transformer
108
119
  */
109
- hmrImprovements: boolean;
120
+ hmrImprovements: false,
110
121
 
111
122
  /**
112
123
  * Fixes a bug where imported objects that are accessed with non-static
113
124
  * properties (e.g. `CONSTANTS['api_' + endpoint`]) would not be recognised as
114
125
  * being used, and thus not included in the bundle.
115
126
  */
116
- unusedComputedPropertyFix: boolean;
127
+ unusedComputedPropertyFix: process.env.ATLASPACK_BUILD_ENV === 'test',
117
128
 
118
129
  /**
119
130
  * Fixes an issue where star re-exports of empty files (usually occurring in compiled typescript libraries)
120
131
  * could cause exports to undefined at runtime.
121
132
  */
122
- emptyFileStarRexportFix: boolean;
133
+ emptyFileStarRexportFix: process.env.ATLASPACK_BUILD_ENV === 'test',
123
134
 
124
135
  /**
125
136
  * Enables the new packaging progress CLI experience
126
137
  */
127
- cliProgressReportingImprovements: boolean;
138
+ cliProgressReportingImprovements: false,
128
139
 
129
140
  /**
130
141
  * Adds support for `webpackChunkName` comments in dynamic imports.
131
142
  * Imports with the same `webpackChunkName` will be bundled together.
132
143
  */
133
- supportWebpackChunkName: boolean;
144
+ supportWebpackChunkName: process.env.ATLASPACK_BUILD_ENV === 'test',
134
145
 
135
146
  /**
136
147
  * Enable a change to the conditional bundling loader to use a fallback bundle loading if the expected scripts aren't found
137
148
  *
138
149
  * Split into two flags, to allow usage in the dev or prod packagers separately
139
150
  */
140
- condbDevFallbackDev: boolean;
141
- condbDevFallbackProd: boolean;
151
+ condbDevFallbackDev: false,
152
+ condbDevFallbackProd: false,
142
153
 
143
154
  /**
144
155
  * Enable the new incremental bundling versioning logic which determines whether
145
156
  * a full bundling pass is required based on the AssetGraph's bundlingVersion.
146
157
  */
147
- incrementalBundlingVersioning: boolean;
148
-
158
+ incrementalBundlingVersioning: process.env.ATLASPACK_BUILD_ENV === 'test',
149
159
  /**
150
160
  * Allow for the use of `data-atlaspack-isolated` on script tags in HTML to produce
151
161
  * inline scripts that are build as "isolated" bundles.
152
162
  */
153
- inlineIsolatedScripts: boolean;
163
+ inlineIsolatedScripts: process.env.ATLASPACK_BUILD_ENV === 'test',
154
164
  };
155
165
 
156
- export type ConsistencyCheckFeatureFlagValue =
157
- (typeof CONSISTENCY_CHECK_VALUES)[number];
158
-
159
- export const CONSISTENCY_CHECK_VALUES: ReadonlyArray<string> = Object.freeze([
160
- 'NEW',
161
- 'OLD',
162
- 'NEW_AND_CHECK',
163
- 'OLD_AND_CHECK',
164
- ]);
165
-
166
- export const DEFAULT_FEATURE_FLAGS: FeatureFlags = {
167
- exampleConsistencyCheckFeature: 'OLD',
168
- exampleFeature: false,
169
- atlaspackV3: false,
170
- useWatchmanWatcher: false,
171
- importRetry: false,
172
- fixQuadraticCacheInvalidation: 'OLD',
173
- conditionalBundlingApi: false,
174
- vcsMode: 'OLD',
175
- loadableSideEffects: false,
176
- reduceResolverStringCreation: false,
177
- inlineBundlesSourceMapFixes: false,
178
- patchProjectPaths: false,
179
- cachePerformanceImprovements: process.env.NODE_ENV === 'test',
180
- environmentDeduplication: false,
181
- inlineStringReplacementPerf: false,
182
- // Default to true as it's a monitoring change. Can be turned off if necessary.
183
- verboseRequestInvalidationStats: true,
184
- resolveBundlerConfigFromCwd: false,
185
- applyScopeHoistingImprovement: false,
186
- inlineConstOptimisationFix: false,
187
- hmrImprovements: false,
188
- unusedComputedPropertyFix: process.env.NODE_ENV === 'test',
189
- emptyFileStarRexportFix: process.env.NODE_ENV === 'test',
190
- cliProgressReportingImprovements: false,
191
- supportWebpackChunkName: process.env.NODE_ENV === 'test',
192
- condbDevFallbackDev: false,
193
- condbDevFallbackProd: false,
194
- incrementalBundlingVersioning: process.env.NODE_ENV === 'test',
195
- inlineIsolatedScripts: process.env.NODE_ENV === 'test',
196
- };
166
+ export type FeatureFlags = typeof DEFAULT_FEATURE_FLAGS;
197
167
 
198
168
  let featureFlagValues: FeatureFlags = {...DEFAULT_FEATURE_FLAGS};
199
169