@atlaspack/core 2.12.1-canary.3565 → 2.12.1-canary.3567

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.
@@ -1116,9 +1116,16 @@ class BundleGraph {
1116
1116
  if (!this._graph.hasContentKey(dep.id)) {
1117
1117
  return null;
1118
1118
  }
1119
- let res = this._graph.getNodeIdsConnectedTo(this._graph.getNodeIdByContentKey(dep.id));
1120
- (0, _assert().default)(res.length <= 1, 'Expected a single asset to be connected to a dependency');
1121
- let resNode = this._graph.getNode(res[0]);
1119
+ let res = null;
1120
+ let count = 0;
1121
+ this._graph.forEachNodeIdConnectedTo(this._graph.getNodeIdByContentKey(dep.id), node => {
1122
+ res = node;
1123
+ count += 1;
1124
+ if (count > 1) {
1125
+ throw new Error('Expected a single asset to be connected to a dependency');
1126
+ }
1127
+ }, 1);
1128
+ let resNode = res != null ? this._graph.getNode(res) : null;
1122
1129
  if ((resNode === null || resNode === void 0 ? void 0 : resNode.type) === 'asset') {
1123
1130
  return resNode.value;
1124
1131
  }
@@ -12,6 +12,14 @@ function _rust() {
12
12
  return data;
13
13
  }
14
14
  var _WorkerPool = require("./WorkerPool");
15
+ function _diagnostic() {
16
+ const data = _interopRequireDefault(require("@atlaspack/diagnostic"));
17
+ _diagnostic = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
23
  class AtlaspackV3 {
16
24
  constructor({
17
25
  fs,
@@ -35,7 +43,7 @@ class AtlaspackV3 {
35
43
  }
36
44
  async buildAssetGraph() {
37
45
  const workerIds = [];
38
- let result = await this._internal.buildAssetGraph({
46
+ let [graph, error] = await this._internal.buildAssetGraph({
39
47
  registerWorker: tx_worker => {
40
48
  // $FlowFixMe
41
49
  const workerId = _WorkerPool.workerPool.registerWorker(tx_worker);
@@ -43,7 +51,12 @@ class AtlaspackV3 {
43
51
  }
44
52
  });
45
53
  _WorkerPool.workerPool.releaseWorkers(workerIds);
46
- return result;
54
+ if (error !== null) {
55
+ throw new (_diagnostic().default)({
56
+ diagnostic: error
57
+ });
58
+ }
59
+ return graph;
47
60
  }
48
61
  }
49
62
  exports.AtlaspackV3 = AtlaspackV3;
@@ -31,15 +31,8 @@ function createAssetGraphRequestRust(rustAtlaspack) {
31
31
  id: input.name,
32
32
  run: async input => {
33
33
  let options = input.options;
34
- let serializedAssetGraph;
35
- try {
36
- serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
37
- serializedAssetGraph.nodes = serializedAssetGraph.nodes.flatMap(node => JSON.parse(node));
38
- } catch (err) {
39
- throw new (_diagnostic().default)({
40
- diagnostic: err
41
- });
42
- }
34
+ let serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
35
+ serializedAssetGraph.nodes = serializedAssetGraph.nodes.flatMap(node => JSON.parse(node));
43
36
  let {
44
37
  assetGraph,
45
38
  changedAssets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.12.1-canary.3565+2b1e35dc3",
3
+ "version": "2.12.1-canary.3567+e0effea53",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,21 +20,21 @@
20
20
  "check-ts": "tsc --noEmit index.d.ts"
21
21
  },
22
22
  "dependencies": {
23
- "@atlaspack/build-cache": "2.12.1-canary.3565+2b1e35dc3",
24
- "@atlaspack/cache": "2.12.1-canary.3565+2b1e35dc3",
25
- "@atlaspack/diagnostic": "2.12.1-canary.3565+2b1e35dc3",
26
- "@atlaspack/events": "2.12.1-canary.3565+2b1e35dc3",
27
- "@atlaspack/feature-flags": "2.12.1-canary.3565+2b1e35dc3",
28
- "@atlaspack/fs": "2.12.1-canary.3565+2b1e35dc3",
29
- "@atlaspack/graph": "3.2.1-canary.3565+2b1e35dc3",
30
- "@atlaspack/logger": "2.12.1-canary.3565+2b1e35dc3",
31
- "@atlaspack/package-manager": "2.12.1-canary.3565+2b1e35dc3",
32
- "@atlaspack/plugin": "2.12.1-canary.3565+2b1e35dc3",
33
- "@atlaspack/profiler": "2.12.1-canary.3565+2b1e35dc3",
34
- "@atlaspack/rust": "2.12.1-canary.3565+2b1e35dc3",
35
- "@atlaspack/types": "2.12.1-canary.3565+2b1e35dc3",
36
- "@atlaspack/utils": "2.12.1-canary.3565+2b1e35dc3",
37
- "@atlaspack/workers": "2.12.1-canary.3565+2b1e35dc3",
23
+ "@atlaspack/build-cache": "2.12.1-canary.3567+e0effea53",
24
+ "@atlaspack/cache": "2.12.1-canary.3567+e0effea53",
25
+ "@atlaspack/diagnostic": "2.12.1-canary.3567+e0effea53",
26
+ "@atlaspack/events": "2.12.1-canary.3567+e0effea53",
27
+ "@atlaspack/feature-flags": "2.12.1-canary.3567+e0effea53",
28
+ "@atlaspack/fs": "2.12.1-canary.3567+e0effea53",
29
+ "@atlaspack/graph": "3.2.1-canary.3567+e0effea53",
30
+ "@atlaspack/logger": "2.12.1-canary.3567+e0effea53",
31
+ "@atlaspack/package-manager": "2.12.1-canary.3567+e0effea53",
32
+ "@atlaspack/plugin": "2.12.1-canary.3567+e0effea53",
33
+ "@atlaspack/profiler": "2.12.1-canary.3567+e0effea53",
34
+ "@atlaspack/rust": "2.12.1-canary.3567+e0effea53",
35
+ "@atlaspack/types": "2.12.1-canary.3567+e0effea53",
36
+ "@atlaspack/utils": "2.12.1-canary.3567+e0effea53",
37
+ "@atlaspack/workers": "2.12.1-canary.3567+e0effea53",
38
38
  "@mischnic/json-sourcemap": "^0.1.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
@@ -66,5 +66,5 @@
66
66
  "browser": {
67
67
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
68
  },
69
- "gitHead": "2b1e35dc3d51843fba13edcb958c01406ff355e4"
69
+ "gitHead": "e0effea53c21b3c3e3bc9d368468c562e5f80531"
70
70
  }
@@ -1773,14 +1773,23 @@ export default class BundleGraph {
1773
1773
  return null;
1774
1774
  }
1775
1775
 
1776
- let res = this._graph.getNodeIdsConnectedTo(
1776
+ let res = null;
1777
+ let count = 0;
1778
+ this._graph.forEachNodeIdConnectedTo(
1777
1779
  this._graph.getNodeIdByContentKey(dep.id),
1780
+ (node) => {
1781
+ res = node;
1782
+ count += 1;
1783
+ if (count > 1) {
1784
+ throw new Error(
1785
+ 'Expected a single asset to be connected to a dependency',
1786
+ );
1787
+ }
1788
+ },
1789
+ 1,
1778
1790
  );
1779
- invariant(
1780
- res.length <= 1,
1781
- 'Expected a single asset to be connected to a dependency',
1782
- );
1783
- let resNode = this._graph.getNode(res[0]);
1791
+
1792
+ let resNode = res != null ? this._graph.getNode(res) : null;
1784
1793
  if (resNode?.type === 'asset') {
1785
1794
  return resNode.value;
1786
1795
  }
@@ -6,6 +6,7 @@ import {
6
6
  type AtlaspackNapiOptions,
7
7
  } from '@atlaspack/rust';
8
8
  import {workerPool} from './WorkerPool';
9
+ import ThrowableDiagnostic from '@atlaspack/diagnostic';
9
10
 
10
11
  export type AtlaspackV3Options = {|
11
12
  fs?: AtlaspackNapiOptions['fs'],
@@ -50,7 +51,8 @@ export class AtlaspackV3 {
50
51
 
51
52
  async buildAssetGraph(): Promise<any> {
52
53
  const workerIds = [];
53
- let result = await this._internal.buildAssetGraph({
54
+
55
+ let [graph, error] = await this._internal.buildAssetGraph({
54
56
  registerWorker: (tx_worker) => {
55
57
  // $FlowFixMe
56
58
  const workerId = workerPool.registerWorker(tx_worker);
@@ -60,6 +62,12 @@ export class AtlaspackV3 {
60
62
 
61
63
  workerPool.releaseWorkers(workerIds);
62
64
 
63
- return result;
65
+ if (error !== null) {
66
+ throw new ThrowableDiagnostic({
67
+ diagnostic: error,
68
+ });
69
+ }
70
+
71
+ return graph;
64
72
  }
65
73
  }
@@ -37,17 +37,11 @@ export function createAssetGraphRequestRust(
37
37
  id: input.name,
38
38
  run: async (input) => {
39
39
  let options = input.options;
40
- let serializedAssetGraph;
41
- try {
42
- serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
43
- serializedAssetGraph.nodes = serializedAssetGraph.nodes.flatMap(
44
- (node) => JSON.parse(node),
45
- );
46
- } catch (err) {
47
- throw new ThrowableDiagnostic({
48
- diagnostic: err,
49
- });
50
- }
40
+ let serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
41
+
42
+ serializedAssetGraph.nodes = serializedAssetGraph.nodes.flatMap((node) =>
43
+ JSON.parse(node),
44
+ );
51
45
 
52
46
  let {assetGraph, changedAssets} = instrument(
53
47
  'atlaspack_v3_getAssetGraph',