@atlaspack/core 2.16.2-canary.293 → 2.16.2-canary.295

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.
@@ -48,15 +48,8 @@ class AtlaspackV3 {
48
48
  this._napiWorkerPool.shutdown();
49
49
  }
50
50
  }
51
- async buildAssetGraph() {
52
- // @ts-expect-error TS2488
53
- let [graph, error] = await (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
54
- if (error !== null) {
55
- throw new diagnostic_1.default({
56
- diagnostic: error,
57
- });
58
- }
59
- return graph;
51
+ buildAssetGraph() {
52
+ return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
60
53
  }
61
54
  async respondToFsEvents(events) {
62
55
  // @ts-expect-error TS2488
@@ -22,11 +22,13 @@ function createAssetGraphRequestRust(rustAtlaspack) {
22
22
  id: input.name,
23
23
  run: async (input) => {
24
24
  let options = input.options;
25
- let serializedAssetGraph = (await rustAtlaspack.buildAssetGraph());
26
- // Newly created nodes
27
- serializedAssetGraph.nodes = serializedAssetGraph.nodes.map((node) => JSON.parse(node));
28
- // Updated existing nodes
29
- serializedAssetGraph.updates = serializedAssetGraph.updates.map((node) => JSON.parse(node));
25
+ let { assetGraphPromise, commitPromise } = await rustAtlaspack.buildAssetGraph();
26
+ let [serializedAssetGraph, assetGraphError] = (await assetGraphPromise);
27
+ if (assetGraphError) {
28
+ throw new diagnostic_1.default({
29
+ diagnostic: assetGraphError,
30
+ });
31
+ }
30
32
  // Don't reuse a previous asset graph result if Rust didn't have one too
31
33
  let prevResult = null;
32
34
  if (serializedAssetGraph.hadPreviousGraph) {
@@ -58,6 +60,14 @@ function createAssetGraphRequestRust(rustAtlaspack) {
58
60
  changedAssetsPropagation,
59
61
  previousSymbolPropagationErrors: undefined,
60
62
  };
63
+ let [_commitResult, commitError] = await commitPromise;
64
+ if (commitError) {
65
+ throw new diagnostic_1.default({
66
+ diagnostic: {
67
+ message: 'Error committing asset graph in Rust: ' + commitError.message,
68
+ },
69
+ });
70
+ }
61
71
  await input.api.storeResult(result);
62
72
  input.api.invalidateOnBuild();
63
73
  return result;
@@ -168,6 +178,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
168
178
  let node = isUpdateNode
169
179
  ? serializedGraph.updates[index - nodeTypeSwitchoverIndex]
170
180
  : serializedGraph.nodes[index];
181
+ node = JSON.parse(node);
171
182
  if (node.type === 'entry') {
172
183
  let id = 'entry:' + ++entry;
173
184
  graph.addNodeByContentKey(id, {
@@ -69,15 +69,8 @@ class AtlaspackV3 {
69
69
  this._napiWorkerPool.shutdown();
70
70
  }
71
71
  }
72
- async buildAssetGraph() {
73
- // @ts-expect-error TS2488
74
- let [graph, error] = await (0, _rust().atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
75
- if (error !== null) {
76
- throw new (_diagnostic().default)({
77
- diagnostic: error
78
- });
79
- }
80
- return graph;
72
+ buildAssetGraph() {
73
+ return (0, _rust().atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
81
74
  }
82
75
  async respondToFsEvents(events) {
83
76
  // @ts-expect-error TS2488
@@ -46,13 +46,16 @@ function createAssetGraphRequestRust(rustAtlaspack) {
46
46
  id: input.name,
47
47
  run: async input => {
48
48
  let options = input.options;
49
- let serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
50
-
51
- // Newly created nodes
52
- serializedAssetGraph.nodes = serializedAssetGraph.nodes.map(node => JSON.parse(node));
53
-
54
- // Updated existing nodes
55
- serializedAssetGraph.updates = serializedAssetGraph.updates.map(node => JSON.parse(node));
49
+ let {
50
+ assetGraphPromise,
51
+ commitPromise
52
+ } = await rustAtlaspack.buildAssetGraph();
53
+ let [serializedAssetGraph, assetGraphError] = await assetGraphPromise;
54
+ if (assetGraphError) {
55
+ throw new (_diagnostic().default)({
56
+ diagnostic: assetGraphError
57
+ });
58
+ }
56
59
 
57
60
  // Don't reuse a previous asset graph result if Rust didn't have one too
58
61
  let prevResult = null;
@@ -91,6 +94,14 @@ function createAssetGraphRequestRust(rustAtlaspack) {
91
94
  changedAssetsPropagation,
92
95
  previousSymbolPropagationErrors: undefined
93
96
  };
97
+ let [_commitResult, commitError] = await commitPromise;
98
+ if (commitError) {
99
+ throw new (_diagnostic().default)({
100
+ diagnostic: {
101
+ message: 'Error committing asset graph in Rust: ' + commitError.message
102
+ }
103
+ });
104
+ }
94
105
  await input.api.storeResult(result);
95
106
  input.api.invalidateOnBuild();
96
107
  return result;
@@ -188,6 +199,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
188
199
  for (let index = 0; index < nodesCount; index++) {
189
200
  let isUpdateNode = index >= nodeTypeSwitchoverIndex;
190
201
  let node = isUpdateNode ? serializedGraph.updates[index - nodeTypeSwitchoverIndex] : serializedGraph.nodes[index];
202
+ node = JSON.parse(node);
191
203
  if (node.type === 'entry') {
192
204
  let id = 'entry:' + ++entry;
193
205
  graph.addNodeByContentKey(id, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.16.2-canary.293+57105322b",
3
+ "version": "2.16.2-canary.295+28f5424f7",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,22 +22,22 @@
22
22
  "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
23
23
  },
24
24
  "dependencies": {
25
- "@atlaspack/build-cache": "2.13.3-canary.361+57105322b",
26
- "@atlaspack/cache": "3.1.1-canary.293+57105322b",
27
- "@atlaspack/diagnostic": "2.14.1-canary.361+57105322b",
28
- "@atlaspack/events": "2.14.1-canary.361+57105322b",
29
- "@atlaspack/feature-flags": "2.14.1-canary.361+57105322b",
30
- "@atlaspack/fs": "2.14.5-canary.293+57105322b",
31
- "@atlaspack/graph": "3.4.1-canary.361+57105322b",
32
- "@atlaspack/logger": "2.14.5-canary.293+57105322b",
33
- "@atlaspack/package-manager": "2.14.5-canary.293+57105322b",
34
- "@atlaspack/plugin": "2.14.5-canary.293+57105322b",
35
- "@atlaspack/profiler": "2.14.1-canary.361+57105322b",
36
- "@atlaspack/rust": "3.2.1-canary.293+57105322b",
37
- "@atlaspack/source-map": "3.1.1-canary.4072+57105322b",
38
- "@atlaspack/types": "2.14.5-canary.293+57105322b",
39
- "@atlaspack/utils": "2.14.5-canary.293+57105322b",
40
- "@atlaspack/workers": "2.14.5-canary.293+57105322b",
25
+ "@atlaspack/build-cache": "2.13.3-canary.363+28f5424f7",
26
+ "@atlaspack/cache": "3.1.1-canary.295+28f5424f7",
27
+ "@atlaspack/diagnostic": "2.14.1-canary.363+28f5424f7",
28
+ "@atlaspack/events": "2.14.1-canary.363+28f5424f7",
29
+ "@atlaspack/feature-flags": "2.14.1-canary.363+28f5424f7",
30
+ "@atlaspack/fs": "2.14.5-canary.295+28f5424f7",
31
+ "@atlaspack/graph": "3.4.1-canary.363+28f5424f7",
32
+ "@atlaspack/logger": "2.14.5-canary.295+28f5424f7",
33
+ "@atlaspack/package-manager": "2.14.5-canary.295+28f5424f7",
34
+ "@atlaspack/plugin": "2.14.5-canary.295+28f5424f7",
35
+ "@atlaspack/profiler": "2.14.1-canary.363+28f5424f7",
36
+ "@atlaspack/rust": "3.2.1-canary.295+28f5424f7",
37
+ "@atlaspack/source-map": "3.1.1-canary.4074+28f5424f7",
38
+ "@atlaspack/types": "2.14.5-canary.295+28f5424f7",
39
+ "@atlaspack/utils": "2.14.5-canary.295+28f5424f7",
40
+ "@atlaspack/workers": "2.14.5-canary.295+28f5424f7",
41
41
  "@mischnic/json-sourcemap": "^0.1.0",
42
42
  "base-x": "^3.0.8",
43
43
  "browserslist": "^4.6.6",
@@ -61,5 +61,5 @@
61
61
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
62
62
  },
63
63
  "type": "commonjs",
64
- "gitHead": "57105322b26ce42af2cbfcc0506cff929e50b630"
64
+ "gitHead": "28f5424f7e2080dd4fbbeb1bc5314a530197a23e"
65
65
  }
@@ -91,19 +91,8 @@ export class AtlaspackV3 {
91
91
  }
92
92
  }
93
93
 
94
- async buildAssetGraph(): Promise<any> {
95
- // @ts-expect-error TS2488
96
- let [graph, error] = await atlaspackNapiBuildAssetGraph(
97
- this._atlaspack_napi,
98
- );
99
-
100
- if (error !== null) {
101
- throw new ThrowableDiagnostic({
102
- diagnostic: error,
103
- });
104
- }
105
-
106
- return graph;
94
+ buildAssetGraph(): Promise<any> {
95
+ return atlaspackNapiBuildAssetGraph(this._atlaspack_napi) as Promise<any>;
107
96
  }
108
97
 
109
98
  async respondToFsEvents(events: Array<Event>): Promise<boolean> {
@@ -53,18 +53,17 @@ export function createAssetGraphRequestRust(
53
53
  id: input.name,
54
54
  run: async (input) => {
55
55
  let options = input.options;
56
- let serializedAssetGraph =
57
- (await rustAtlaspack.buildAssetGraph()) as SerializedAssetGraphDelta;
56
+ let {assetGraphPromise, commitPromise} =
57
+ await rustAtlaspack.buildAssetGraph();
58
58
 
59
- // Newly created nodes
60
- serializedAssetGraph.nodes = serializedAssetGraph.nodes.map((node) =>
61
- JSON.parse(node),
62
- );
59
+ let [serializedAssetGraph, assetGraphError] =
60
+ (await assetGraphPromise) as [SerializedAssetGraphDelta, Error | null];
63
61
 
64
- // Updated existing nodes
65
- serializedAssetGraph.updates = serializedAssetGraph.updates.map((node) =>
66
- JSON.parse(node),
67
- );
62
+ if (assetGraphError) {
63
+ throw new ThrowableDiagnostic({
64
+ diagnostic: assetGraphError,
65
+ });
66
+ }
68
67
 
69
68
  // Don't reuse a previous asset graph result if Rust didn't have one too
70
69
  let prevResult = null;
@@ -106,6 +105,17 @@ export function createAssetGraphRequestRust(
106
105
  previousSymbolPropagationErrors: undefined,
107
106
  };
108
107
 
108
+ let [_commitResult, commitError] = await commitPromise;
109
+
110
+ if (commitError) {
111
+ throw new ThrowableDiagnostic({
112
+ diagnostic: {
113
+ message:
114
+ 'Error committing asset graph in Rust: ' + commitError.message,
115
+ },
116
+ });
117
+ }
118
+
109
119
  await input.api.storeResult(result);
110
120
  input.api.invalidateOnBuild();
111
121
 
@@ -242,6 +252,8 @@ export function getAssetGraph(
242
252
  ? serializedGraph.updates[index - nodeTypeSwitchoverIndex]
243
253
  : serializedGraph.nodes[index];
244
254
 
255
+ node = JSON.parse(node);
256
+
245
257
  if (node.type === 'entry') {
246
258
  let id = 'entry:' + ++entry;
247
259