@atlaspack/core 2.36.0 → 2.38.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.
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  atlaspackNapiCreate,
3
+ atlaspackNapiBuild,
3
4
  atlaspackNapiBuildAssetGraph,
4
5
  atlaspackNapiBuildBundleGraph,
5
6
  atlaspackNapiRespondToFsEvents,
@@ -100,12 +101,29 @@ export class AtlaspackV3 {
100
101
  }
101
102
  }
102
103
 
103
- buildAssetGraph(): Promise<any> {
104
- return atlaspackNapiBuildAssetGraph(this._atlaspack_napi) as Promise<any>;
104
+ buildAssetGraph(
105
+ progressCallback?: (eventJson: string) => void,
106
+ ): Promise<any> {
107
+ return atlaspackNapiBuildAssetGraph(
108
+ this._atlaspack_napi,
109
+ progressCallback,
110
+ ) as Promise<any>;
105
111
  }
106
112
 
107
- buildBundleGraph(): Promise<any> {
108
- return atlaspackNapiBuildBundleGraph(this._atlaspack_napi) as Promise<any>;
113
+ buildBundleGraph(
114
+ progressCallback?: (eventJson: string) => void,
115
+ ): Promise<any> {
116
+ return atlaspackNapiBuildBundleGraph(
117
+ this._atlaspack_napi,
118
+ progressCallback,
119
+ ) as Promise<any>;
120
+ }
121
+
122
+ build(progressCallback: (eventJson: string) => void): Promise<any> {
123
+ return atlaspackNapiBuild(
124
+ this._atlaspack_napi,
125
+ progressCallback,
126
+ ) as Promise<any>;
109
127
  }
110
128
 
111
129
  loadBundleGraph(bundleGraph: BundleGraph): Promise<void> {
@@ -51,4 +51,9 @@ export class FileSystemV3 implements FileSystem {
51
51
  }
52
52
  },
53
53
  );
54
+
55
+ writeFile: JsCallable<[FilePath, number[]], Promise<void>> = jsCallable(
56
+ (path: FilePath, contents: number[]) =>
57
+ this.#fs.writeFile(path, Buffer.from(contents)),
58
+ );
54
59
  }
@@ -173,15 +173,24 @@ export class AtlaspackWorker {
173
173
  resolution: {type: 'excluded'},
174
174
  };
175
175
  }
176
+ // A resolver may return a result without filePath to indicate it didn't
177
+ // resolve the dependency (equivalent to returning null). The JS-side
178
+ // PathRequest treats this as "try the next resolver".
179
+ if (!result.filePath) {
180
+ return {
181
+ invalidations: [],
182
+ resolution: {type: 'unresolved'},
183
+ };
184
+ }
176
185
 
177
186
  return {
178
187
  invalidations: [],
179
188
  resolution: {
180
189
  type: 'resolved',
181
- filePath: result.filePath || '',
190
+ filePath: result.filePath,
182
191
  canDefer: result.canDefer || false,
183
192
  sideEffects: result.sideEffects ?? true,
184
- code: result.code || undefined,
193
+ code: result.code ?? undefined,
185
194
  meta: result.meta || undefined,
186
195
  pipeline: result.pipeline || undefined,
187
196
  priority: dependencyPriorityMap.intoNullable(result.priority),
@@ -7,6 +7,7 @@ import {getFeatureFlag} from '@atlaspack/feature-flags';
7
7
 
8
8
  import AssetGraph from '../AssetGraph';
9
9
  import type {AtlaspackV3} from '../atlaspack-v3';
10
+ import {report} from '../ReporterRunner';
10
11
  import {requestTypes, StaticRunOpts} from '../RequestTracker';
11
12
  import {propagateSymbols} from '../SymbolPropagation';
12
13
  import type {
@@ -54,7 +55,10 @@ export function createAssetGraphRequestRust(
54
55
  run: async (runInput) => {
55
56
  let options = runInput.options;
56
57
  let {assetGraphPromise, commitPromise} =
57
- await rustAtlaspack.buildAssetGraph();
58
+ await rustAtlaspack.buildAssetGraph((eventJson: string) => {
59
+ let event = JSON.parse(eventJson);
60
+ report(event);
61
+ });
58
62
 
59
63
  let [serializedAssetGraph, assetGraphError] =
60
64
  (await assetGraphPromise) as [SerializedAssetGraphDelta, Error | null];
@@ -23,6 +23,7 @@ import {tracer} from '@atlaspack/profiler';
23
23
  import {requestTypes} from '../RequestTracker';
24
24
  import {getFeatureFlag} from '@atlaspack/feature-flags';
25
25
  import {fromEnvironmentId} from '../EnvironmentManager';
26
+ import {tracer as atlaspackTracer} from '@atlaspack/logger';
26
27
 
27
28
  type AtlaspackBuildRequestInput = {
28
29
  optionsRef: SharedReference;
@@ -144,6 +145,8 @@ async function run({
144
145
  });
145
146
 
146
147
  let packagingMeasurement = tracer.createMeasurement('packaging');
148
+ const span = atlaspackTracer.enter('writeBundles');
149
+
147
150
  let writeBundlesRequest = createWriteBundlesRequest({
148
151
  bundleGraph,
149
152
  optionsRef,
@@ -152,6 +155,7 @@ async function run({
152
155
  let {bundleInfo, scopeHoistingStats} =
153
156
  await api.runRequest(writeBundlesRequest);
154
157
  packagingMeasurement && packagingMeasurement.end();
158
+ atlaspackTracer.exit(span);
155
159
  assertSignalNotAborted(signal);
156
160
 
157
161
  return {
@@ -7,6 +7,7 @@ import {instrument, instrumentAsync, PluginLogger} from '@atlaspack/logger';
7
7
  import {getFeatureFlag} from '@atlaspack/feature-flags';
8
8
 
9
9
  import InternalBundleGraph, {bundleGraphEdgeTypes} from '../BundleGraph';
10
+ import {report} from '../ReporterRunner';
10
11
  import dumpGraphToGraphViz from '../dumpGraphToGraphViz';
11
12
  import nullthrows from 'nullthrows';
12
13
  import {hashString} from '@atlaspack/rust';
@@ -96,7 +97,10 @@ export default function createBundleGraphRequestRust(
96
97
  invariant(rustAtlaspack, 'BundleGraphRequestRust requires rustAtlaspack');
97
98
 
98
99
  let {bundleGraphPromise, commitPromise} =
99
- await rustAtlaspack.buildBundleGraph();
100
+ await rustAtlaspack.buildBundleGraph((eventJson: string) => {
101
+ let event = JSON.parse(eventJson);
102
+ report(event);
103
+ });
100
104
  let [serializedBundleGraph, bundleGraphError] =
101
105
  (await bundleGraphPromise) as [SerializedBundleGraph, Error | null];
102
106