@atlaspack/core 2.25.2-dev-9bc89ddee.0 → 2.25.2-dev-9dac9ed3a.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.
@@ -20,13 +20,20 @@ import nullthrows from 'nullthrows';
20
20
  import {hashString} from '@atlaspack/rust';
21
21
  import {createPackageRequest} from './PackageRequest';
22
22
  import createWriteBundleRequest from './WriteBundleRequest';
23
+ import {debugTools} from '@atlaspack/utils';
23
24
 
24
25
  type WriteBundlesRequestInput = {
25
26
  bundleGraph: BundleGraph;
26
27
  optionsRef: SharedReference;
27
28
  };
28
29
 
29
- export type WriteBundlesRequestResult = Map<string, PackagedBundleInfo>;
30
+ export type WriteBundlesRequestResult = {
31
+ bundleInfo: Map<string, PackagedBundleInfo>;
32
+ scopeHoistingStats?: {
33
+ totalAssets: number;
34
+ wrappedAssets: number;
35
+ };
36
+ };
30
37
 
31
38
  type RunInput<TResult> = {
32
39
  input: WriteBundlesRequestInput;
@@ -206,8 +213,30 @@ async function run({
206
213
  }),
207
214
  );
208
215
 
209
- api.storeResult(res);
210
- return res;
216
+ let result: WriteBundlesRequestResult = {bundleInfo: res};
217
+
218
+ if (debugTools['scope-hoisting-stats']) {
219
+ // Aggregate scope hoisting stats from all bundles
220
+ let aggregatedScopeHoistingStats = {
221
+ totalAssets: 0,
222
+ wrappedAssets: 0,
223
+ };
224
+
225
+ for (let bundle of bundles) {
226
+ let bundleInfo = bundleInfoMap[bundle.id];
227
+ if (bundleInfo?.scopeHoistingStats) {
228
+ aggregatedScopeHoistingStats.totalAssets +=
229
+ bundleInfo.scopeHoistingStats.totalAssets;
230
+ aggregatedScopeHoistingStats.wrappedAssets +=
231
+ bundleInfo.scopeHoistingStats.wrappedAssets;
232
+ }
233
+ }
234
+
235
+ result.scopeHoistingStats = aggregatedScopeHoistingStats;
236
+ }
237
+
238
+ api.storeResult(result);
239
+ return result;
211
240
  } finally {
212
241
  await dispose();
213
242
  }
@@ -382,6 +382,9 @@ describe('TargetResolver', () => {
382
382
  loc: undefined,
383
383
  sourceType: 'module',
384
384
  unstableSingleFileOutput: false,
385
+ customEnv: {
386
+ useFlag: 'false',
387
+ },
385
388
  }),
386
389
  loc: {
387
390
  filePath: relative(
@@ -416,6 +419,9 @@ describe('TargetResolver', () => {
416
419
  loc: undefined,
417
420
  sourceType: 'module',
418
421
  unstableSingleFileOutput: false,
422
+ customEnv: {
423
+ useFlag: 'true',
424
+ },
419
425
  }),
420
426
  loc: {
421
427
  filePath: relative(
@@ -501,6 +507,9 @@ describe('TargetResolver', () => {
501
507
  loc: undefined,
502
508
  sourceType: 'module',
503
509
  unstableSingleFileOutput: false,
510
+ customEnv: {
511
+ useFlag: 'false',
512
+ },
504
513
  }),
505
514
  loc: {
506
515
  filePath: relative(
@@ -535,6 +544,9 @@ describe('TargetResolver', () => {
535
544
  loc: undefined,
536
545
  sourceType: 'module',
537
546
  unstableSingleFileOutput: false,
547
+ customEnv: {
548
+ useFlag: 'true',
549
+ },
538
550
  }),
539
551
  loc: {
540
552
  filePath: relative(
@@ -9,11 +9,17 @@
9
9
  "browserModern": {
10
10
  "engines": {
11
11
  "browsers": ["last 1 version"]
12
+ },
13
+ "env": {
14
+ "useFlag": "false"
12
15
  }
13
16
  },
14
17
  "browserLegacy": {
15
18
  "engines": {
16
19
  "browsers": ["ie11"]
20
+ },
21
+ "env": {
22
+ "useFlag": "true"
17
23
  }
18
24
  }
19
25
  }