@atlaspack/feature-flags 2.14.1-canary.51 → 2.14.1-canary.511

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/dist/index.js ADDED
@@ -0,0 +1,409 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_FEATURE_FLAGS = exports.CONSISTENCY_CHECK_VALUES = void 0;
4
+ exports.setFeatureFlags = setFeatureFlags;
5
+ exports.getFeatureFlag = getFeatureFlag;
6
+ exports.getFeatureFlagValue = getFeatureFlagValue;
7
+ exports.runWithConsistencyCheck = runWithConsistencyCheck;
8
+ exports.CONSISTENCY_CHECK_VALUES = Object.freeze([
9
+ 'NEW',
10
+ 'OLD',
11
+ 'NEW_AND_CHECK',
12
+ 'OLD_AND_CHECK',
13
+ ]);
14
+ exports.DEFAULT_FEATURE_FLAGS = {
15
+ // This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
16
+ exampleFeature: false,
17
+ exampleConsistencyCheckFeature: 'OLD',
18
+ /**
19
+ * Rust backed requests
20
+ *
21
+ * @author Matt Jones <mjones4@atlassian.com>
22
+ * @since 2024-05-01
23
+ */
24
+ atlaspackV3: false,
25
+ /**
26
+ * Enable Rust symbol tracker results in the AssetGraphRequest.
27
+ *
28
+ * This is used to gate the new Rust-side symbol tracking work.
29
+ *
30
+ * @author Ben Jervis <bjervis@atlassian.com>
31
+ * @since 2026-02-05
32
+ */
33
+ rustSymbolTracker: false,
34
+ /**
35
+ * Use node.js implementation of @parcel/watcher watchman backend
36
+ *
37
+ * @author Pedro Tacla Yamada <pyamada@atlassian.com>
38
+ * @since 2024-08-09
39
+ */
40
+ useWatchmanWatcher: false,
41
+ /**
42
+ * Configure runtime to enable retriable dynamic imports
43
+ *
44
+ * @author David Alsh <dalsh@atlassian.com>
45
+ * @since 2024-08-21
46
+ */
47
+ importRetry: false,
48
+ /**
49
+ * Fixes quadratic cache invalidation issue
50
+ *
51
+ * @author Pedro Tacla Yamada <pyamada@atlassian.com>
52
+ * @since 2024-10-21
53
+ */
54
+ fixQuadraticCacheInvalidation: 'OLD',
55
+ /**
56
+ * Enables an experimental "conditional bundling" API - this allows the use of `importCond` syntax
57
+ * in order to have (consumer) feature flag driven bundling. This feature is very experimental,
58
+ * and requires server-side support.
59
+ *
60
+ * @author Jake Lane <jlane2@atlassian.com>
61
+ * @since 2024-09-11
62
+ */
63
+ conditionalBundlingApi: false,
64
+ /**
65
+ * Enable VCS mode. Expected values are:
66
+ * - OLD - default value, return watchman result
67
+ * - NEW_AND_CHECK - Return VCS result but still call watchman
68
+ * - NEW: Return VCS result, but don't call watchman
69
+ *
70
+ * @author Celeste Carloni <ccarloni@atlassian.com>
71
+ * @since 2025-02-04
72
+ */
73
+ vcsMode: 'OLD',
74
+ /**
75
+ * Deduplicates environments across cache / memory entities
76
+ *
77
+ * @author Pedro Tacla Yamada <pyamada@atlassian.com>
78
+ * @since 2025-06-11
79
+ */
80
+ environmentDeduplication: false,
81
+ /**
82
+ * Enable scanning for the presence of loadable to determine side effects
83
+ *
84
+ * @author Ben Jervis <bjervis@atlassian.com>
85
+ * @since 2025-03-07
86
+ */
87
+ loadableSideEffects: false,
88
+ /**
89
+ * Enable performance optimization for the resolver specifier to_string
90
+ * conversions
91
+ *
92
+ * @author Pedro Tacla Yamada <pyamada@atlassian.com>
93
+ * @since 2025-03-13
94
+ */
95
+ reduceResolverStringCreation: false,
96
+ /**
97
+ * Fixes source maps for inline bundles
98
+ *
99
+ * @author Pedro Tacla Yamada <pyamada@atlassian.com>
100
+ * @since 2025-04-08
101
+ */
102
+ inlineBundlesSourceMapFixes: false,
103
+ /** Enable patch project paths. This will patch the project paths to be relative to the project root.
104
+ * This feature is experimental and should not be used in production. It will used to test downloadble cache artefacts.
105
+ *
106
+ * @author Celeste Carloni <ccarloni@atlassian.com>
107
+ * @since 2025-04-10
108
+ */
109
+ patchProjectPaths: false,
110
+ /**
111
+ * Enable resolution of bundler config starting from the CWD
112
+ *
113
+ * @author Ben Jervis <bjervis@atlassian.com>
114
+ * @since 2025-05-29
115
+ */
116
+ resolveBundlerConfigFromCwd: false,
117
+ /**
118
+ * Enable a setting that allows for more assets to be scope hoisted, if
119
+ * they're safe to do so.
120
+ *
121
+ * @author Ben Jervis <bjervis@atlassian.com>
122
+ * @since 2025-06-17
123
+ */
124
+ applyScopeHoistingImprovement: false,
125
+ /**
126
+ * Enable a change where a constant module only have the namespacing object added in bundles where it is required
127
+ *
128
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
129
+ * @since 2025-06-19
130
+ */
131
+ inlineConstOptimisationFix: false,
132
+ /**
133
+ * Improves/fixes HMR behaviour by:
134
+ * - Fixing HMR behaviour with lazy bundle edges
135
+ * - Moving the functionality of the react-refresh runtime into the react-refresh-wrap transformer
136
+ *
137
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
138
+ * @since 2025-06-20
139
+ */
140
+ hmrImprovements: false,
141
+ /**
142
+ * Enables the new packaging progress CLI experience
143
+ *
144
+ * @author Matt Jones <mjones4@atlassian.com>
145
+ * @since 2025-07-02
146
+ */
147
+ cliProgressReportingImprovements: false,
148
+ /**
149
+ * Adds support for `webpackChunkName` comments in dynamic imports.
150
+ * Imports with the same `webpackChunkName` will be bundled together.
151
+ *
152
+ * @author Ben Jervis <bjervis@atlassian.com>
153
+ * @since 2025-07-08
154
+ */
155
+ supportWebpackChunkName: process.env.ATLASPACK_BUILD_ENV === 'test',
156
+ /**
157
+ * Enable a change to the conditional bundling loader to use a fallback bundle loading if the expected scripts aren't found
158
+ *
159
+ * Split into two flags, to allow usage in the dev or prod packagers separately
160
+ *
161
+ * @author Jake Lane <jlane2@atlassian.com>
162
+ * @since 2025-07-08
163
+ */
164
+ condbDevFallbackDev: false,
165
+ /**
166
+ *
167
+ * @author Jake Lane <jlane2@atlassian.com>
168
+ * @since 2025-07-08
169
+ */
170
+ condbDevFallbackProd: false,
171
+ /**
172
+ * Remove redundant shared bundles that are no longer required after merging
173
+ * async bundles.
174
+ *
175
+ * @author Matt Jones <mjones4@atlassian.com>
176
+ * @since 2025-08-20
177
+ */
178
+ removeRedundantSharedBundles: process.env.ATLASPACK_BUILD_ENV === 'test',
179
+ /**
180
+ * When enabled, single file output bundles have a stable name
181
+ *
182
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
183
+ * @since 2025-08-21
184
+ */
185
+ singleFileOutputStableName: process.env.ATLASPACK_BUILD_ENV === 'test',
186
+ /**
187
+ * Enable optimised prelude for the ScopeHoistingPackager.
188
+ *
189
+ * @author Jake Lane <jlane2@atlassian.com>
190
+ * @since 2025-08-22
191
+ */
192
+ useNewPrelude: false,
193
+ /**
194
+ * Enable a fix for applyScopeHoistingImprovement that allows assets to still
195
+ * be at the top level of the bundle.
196
+ *
197
+ * @author Ben Jervis <bjervis@atlassian.com>
198
+ * @since 2025-08-27
199
+ */
200
+ applyScopeHoistingImprovementV2: false,
201
+ /**
202
+ * When enabled, if both explicit entries and explicit targets are specified,
203
+ * the source properties of those targets are used as filters against the base entries.
204
+ * This allows building only specific entries for specific targets.
205
+ *
206
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
207
+ * @since 2025-09-03
208
+ */
209
+ allowExplicitTargetEntries: process.env.ATLASPACK_BUILD_ENV === 'test',
210
+ /**
211
+ * When enabled, the packager will avoid using the binding helper for exports where possible.
212
+ *
213
+ * @author Jake Lane <jlane2@atlassian.com>
214
+ * @since 2025-09-08
215
+ */
216
+ exportsRebindingOptimisation: false,
217
+ /**
218
+ * When enabled, ensures the `unstableSingleFileOutput` environment property is preserved during CSS transformation
219
+ *
220
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
221
+ * @since 2025-09-09
222
+ */
223
+ preserveUnstableSingleFileOutputInCss: process.env.ATLASPACK_BUILD_ENV === 'test',
224
+ /**
225
+ * When enabled, fixes handling of symbol locations when source maps contain
226
+ * project relative paths
227
+ *
228
+ * @author Matt Jones <mjones4@atlassian.com>
229
+ * @since 2025-09-18
230
+ */
231
+ symbolLocationFix: process.env.ATLASPACK_BUILD_ENV === 'test',
232
+ /**
233
+ * When enabled, avoid retaining sourcesContent in memory during transformation.
234
+ * Source contents will be inlined only during final map stringify if needed.
235
+ * @author Shanon Jackson <sjackson3@atlassian.com>
236
+ * @since 2025-09-22
237
+ */
238
+ omitSourcesContentInMemory: false,
239
+ /**
240
+ * Fixes an issue in BundleGraph.fromAssetGraph where Dependency.sourceAssetId
241
+ * diverging from Asset.id can cause it to fail. The fix to to stop using Dependency.sourceAssetId
242
+ * all together and use graph.getNodeIdsConnectedTo instead.
243
+ *
244
+ * @author Matt Jones <mjones4@atlassian.com>
245
+ * @since 2025-09-29
246
+ */
247
+ sourceAssetIdBundleGraphFix: process.env.ATLASPACK_BUILD_ENV === 'test',
248
+ /**
249
+
250
+ * When _disabled_, will early exit from the @atlaspack/transformer-tokens transformation
251
+ *
252
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
253
+ * @since 2025-10-17
254
+ */
255
+ enableTokensTransformer: process.env.ATLASPACK_BUILD_ENV === 'test',
256
+ /*
257
+ * When enabled, applies the SWC compiled CSS in JS transformer to the codebase.
258
+ *
259
+ * This is a temporary feature flag for the migration state. We eventually will remove this transformer plugin and directly use the SWC visitor in the JS transform.
260
+ *
261
+ * @author Jake Lane <jlane2@atlassian.com>
262
+ * @since 2025-10-16
263
+ */
264
+ compiledCssInJsTransformer: process.env.ATLASPACK_BUILD_ENV === 'test',
265
+ /**
266
+ * Fixes an issue where nested Promise.resolve chains mixed with dynamic
267
+ * imports could cause build errors.
268
+ *
269
+ * @author Matt Jones <mjones4@atlassian.com>
270
+ * @since 2025-11-05
271
+ */
272
+ nestedPromiseImportFix: process.env.ATLASPACK_BUILD_ENV === 'test',
273
+ /**
274
+ * Disallows circular package aliases during resolution.
275
+ * This fixes cases where package A aliases to package B, but package B
276
+ * imports package A, causing infinite loops during resolution. Instead,
277
+ * we disable the alias allow package B to import the real package A.
278
+ *
279
+ * This is useful in cases where you create wrapper packages that re-export
280
+ * another package under a different name.
281
+ *
282
+ * @author Matt Jones <mjones4@atlassian.com>
283
+ * @since 2025-11-27
284
+ */
285
+ disallowCircularPackageAliases: process.env.ATLASPACK_BUILD_ENV === 'test',
286
+ /**
287
+ * When enabled, applies the tokens and SWC compiled CSS in JS transformer to the codebase in the core pass
288
+ *
289
+ * @author Jake Lane <jlane2@atlassian.com>
290
+ * @since 2025-12-02
291
+ */
292
+ coreTokensAndCompiledCssInJsTransform: process.env.ATLASPACK_BUILD_ENV === 'test',
293
+ /**
294
+ * Enables experimental mode for runtimes that skips symbol prop in favour of
295
+ * the symbol data added to each runtime asset
296
+ *
297
+ * @author Ben Jervis <bjervis@atlassian.com>
298
+ * @since 2025-12-09
299
+ */
300
+ skipRuntimeSymbolProp: false,
301
+ /**
302
+ * Enable new JSX config loading.
303
+ * The new config is a top-level "react" key in the `@atlaspack/transformer-js` config.
304
+ * When enabled, we no longer use package.json react deps and tsconfig to infer the JSX config.
305
+ *
306
+ * @author Matt Jones <mjones4@atlassian.com>
307
+ * @since 2025-12-09
308
+ */
309
+ newJsxConfig:
310
+ // Enable for tests only in v3 mode
311
+ process.env.ATLASPACK_BUILD_ENV === 'test' &&
312
+ process.env.ATLASPACK_V3 === 'true',
313
+ /**
314
+ * Enable V3 Rust caching
315
+ *
316
+ * @author Matt Jones <mjones4@atlassian.com>
317
+ * @since 2025-12-15
318
+ */
319
+ v3Caching: false,
320
+ /**
321
+ * Use LargeMap in build cache serializer to work around Node 24's Map size limit.
322
+ *
323
+ * @author Matt Jones <mjones4@atlassian.com>
324
+ * @since 2026-01-16
325
+ */
326
+ useLargeMapInBuildCache: process.env.ATLASPACK_BUILD_ENV === 'test',
327
+ /**
328
+ * Enables native packaging. By itself, this feature flag will only ensure that
329
+ * the native code is ready for a bundle graph, but does not enable any native packaging features.
330
+ *
331
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
332
+ * @since 2026-01-21
333
+ */
334
+ nativePackager: false,
335
+ /**
336
+ * Enables native packaging for SSR development. This flag is used in conjuction with runtime checks to enable the
337
+ * setup and use of the native packager when building bundles in development mode for the `tesseract` target.
338
+ *
339
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
340
+ * @since 2026-01-21
341
+ */
342
+ nativePackagerSSRDev: false,
343
+ /**
344
+ * Enables native bundling. When enabled, the bundle graph is built in Rust
345
+ * instead of JavaScript.
346
+ *
347
+ * @author Matt Jones <mjones4@atlassian.com>
348
+ * @since 2026-01-27
349
+ */
350
+ nativeBundling: false,
351
+ /**
352
+ * Enables the full native build pipeline. When enabled, the entire build
353
+ * (asset graph, bundle graph, packaging, and writing) runs natively in Rust
354
+ * via a single NAPI call, bypassing the JS request tracker.
355
+ *
356
+ * @author Matt Jones <mjones4@atlassian.com>
357
+ * @since 2026-03-04
358
+ */
359
+ fullNative: false,
360
+ /**
361
+ * When enabled, tracks HASH_REF replacements during bundle write and adjusts
362
+ * the source map column offsets so mappings remain correct after placeholder
363
+ * replacement.
364
+ *
365
+ * @since 2025-02-10
366
+ * @author Marcin Szczepanski <mszczepanski@atlassian.com>
367
+ */
368
+ fixSourceMapHashRefs: process.env.ATLASPACK_BUILD_ENV === 'test',
369
+ };
370
+ let featureFlagValues = { ...exports.DEFAULT_FEATURE_FLAGS };
371
+ function setFeatureFlags(flags) {
372
+ featureFlagValues = flags;
373
+ }
374
+ function getFeatureFlag(flagName) {
375
+ const value = featureFlagValues[flagName];
376
+ return value === true || value === 'NEW';
377
+ }
378
+ function getFeatureFlagValue(flagName) {
379
+ return featureFlagValues[flagName];
380
+ }
381
+ /**
382
+ * Run a function with a consistency check.
383
+ */
384
+ function runWithConsistencyCheck(flag, oldFn, newFn, diffFn, report) {
385
+ const value = featureFlagValues[flag];
386
+ if (value === false || value === '' || value === 'OLD') {
387
+ return oldFn();
388
+ }
389
+ if (value === true || value === 'NEW') {
390
+ return newFn();
391
+ }
392
+ const oldStartTime = performance.now();
393
+ const oldResult = oldFn();
394
+ const oldExecutionTimeMs = performance.now() - oldStartTime;
395
+ const newStartTime = performance.now();
396
+ const newResult = newFn();
397
+ const newExecutionTimeMs = performance.now() - newStartTime;
398
+ const diff = diffFn(oldResult, newResult);
399
+ report({
400
+ isDifferent: diff.isDifferent,
401
+ oldExecutionTimeMs,
402
+ newExecutionTimeMs,
403
+ custom: diff.custom,
404
+ }, oldResult, newResult);
405
+ if (value === 'NEW_AND_CHECK') {
406
+ return newResult;
407
+ }
408
+ return oldResult;
409
+ }