@atlaspack/core 2.16.2-canary.222 → 2.16.2-canary.230

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.
@@ -46,15 +46,13 @@ export function createPackageRequest(
46
46
  };
47
47
  }
48
48
 
49
- // @ts-expect-error TS7031
50
- async function run({input, api, farm}) {
49
+ async function run({input, api, farm}: RunInput<BundleInfo>) {
51
50
  let {bundleGraphReference, optionsRef, bundle, useMainThread} = input;
52
51
  let runPackage = farm.createHandle('runPackage', useMainThread);
53
52
 
54
53
  let start = Date.now();
55
54
  let {devDeps, invalidDevDeps} = await getDevDepRequests(api);
56
55
  let {cachePath} = nullthrows(
57
- // @ts-expect-error TS2347
58
56
  await api.runRequest<null, ConfigAndCachePath>(
59
57
  createAtlaspackConfigRequest(),
60
58
  ),
@@ -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
  }