@atlaspack/query 2.14.5-dev.55 → 2.14.5-dev.69

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaspack/query
2
2
 
3
+ ## 2.14.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`1b52b99`](https://github.com/atlassian-labs/atlaspack/commit/1b52b99db4298b04c1a6eb0f97994d75a2d436f9)]:
8
+ - @atlaspack/graph@3.5.0
9
+ - @atlaspack/core@2.18.1
10
+
11
+ ## 2.14.10
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196), [`0b2f6f5`](https://github.com/atlassian-labs/atlaspack/commit/0b2f6f55794d3ff6e2f5a41f963e7e5dd8ad9f8d), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
16
+ - @atlaspack/core@2.18.0
17
+ - @atlaspack/cache@3.2.5
18
+
3
19
  ## 2.14.9
4
20
 
5
21
  ### Patch Changes
package/lib/bin.js CHANGED
@@ -1,9 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- if (process.env.ATLASPACK_BUILD_ENV !== 'production' || process.env.ATLASPACK_SELF_BUILD) {
5
- require('@atlaspack/babel-register');
6
- }
7
4
  const run = require('./cli').run;
8
5
  require('v8-compile-cache');
9
6
  run(process.argv.slice(2));
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  /* eslint-disable monorepo/no-internal-import */
4
- const v = process.env.ATLASPACK_BUILD_ENV === 'production' ? {
4
+ const v = {
5
5
  // Split up require specifier to outsmart packages/dev/babel-register/babel-plugin-module-translate.js
6
6
  // $FlowFixMe(unsupported-syntax)
7
7
  AssetGraph: require('@atlaspack/core' + '/lib/AssetGraph').default,
@@ -15,12 +15,5 @@ const v = process.env.ATLASPACK_BUILD_ENV === 'production' ? {
15
15
  Priority: require('@atlaspack/core' + '/lib/types').Priority,
16
16
  // $FlowFixMe(unsupported-syntax)
17
17
  fromProjectPathRelative: require('@atlaspack/core' + '/lib/projectPath').fromProjectPathRelative
18
- } : {
19
- AssetGraph: require('@atlaspack/core/src/AssetGraph').default,
20
- BundleGraph: require('@atlaspack/core/src/BundleGraph'),
21
- RequestTracker: require('@atlaspack/core/src/RequestTracker'),
22
- LMDBLiteCache: require('@atlaspack/cache/src/LMDBLiteCache').LMDBLiteCache,
23
- Priority: require('@atlaspack/core/src/types').Priority,
24
- fromProjectPathRelative: require('@atlaspack/core/src/projectPath').fromProjectPathRelative
25
18
  };
26
19
  module.exports = v;
package/lib/index.js CHANGED
@@ -4,20 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.loadGraphs = loadGraphs;
7
- function _fs() {
8
- const data = _interopRequireDefault(require("fs"));
9
- _fs = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _path() {
15
- const data = _interopRequireDefault(require("path"));
16
- _path = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
7
  function _v() {
22
8
  const data = _interopRequireDefault(require("v8"));
23
9
  _v = function () {
@@ -54,53 +40,48 @@ const {
54
40
  LMDBLiteCache
55
41
  } = require('./deep-imports.js');
56
42
  async function loadGraphs(cacheDir) {
57
- function getMostRecentCacheBlobs() {
58
- let files = _fs().default.readdirSync(cacheDir);
59
- let result = {};
60
- let blobsToFind = [{
61
- name: 'requestGraphBlob',
62
- check: basename => basename.startsWith('requestGraph-') && !basename.startsWith('requestGraph-nodes')
63
- }, {
64
- name: 'bundleGraphBlob',
65
- check: basename => basename.endsWith('BundleGraph-0')
66
- }, {
67
- name: 'assetGraphBlob',
68
- check: basename => basename.endsWith('AssetGraph-0')
69
- }];
70
- for (let file of files) {
71
- let basename = _path().default.basename(file);
72
- let match = blobsToFind.find(({
73
- check
74
- }) => check(basename));
75
- if (match) {
76
- let stat = _fs().default.statSync(_path().default.join(cacheDir, file));
77
- if (!match.mtime || stat.mtime > match.mtime) {
78
- match.mtime = stat.mtime;
79
- result[match.name] = file;
80
- }
81
- }
43
+ let cacheInfo = new Map();
44
+ const cache = new LMDBLiteCache(cacheDir);
45
+ let requestGraphBlob;
46
+ let requestGraphKey;
47
+ let bundleGraphBlob;
48
+ let assetGraphBlob;
49
+ for (let key of cache.keys()) {
50
+ if (key.startsWith('Asset/')) {
51
+ continue;
52
+ } else if (key.startsWith('PackagerRunner/')) {
53
+ continue;
54
+ }
55
+ if (key.startsWith('RequestTracker/') && key.endsWith('/RequestGraph')) {
56
+ requestGraphBlob = key;
57
+ requestGraphKey = key.split('/').slice(0, -1).join('/');
58
+ }
59
+ if (key.startsWith('BundleGraph/')) {
60
+ bundleGraphBlob = key;
61
+ }
62
+ if (key.startsWith('AssetGraph/')) {
63
+ assetGraphBlob = key;
82
64
  }
83
- return result;
84
65
  }
85
- let cacheInfo = new Map();
86
- let {
66
+ console.log({
87
67
  requestGraphBlob,
88
68
  bundleGraphBlob,
89
69
  assetGraphBlob
90
- } = getMostRecentCacheBlobs();
91
- const cache = new LMDBLiteCache(cacheDir);
70
+ });
92
71
 
93
72
  // Get requestTracker
94
73
  let requestTracker;
95
- if (requestGraphBlob) {
74
+ if (requestGraphBlob != null && requestGraphKey != null) {
96
75
  try {
97
76
  var _cacheInfo$get;
98
- let requestGraphKey = requestGraphBlob.slice(0, -'-0'.length);
99
77
  let date = Date.now();
78
+ const buffer = await cache.getBlob(requestGraphBlob);
79
+ const deserializer = new (_v().default.Deserializer)(buffer);
80
+ console.log('Wire format version stored', deserializer.getWireFormatVersion());
100
81
  let {
101
82
  requestGraph,
102
83
  bufferLength
103
- } = await readAndDeserializeRequestGraph(cache, requestGraphKey, requestGraphKey.replace('requestGraph-', ''));
84
+ } = await readAndDeserializeRequestGraph(cache, requestGraphBlob, requestGraphKey);
104
85
  requestTracker = new RequestTracker({
105
86
  graph: requestGraph,
106
87
  // $FlowFixMe
@@ -112,16 +93,16 @@ async function loadGraphs(cacheDir) {
112
93
  cacheInfo.set('RequestGraph', [bufferLength]);
113
94
  (_cacheInfo$get = cacheInfo.get('RequestGraph')) === null || _cacheInfo$get === void 0 || _cacheInfo$get.push(timeToDeserialize);
114
95
  } catch (e) {
115
- console.log('Error loading Request Graph\n', e);
96
+ console.error('Error loading Request Graph\n', e);
116
97
  }
117
98
  }
118
99
 
119
100
  // Get bundleGraph
120
101
  let bundleGraph;
121
- if (bundleGraphBlob) {
102
+ if (bundleGraphBlob != null) {
122
103
  try {
123
104
  var _cacheInfo$get2;
124
- let file = await cache.getLargeBlob(_path().default.basename(bundleGraphBlob).slice(0, -'-0'.length));
105
+ let file = await cache.getBlob(bundleGraphBlob);
125
106
  let timeToDeserialize = Date.now();
126
107
  let obj = _v().default.deserialize(file);
127
108
  (0, _assert().default)(obj.bundleGraph != null);
@@ -130,17 +111,17 @@ async function loadGraphs(cacheDir) {
130
111
  cacheInfo.set('BundleGraph', [Buffer.byteLength(file)]);
131
112
  (_cacheInfo$get2 = cacheInfo.get('BundleGraph')) === null || _cacheInfo$get2 === void 0 || _cacheInfo$get2.push(timeToDeserialize);
132
113
  } catch (e) {
133
- console.log('Error loading Bundle Graph\n', e);
114
+ console.error('Error loading Bundle Graph\n', e);
134
115
  }
135
116
  }
136
117
 
137
118
  // Get assetGraph
138
119
  let assetGraph;
139
- if (assetGraphBlob) {
120
+ if (assetGraphBlob != null) {
140
121
  try {
141
122
  var _cacheInfo$get3;
142
123
  // TODO: this should be reviewed when `cachePerformanceImprovements` flag is removed, as we'll be writing files to LMDB cache instead of large blobs
143
- let file = await cache.getLargeBlob(_path().default.basename(assetGraphBlob).slice(0, -'-0'.length));
124
+ let file = await cache.getBlob(assetGraphBlob);
144
125
  let timeToDeserialize = Date.now();
145
126
  let obj = _v().default.deserialize(file);
146
127
  (0, _assert().default)(obj.assetGraph != null);
@@ -149,7 +130,7 @@ async function loadGraphs(cacheDir) {
149
130
  cacheInfo.set('AssetGraph', [Buffer.byteLength(file)]);
150
131
  (_cacheInfo$get3 = cacheInfo.get('AssetGraph')) === null || _cacheInfo$get3 === void 0 || _cacheInfo$get3.push(timeToDeserialize);
151
132
  } catch (e) {
152
- console.log('Error loading Asset Graph\n', e);
133
+ console.error('Error loading Asset Graph\n', e);
153
134
  }
154
135
  }
155
136
  function getSubRequests(id) {
@@ -171,7 +152,7 @@ async function loadGraphs(cacheDir) {
171
152
  bundleInfo = (0, _nullthrows().default)(writeBundlesRequest.result);
172
153
  }
173
154
  } catch (e) {
174
- console.log('Error loading bundleInfo\n', e);
155
+ console.error('Error loading bundleInfo\n', e);
175
156
  }
176
157
  return {
177
158
  assetGraph,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/query",
3
- "version": "2.14.5-dev.55+5a11f33c5",
3
+ "version": "2.14.5-dev.69+67cb517ae",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,9 +18,9 @@
18
18
  },
19
19
  "main": "src/index.js",
20
20
  "dependencies": {
21
- "@atlaspack/cache": "3.1.1-dev.55+5a11f33c5",
22
- "@atlaspack/core": "2.16.2-dev.55+5a11f33c5",
23
- "@atlaspack/graph": "3.4.1-dev.123+5a11f33c5",
21
+ "@atlaspack/cache": "3.1.1-dev.69+67cb517ae",
22
+ "@atlaspack/core": "2.16.2-dev.69+67cb517ae",
23
+ "@atlaspack/graph": "3.4.1-dev.137+67cb517ae",
24
24
  "nullthrows": "^1.1.1",
25
25
  "table": "^6.8.1",
26
26
  "v8-compile-cache": "^2.0.0"
@@ -31,5 +31,5 @@
31
31
  "rimraf": "^5.0.5"
32
32
  },
33
33
  "type": "commonjs",
34
- "gitHead": "5a11f33c51ff74d1cf8d4b72cfa0fda833aa980a"
34
+ "gitHead": "67cb517ae793046fb5a0d2ef02ba74510fefccf3"
35
35
  }
package/src/index.js CHANGED
@@ -3,8 +3,6 @@
3
3
  import type {ContentKey, NodeId} from '@atlaspack/graph';
4
4
  import type {PackagedBundleInfo} from '@atlaspack/core/src/types';
5
5
 
6
- import fs from 'fs';
7
- import path from 'path';
8
6
  import v8 from 'v8';
9
7
  import nullthrows from 'nullthrows';
10
8
  import invariant from 'assert';
@@ -27,65 +25,51 @@ export async function loadGraphs(cacheDir: string): Promise<{|
27
25
  bundleInfo: ?Map<ContentKey, PackagedBundleInfo>,
28
26
  cacheInfo: ?Map<string, Array<string | number>>,
29
27
  |}> {
30
- function getMostRecentCacheBlobs() {
31
- let files = fs.readdirSync(cacheDir);
32
-
33
- let result = {};
34
-
35
- let blobsToFind: Array<{|
36
- name: string,
37
- check: (v: string) => boolean,
38
- mtime?: Date,
39
- |}> = [
40
- {
41
- name: 'requestGraphBlob',
42
- check: (basename) =>
43
- basename.startsWith('requestGraph-') &&
44
- !basename.startsWith('requestGraph-nodes'),
45
- },
46
- {
47
- name: 'bundleGraphBlob',
48
- check: (basename) => basename.endsWith('BundleGraph-0'),
49
- },
50
- {
51
- name: 'assetGraphBlob',
52
- check: (basename) => basename.endsWith('AssetGraph-0'),
53
- },
54
- ];
55
-
56
- for (let file of files) {
57
- let basename = path.basename(file);
58
- let match = blobsToFind.find(({check}) => check(basename));
59
-
60
- if (match) {
61
- let stat = fs.statSync(path.join(cacheDir, file));
62
-
63
- if (!match.mtime || stat.mtime > match.mtime) {
64
- match.mtime = stat.mtime;
65
- result[match.name] = file;
66
- }
67
- }
28
+ let cacheInfo: Map<string, Array<string | number>> = new Map();
29
+ const cache = new LMDBLiteCache(cacheDir);
30
+
31
+ let requestGraphBlob;
32
+ let requestGraphKey;
33
+ let bundleGraphBlob;
34
+ let assetGraphBlob;
35
+ for (let key of cache.keys()) {
36
+ if (key.startsWith('Asset/')) {
37
+ continue;
38
+ } else if (key.startsWith('PackagerRunner/')) {
39
+ continue;
68
40
  }
69
41
 
70
- return result;
42
+ if (key.startsWith('RequestTracker/') && key.endsWith('/RequestGraph')) {
43
+ requestGraphBlob = key;
44
+ requestGraphKey = key.split('/').slice(0, -1).join('/');
45
+ }
46
+ if (key.startsWith('BundleGraph/')) {
47
+ bundleGraphBlob = key;
48
+ }
49
+ if (key.startsWith('AssetGraph/')) {
50
+ assetGraphBlob = key;
51
+ }
71
52
  }
72
53
 
73
- let cacheInfo: Map<string, Array<string | number>> = new Map();
74
-
75
- let {requestGraphBlob, bundleGraphBlob, assetGraphBlob} =
76
- getMostRecentCacheBlobs();
77
- const cache = new LMDBLiteCache(cacheDir);
54
+ console.log({requestGraphBlob, bundleGraphBlob, assetGraphBlob});
78
55
 
79
56
  // Get requestTracker
80
57
  let requestTracker;
81
- if (requestGraphBlob) {
58
+ if (requestGraphBlob != null && requestGraphKey != null) {
82
59
  try {
83
- let requestGraphKey = requestGraphBlob.slice(0, -'-0'.length);
84
60
  let date = Date.now();
61
+
62
+ const buffer = await cache.getBlob(requestGraphBlob);
63
+ const deserializer = new v8.Deserializer(buffer);
64
+ console.log(
65
+ 'Wire format version stored',
66
+ deserializer.getWireFormatVersion(),
67
+ );
68
+
85
69
  let {requestGraph, bufferLength} = await readAndDeserializeRequestGraph(
86
70
  cache,
71
+ requestGraphBlob,
87
72
  requestGraphKey,
88
- requestGraphKey.replace('requestGraph-', ''),
89
73
  );
90
74
 
91
75
  requestTracker = new RequestTracker({
@@ -99,17 +83,15 @@ export async function loadGraphs(cacheDir: string): Promise<{|
99
83
  cacheInfo.set('RequestGraph', [bufferLength]);
100
84
  cacheInfo.get('RequestGraph')?.push(timeToDeserialize);
101
85
  } catch (e) {
102
- console.log('Error loading Request Graph\n', e);
86
+ console.error('Error loading Request Graph\n', e);
103
87
  }
104
88
  }
105
89
 
106
90
  // Get bundleGraph
107
91
  let bundleGraph;
108
- if (bundleGraphBlob) {
92
+ if (bundleGraphBlob != null) {
109
93
  try {
110
- let file = await cache.getLargeBlob(
111
- path.basename(bundleGraphBlob).slice(0, -'-0'.length),
112
- );
94
+ let file = await cache.getBlob(bundleGraphBlob);
113
95
 
114
96
  let timeToDeserialize = Date.now();
115
97
  let obj = v8.deserialize(file);
@@ -120,18 +102,16 @@ export async function loadGraphs(cacheDir: string): Promise<{|
120
102
  cacheInfo.set('BundleGraph', [Buffer.byteLength(file)]);
121
103
  cacheInfo.get('BundleGraph')?.push(timeToDeserialize);
122
104
  } catch (e) {
123
- console.log('Error loading Bundle Graph\n', e);
105
+ console.error('Error loading Bundle Graph\n', e);
124
106
  }
125
107
  }
126
108
 
127
109
  // Get assetGraph
128
110
  let assetGraph;
129
- if (assetGraphBlob) {
111
+ if (assetGraphBlob != null) {
130
112
  try {
131
113
  // TODO: this should be reviewed when `cachePerformanceImprovements` flag is removed, as we'll be writing files to LMDB cache instead of large blobs
132
- let file = await cache.getLargeBlob(
133
- path.basename(assetGraphBlob).slice(0, -'-0'.length),
134
- );
114
+ let file = await cache.getBlob(assetGraphBlob);
135
115
 
136
116
  let timeToDeserialize = Date.now();
137
117
  let obj = v8.deserialize(file);
@@ -142,7 +122,7 @@ export async function loadGraphs(cacheDir: string): Promise<{|
142
122
  cacheInfo.set('AssetGraph', [Buffer.byteLength(file)]);
143
123
  cacheInfo.get('AssetGraph')?.push(timeToDeserialize);
144
124
  } catch (e) {
145
- console.log('Error loading Asset Graph\n', e);
125
+ console.error('Error loading Asset Graph\n', e);
146
126
  }
147
127
  }
148
128
 
@@ -179,7 +159,7 @@ export async function loadGraphs(cacheDir: string): Promise<{|
179
159
  >);
180
160
  }
181
161
  } catch (e) {
182
- console.log('Error loading bundleInfo\n', e);
162
+ console.error('Error loading bundleInfo\n', e);
183
163
  }
184
164
 
185
165
  return {assetGraph, bundleGraph, requestTracker, bundleInfo, cacheInfo};