@atlaspack/core 2.16.2-canary.369 → 2.16.2-canary.370

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.
@@ -7,6 +7,7 @@ exports.AtlaspackV3 = void 0;
7
7
  const rust_1 = require("@atlaspack/rust");
8
8
  const NapiWorkerPool_1 = require("./NapiWorkerPool");
9
9
  const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
10
+ const assert_1 = __importDefault(require("assert"));
10
11
  class AtlaspackV3 {
11
12
  constructor(atlaspack_napi, napiWorkerPool, isDefaultNapiWorkerPool) {
12
13
  this._atlaspack_napi = atlaspack_napi;
@@ -52,6 +53,7 @@ class AtlaspackV3 {
52
53
  return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
53
54
  }
54
55
  loadBundleGraph({ nodes, edges, }) {
56
+ (0, assert_1.default)(nodes.length > 0, 'Bundle graph must have at least one node');
55
57
  return (0, rust_1.atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodes, edges);
56
58
  }
57
59
  package() {
@@ -48,7 +48,17 @@ async function run({ input, api, options, rustAtlaspack, }) {
48
48
  }
49
49
  });
50
50
  if (hasSupportedTarget) {
51
- await rustAtlaspack.loadBundleGraph({ nodes: [], edges: [] });
51
+ // In theory this could be a (somehow) null[] - but we know if we've gotten this far it probably isn't..
52
+ let nodes = bundleGraph._graph.nodes;
53
+ let rawEdges = [];
54
+ const gen = bundleGraph._graph.getAllEdges();
55
+ let next = gen.next();
56
+ while (!next.done) {
57
+ let edge = next.value;
58
+ rawEdges.push([edge.from, edge.to, edge.type]);
59
+ next = gen.next();
60
+ }
61
+ await rustAtlaspack.loadBundleGraph({ nodes, edges: rawEdges });
52
62
  }
53
63
  }
54
64
  // @ts-expect-error TS2345
@@ -19,6 +19,13 @@ function _diagnostic() {
19
19
  };
20
20
  return data;
21
21
  }
22
+ function _assert() {
23
+ const data = _interopRequireDefault(require("assert"));
24
+ _assert = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
22
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
30
  class AtlaspackV3 {
24
31
  constructor(atlaspack_napi, napiWorkerPool, isDefaultNapiWorkerPool) {
@@ -76,6 +83,7 @@ class AtlaspackV3 {
76
83
  nodes,
77
84
  edges
78
85
  }) {
86
+ (0, _assert().default)(nodes.length > 0, 'Bundle graph must have at least one node');
79
87
  return (0, _rust().atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodes, edges);
80
88
  }
81
89
  package() {
@@ -70,9 +70,19 @@ async function run({
70
70
  }
71
71
  });
72
72
  if (hasSupportedTarget) {
73
+ // In theory this could be a (somehow) null[] - but we know if we've gotten this far it probably isn't..
74
+ let nodes = bundleGraph._graph.nodes;
75
+ let rawEdges = [];
76
+ const gen = bundleGraph._graph.getAllEdges();
77
+ let next = gen.next();
78
+ while (!next.done) {
79
+ let edge = next.value;
80
+ rawEdges.push([edge.from, edge.to, edge.type]);
81
+ next = gen.next();
82
+ }
73
83
  await rustAtlaspack.loadBundleGraph({
74
- nodes: [],
75
- edges: []
84
+ nodes,
85
+ edges: rawEdges
76
86
  });
77
87
  }
78
88
  }
@@ -2,6 +2,7 @@ import { AtlaspackNapi, Lmdb, AtlaspackNapiOptions, CacheStats } from '@atlaspac
2
2
  import type { Event } from '@parcel/watcher';
3
3
  import type { NapiWorkerPool as INapiWorkerPool } from '@atlaspack/types';
4
4
  import { BundleGraphNode } from '../types';
5
+ import { BundleGraphEdgeType } from '../BundleGraph';
5
6
  export type AtlaspackV3Options = {
6
7
  fs?: AtlaspackNapiOptions['fs'];
7
8
  packageManager?: AtlaspackNapiOptions['packageManager'];
@@ -25,7 +26,7 @@ export declare class AtlaspackV3 {
25
26
  buildAssetGraph(): Promise<any>;
26
27
  loadBundleGraph({ nodes, edges, }: {
27
28
  nodes: BundleGraphNode[];
28
- edges: [number, number][];
29
+ edges: [number, number, BundleGraphEdgeType][];
29
30
  }): Promise<any>;
30
31
  package(): Promise<any>;
31
32
  respondToFsEvents(events: Array<Event>): Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.16.2-canary.369+af6d2ca13",
3
+ "version": "2.16.2-canary.370+e8ea59bea",
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.437+af6d2ca13",
26
- "@atlaspack/cache": "3.1.1-canary.369+af6d2ca13",
27
- "@atlaspack/diagnostic": "2.14.1-canary.437+af6d2ca13",
28
- "@atlaspack/events": "2.14.1-canary.437+af6d2ca13",
29
- "@atlaspack/feature-flags": "2.14.1-canary.437+af6d2ca13",
30
- "@atlaspack/fs": "2.14.5-canary.369+af6d2ca13",
31
- "@atlaspack/graph": "3.4.1-canary.437+af6d2ca13",
32
- "@atlaspack/logger": "2.14.5-canary.369+af6d2ca13",
33
- "@atlaspack/package-manager": "2.14.5-canary.369+af6d2ca13",
34
- "@atlaspack/plugin": "2.14.5-canary.369+af6d2ca13",
35
- "@atlaspack/profiler": "2.14.1-canary.437+af6d2ca13",
36
- "@atlaspack/rust": "3.2.1-canary.369+af6d2ca13",
37
- "@atlaspack/source-map": "3.2.5-canary.4148+af6d2ca13",
38
- "@atlaspack/types": "2.14.5-canary.369+af6d2ca13",
39
- "@atlaspack/utils": "2.14.5-canary.369+af6d2ca13",
40
- "@atlaspack/workers": "2.14.5-canary.369+af6d2ca13",
25
+ "@atlaspack/build-cache": "2.13.3-canary.438+e8ea59bea",
26
+ "@atlaspack/cache": "3.1.1-canary.370+e8ea59bea",
27
+ "@atlaspack/diagnostic": "2.14.1-canary.438+e8ea59bea",
28
+ "@atlaspack/events": "2.14.1-canary.438+e8ea59bea",
29
+ "@atlaspack/feature-flags": "2.14.1-canary.438+e8ea59bea",
30
+ "@atlaspack/fs": "2.14.5-canary.370+e8ea59bea",
31
+ "@atlaspack/graph": "3.4.1-canary.438+e8ea59bea",
32
+ "@atlaspack/logger": "2.14.5-canary.370+e8ea59bea",
33
+ "@atlaspack/package-manager": "2.14.5-canary.370+e8ea59bea",
34
+ "@atlaspack/plugin": "2.14.5-canary.370+e8ea59bea",
35
+ "@atlaspack/profiler": "2.14.1-canary.438+e8ea59bea",
36
+ "@atlaspack/rust": "3.2.1-canary.370+e8ea59bea",
37
+ "@atlaspack/source-map": "3.2.5-canary.4149+e8ea59bea",
38
+ "@atlaspack/types": "2.14.5-canary.370+e8ea59bea",
39
+ "@atlaspack/utils": "2.14.5-canary.370+e8ea59bea",
40
+ "@atlaspack/workers": "2.14.5-canary.370+e8ea59bea",
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": "af6d2ca13c802a32cd586b81fa4f81140ca48862"
64
+ "gitHead": "e8ea59beabb4b4fef647dc9ebea3519b6d56d7b5"
65
65
  }
@@ -15,6 +15,8 @@ import ThrowableDiagnostic from '@atlaspack/diagnostic';
15
15
  import type {Event} from '@parcel/watcher';
16
16
  import type {NapiWorkerPool as INapiWorkerPool} from '@atlaspack/types';
17
17
  import {BundleGraphNode} from '../types';
18
+ import invariant from 'assert';
19
+ import {BundleGraphEdgeType} from '../BundleGraph';
18
20
 
19
21
  export type AtlaspackV3Options = {
20
22
  fs?: AtlaspackNapiOptions['fs'];
@@ -105,8 +107,9 @@ export class AtlaspackV3 {
105
107
  edges,
106
108
  }: {
107
109
  nodes: BundleGraphNode[];
108
- edges: [number, number][];
110
+ edges: [number, number, BundleGraphEdgeType][];
109
111
  }): Promise<any> {
112
+ invariant(nodes.length > 0, 'Bundle graph must have at least one node');
110
113
  return atlaspackNapiLoadBundleGraph(
111
114
  this._atlaspack_napi,
112
115
  nodes,
@@ -3,7 +3,12 @@ import type {Async} from '@atlaspack/types';
3
3
  import type {SharedReference} from '@atlaspack/workers';
4
4
 
5
5
  import type {StaticRunOpts} from '../RequestTracker';
6
- import type {Asset, AssetGroup, PackagedBundleInfo} from '../types';
6
+ import type {
7
+ Asset,
8
+ AssetGroup,
9
+ BundleGraphNode,
10
+ PackagedBundleInfo,
11
+ } from '../types';
7
12
  import type BundleGraph from '../BundleGraph';
8
13
 
9
14
  import createBundleGraphRequest, {
@@ -12,7 +17,7 @@ import createBundleGraphRequest, {
12
17
  import createWriteBundlesRequest from './WriteBundlesRequest';
13
18
  import {assertSignalNotAborted} from '../utils';
14
19
  import dumpGraphToGraphViz from '../dumpGraphToGraphViz';
15
- import {bundleGraphEdgeTypes} from '../BundleGraph';
20
+ import {BundleGraphEdgeType, bundleGraphEdgeTypes} from '../BundleGraph';
16
21
  import {report} from '../ReporterRunner';
17
22
  import IBundleGraph from '../public/BundleGraph';
18
23
  import {NamedBundle} from '../public/Bundle';
@@ -22,6 +27,7 @@ import {tracer} from '@atlaspack/profiler';
22
27
  import {requestTypes} from '../RequestTracker';
23
28
  import {getFeatureFlag} from '@atlaspack/feature-flags';
24
29
  import {fromEnvironmentId} from '../EnvironmentManager';
30
+ import invariant from 'assert';
25
31
 
26
32
  type AtlaspackBuildRequestInput = {
27
33
  optionsRef: SharedReference;
@@ -101,7 +107,17 @@ async function run({
101
107
  }
102
108
  });
103
109
  if (hasSupportedTarget) {
104
- await rustAtlaspack.loadBundleGraph({nodes: [], edges: []});
110
+ // In theory this could be a (somehow) null[] - but we know if we've gotten this far it probably isn't..
111
+ let nodes = bundleGraph._graph.nodes as BundleGraphNode[];
112
+ let rawEdges: [number, number, BundleGraphEdgeType][] = [];
113
+ const gen = bundleGraph._graph.getAllEdges();
114
+ let next = gen.next();
115
+ while (!next.done) {
116
+ let edge = next.value;
117
+ rawEdges.push([edge.from, edge.to, edge.type]);
118
+ next = gen.next();
119
+ }
120
+ await rustAtlaspack.loadBundleGraph({nodes, edges: rawEdges});
105
121
  }
106
122
  }
107
123