@vltpkg/graph 1.3.4 → 1.3.5

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.
@@ -62,17 +62,24 @@ export const build = async (options) => {
62
62
  });
63
63
  }
64
64
  // Start resolving the importers' dependencies server-side, one request
65
- // to the default registry. manifest() picks the answers up as they land.
66
- prefetchResolve(graph, packageInfo, options);
67
- const res = await buildIdealFromStartingGraph({
68
- ...options,
69
- scurry,
70
- add: getMap(options.add),
71
- graph,
72
- packageInfo,
73
- remove: getMap(options.remove),
74
- actual: options.actual,
75
- });
65
+ // to the default registry. manifest() picks the answers up as they land,
66
+ // and nothing reads them once the ideal graph is built.
67
+ const releaseResolve = prefetchResolve(graph, packageInfo, options);
68
+ let res;
69
+ try {
70
+ res = await buildIdealFromStartingGraph({
71
+ ...options,
72
+ scurry,
73
+ add: getMap(options.add),
74
+ graph,
75
+ packageInfo,
76
+ remove: getMap(options.remove),
77
+ actual: options.actual,
78
+ });
79
+ }
80
+ finally {
81
+ releaseResolve();
82
+ }
76
83
  done();
77
84
  // when adding or removing a new dependency from a file dep,
78
85
  // validate the receiver node was present in the graph
@@ -2,9 +2,14 @@ import type { PackageInfoClient } from '@vltpkg/package-info';
2
2
  import type { SpecOptions } from '@vltpkg/spec';
3
3
  import type { Graph } from '../graph.ts';
4
4
  /**
5
- * Start a server-side resolve for the importers' dependencies, one request
6
- * to the default registry, without waiting for it: the request overlaps
7
- * whatever the build does before it asks for its first manifest.
5
+ * Start a server-side resolve for the importers' dependencies the starting
6
+ * graph does not already satisfy, one request to the default registry,
7
+ * without waiting for it: the request overlaps whatever the build does
8
+ * before it asks for its first manifest. A graph loaded whole from a
9
+ * lockfile or node_modules sends nothing.
10
+ *
11
+ * Returns the function that releases the request, for the build to call
12
+ * once it has placed its last node.
8
13
  *
9
14
  * Fails soft in every direction: a registry that does not serve the
10
15
  * endpoint, a request that errors, and a spec it does not resolve all
@@ -12,4 +17,4 @@ import type { Graph } from '../graph.ts';
12
17
  */
13
18
  export declare const prefetchResolve: (graph: Graph, packageInfo: PackageInfoClient, options: SpecOptions & {
14
19
  modifiers?: unknown;
15
- }) => number;
20
+ }) => (() => void);
@@ -1,8 +1,14 @@
1
1
  import { detectLibc } from '@vltpkg/pick-manifest';
2
+ const nothing = () => { };
2
3
  /**
3
- * Start a server-side resolve for the importers' dependencies, one request
4
- * to the default registry, without waiting for it: the request overlaps
5
- * whatever the build does before it asks for its first manifest.
4
+ * Start a server-side resolve for the importers' dependencies the starting
5
+ * graph does not already satisfy, one request to the default registry,
6
+ * without waiting for it: the request overlaps whatever the build does
7
+ * before it asks for its first manifest. A graph loaded whole from a
8
+ * lockfile or node_modules sends nothing.
9
+ *
10
+ * Returns the function that releases the request, for the build to call
11
+ * once it has placed its last node.
6
12
  *
7
13
  * Fails soft in every direction: a registry that does not serve the
8
14
  * endpoint, a request that errors, and a spec it does not resolve all
@@ -12,10 +18,10 @@ export const prefetchResolve = (graph, packageInfo, options) => {
12
18
  // a modifier can swap any spec mid-graph, taking the server's whole
13
19
  // closure off the client's real one; those installs resolve locally
14
20
  if (options.modifiers)
15
- return 0;
21
+ return nothing;
16
22
  const registry = options.registry;
17
23
  if (!registry)
18
- return 0;
24
+ return nothing;
19
25
  const scopes = Object.keys(options['scoped-registries'] ?? {});
20
26
  // a name under a scoped registry is that registry's; it is not sent to
21
27
  // this one at all, and `stop` keeps the server from walking into it
@@ -40,6 +46,11 @@ export const prefetchResolve = (graph, packageInfo, options) => {
40
46
  // protocols, workspace and file specs are the client's to resolve
41
47
  if (spec.includes(':') || scoped(name))
42
48
  continue;
49
+ // an edge the starting graph already resolves to a node that
50
+ // satisfies this very spec is settled; the build keeps it as is
51
+ const edge = importer.edgesOut.get(name);
52
+ if (edge?.to && edge.spec.bareSpec === spec && edge.valid())
53
+ continue;
43
54
  const key = `${name}@${spec}`;
44
55
  if (seen.has(key))
45
56
  continue;
@@ -49,7 +60,7 @@ export const prefetchResolve = (graph, packageInfo, options) => {
49
60
  }
50
61
  }
51
62
  if (!roots.length)
52
- return 0;
63
+ return nothing;
53
64
  const have = [];
54
65
  for (const node of graph.nodes.values()) {
55
66
  if (node.manifest &&
@@ -59,7 +70,7 @@ export const prefetchResolve = (graph, packageInfo, options) => {
59
70
  have.push(`${node.name}@${node.version}`);
60
71
  }
61
72
  }
62
- packageInfo.prefetchResolve(registry, {
73
+ return packageInfo.prefetchResolve(registry, {
63
74
  roots,
64
75
  have,
65
76
  ...(scopes.length ? { stop: { scopes } } : {}),
@@ -71,5 +82,4 @@ export const prefetchResolve = (graph, packageInfo, options) => {
71
82
  libc: detectLibc(),
72
83
  },
73
84
  });
74
- return roots.length;
75
85
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/graph",
3
3
  "description": "A library that helps understanding & expressing what happens on an install",
4
- "version": "1.3.4",
4
+ "version": "1.3.5",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,26 +13,26 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/cmd-shim": "1.3.4",
17
- "@vltpkg/dep-id": "1.3.4",
18
- "@vltpkg/dss-breadcrumb": "1.3.4",
19
- "@vltpkg/error-cause": "1.3.4",
20
- "@vltpkg/fast-split": "1.3.4",
21
- "@vltpkg/graph-run": "1.3.4",
22
- "@vltpkg/init": "1.3.4",
23
- "@vltpkg/output": "1.3.4",
24
- "@vltpkg/package-info": "1.3.4",
25
- "@vltpkg/package-json": "1.3.4",
26
- "@vltpkg/pick-manifest": "1.3.4",
27
- "@vltpkg/query": "1.3.4",
28
- "@vltpkg/rollback-remove": "1.3.4",
29
- "@vltpkg/run": "1.3.4",
30
- "@vltpkg/satisfies": "1.3.4",
31
- "@vltpkg/security-archive": "1.3.4",
32
- "@vltpkg/spec": "1.3.4",
33
- "@vltpkg/types": "1.3.4",
34
- "@vltpkg/vlt-json": "1.3.4",
35
- "@vltpkg/workspaces": "1.3.4",
16
+ "@vltpkg/cmd-shim": "1.3.5",
17
+ "@vltpkg/dep-id": "1.3.5",
18
+ "@vltpkg/dss-breadcrumb": "1.3.5",
19
+ "@vltpkg/error-cause": "1.3.5",
20
+ "@vltpkg/fast-split": "1.3.5",
21
+ "@vltpkg/graph-run": "1.3.5",
22
+ "@vltpkg/init": "1.3.5",
23
+ "@vltpkg/output": "1.3.5",
24
+ "@vltpkg/package-info": "1.3.5",
25
+ "@vltpkg/package-json": "1.3.5",
26
+ "@vltpkg/pick-manifest": "1.3.5",
27
+ "@vltpkg/query": "1.3.5",
28
+ "@vltpkg/rollback-remove": "1.3.5",
29
+ "@vltpkg/run": "1.3.5",
30
+ "@vltpkg/satisfies": "1.3.5",
31
+ "@vltpkg/security-archive": "1.3.5",
32
+ "@vltpkg/spec": "1.3.5",
33
+ "@vltpkg/types": "1.3.5",
34
+ "@vltpkg/vlt-json": "1.3.5",
35
+ "@vltpkg/workspaces": "1.3.5",
36
36
  "path-scurry": "^2.0.1",
37
37
  "promise-call-limit": "^3.0.2"
38
38
  },