@atlaspack/core 2.12.1-canary.3490 → 2.12.1-canary.3492

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/lib/Atlaspack.js CHANGED
@@ -94,6 +94,13 @@ function _rust() {
94
94
  return data;
95
95
  }
96
96
  var _projectPath = require("./projectPath");
97
+ function _cache() {
98
+ const data = require("@atlaspack/cache");
99
+ _cache = function () {
100
+ return data;
101
+ };
102
+ return data;
103
+ }
97
104
  function _profiler() {
98
105
  const data = require("@atlaspack/profiler");
99
106
  _profiler = function () {
@@ -109,6 +116,8 @@ function _featureFlags() {
109
116
  return data;
110
117
  }
111
118
  var _atlaspackV = require("./atlaspack-v3");
119
+ var _AssetGraphRequest = _interopRequireDefault(require("./requests/AssetGraphRequest"));
120
+ var _AssetGraphRequestRust = require("./requests/AssetGraphRequestRust");
112
121
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
113
122
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
114
123
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -123,7 +132,6 @@ class Atlaspack {
123
132
  #initialized /*: boolean*/ = false;
124
133
  #disposable /*: Disposable */;
125
134
  #initialOptions /*: InitialAtlaspackOptions */;
126
- #atlaspackV3;
127
135
  #reporterRunner /*: ReporterRunner*/;
128
136
  #resolvedOptions /*: ?AtlaspackOptions*/ = null;
129
137
  #optionsRef /*: SharedReference */;
@@ -181,6 +189,11 @@ class Atlaspack {
181
189
  outputFS,
182
190
  ...options
183
191
  } = this.#initialOptions;
192
+ const lmdb = resolvedOptions.cache instanceof _cache().LMDBLiteCache ? resolvedOptions.cache.getNativeRef() : null;
193
+
194
+ // $FlowFixMe
195
+ const version = require('../package.json').version;
196
+ await (lmdb === null || lmdb === void 0 ? void 0 : lmdb.put('current_session_version', Buffer.from(version)));
184
197
  rustAtlaspack = new _atlaspackV.AtlaspackV3({
185
198
  ...options,
186
199
  corePath: _path().default.join(__dirname, '..'),
@@ -197,9 +210,11 @@ class Atlaspack {
197
210
  sourceMaps: resolvedOptions.defaultTargetOptions.sourceMaps,
198
211
  shouldOptimize: resolvedOptions.defaultTargetOptions.shouldOptimize,
199
212
  shouldScopeHoist: resolvedOptions.defaultTargetOptions.shouldScopeHoist
200
- }
213
+ },
214
+ lmdb: lmdb ?? null
201
215
  });
202
216
  }
217
+ this.rustAtlaspack = rustAtlaspack;
203
218
  let {
204
219
  config
205
220
  } = await (0, _AtlaspackConfigRequest.loadAtlaspackConfig)(resolvedOptions);
@@ -530,6 +545,30 @@ class Atlaspack {
530
545
  async unstable_invalidate() {
531
546
  await this._init();
532
547
  }
548
+
549
+ /**
550
+ * Build the asset graph
551
+ */
552
+ async unstable_buildAssetGraph() {
553
+ await this._init();
554
+ const input = {
555
+ optionsRef: this.#optionsRef,
556
+ name: 'Main',
557
+ entries: this.#config.options.entries,
558
+ shouldBuildLazily: false,
559
+ lazyIncludes: [],
560
+ lazyExcludes: [],
561
+ requestedAssetIds: this.#requestedAssetIds
562
+ };
563
+ await this.#requestTracker.runRequest(this.rustAtlaspack != null ? (0, _AssetGraphRequestRust.createAssetGraphRequestRust)(this.rustAtlaspack)(input) : (0, _AssetGraphRequest.default)(input));
564
+ // eslint-disable-next-line no-console
565
+ console.log('Done building asset graph!');
566
+ // eslint-disable-next-line no-console
567
+ console.log('Write request tracker to cache');
568
+ await this.writeRequestTrackerToCache();
569
+ // eslint-disable-next-line no-console
570
+ console.log('Done writing request tracker to cache');
571
+ }
533
572
  async unstable_transform(options) {
534
573
  var _options$env;
535
574
  if (!this.#initialized) {
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AtlaspackV3 = void 0;
7
- var _WorkerPool = require("./WorkerPool");
8
7
  function _rust() {
9
8
  const data = require("@atlaspack/rust");
10
9
  _rust = function () {
@@ -12,12 +11,14 @@ function _rust() {
12
11
  };
13
12
  return data;
14
13
  }
14
+ var _WorkerPool = require("./WorkerPool");
15
15
  class AtlaspackV3 {
16
16
  constructor({
17
17
  fs,
18
18
  nodeWorkers,
19
19
  packageManager,
20
20
  threads,
21
+ lmdb,
21
22
  ...options
22
23
  }) {
23
24
  options.logLevel = options.logLevel || 'error';
@@ -26,13 +27,13 @@ class AtlaspackV3 {
26
27
  options.defaultTargetOptions.engines = options.defaultTargetOptions.engines || {
27
28
  browsers: []
28
29
  };
29
- this._internal = new (_rust().AtlaspackNapi)({
30
+ this._internal = _rust().AtlaspackNapi.create({
30
31
  fs,
31
32
  nodeWorkers,
32
33
  packageManager,
33
34
  threads,
34
35
  options
35
- });
36
+ }, lmdb);
36
37
  }
37
38
  async buildAssetGraph() {
38
39
  const workerIds = [];
@@ -42,11 +42,6 @@ function createAssetRequest(input) {
42
42
  }
43
43
  const type = 'asset_request';
44
44
  function getId(input) {
45
- // eslint-disable-next-line no-unused-vars
46
- let {
47
- optionsRef,
48
- ...hashInput
49
- } = input;
50
45
  return (0, _rust().hashString)(type + (0, _projectPath.fromProjectPathRelative)(input.filePath) + input.env.id + String(input.isSource) + String(input.sideEffects) + (input.code ?? '') + ':' + (input.pipeline ?? '') + ':' + (input.query ?? ''));
51
46
  }
52
47
  async function run({
@@ -111,12 +111,13 @@ async function resolveOptions(initialOptions) {
111
111
  // where symlinked dependencies outside the project root need to trigger HMR
112
112
  // updates. Default to the project root if not provided.
113
113
  let watchDir = initialOptions.watchDir != null ? _path().default.resolve(initialOptions.watchDir) : projectRoot;
114
- let cache = initialOptions.cache ?? (outputFS instanceof _fs().NodeFS ? (() => {
115
- if ((0, _featureFlags().getFeatureFlag)('useLmdbJsLite')) {
114
+ const needsRustLmdbCache = (0, _featureFlags().getFeatureFlag)('useLmdbJsLite') || (0, _featureFlags().getFeatureFlag)('atlaspackV3');
115
+ let cache = outputFS instanceof _fs().NodeFS ? (() => {
116
+ if (needsRustLmdbCache) {
116
117
  return new (_cache().LMDBLiteCache)(cacheDir);
117
118
  }
118
119
  return new (_cache().LMDBCache)(cacheDir);
119
- })() : new (_cache().FSCache)(outputFS, cacheDir));
120
+ })() : new (_cache().FSCache)(outputFS, cacheDir);
120
121
  let mode = initialOptions.mode ?? 'development';
121
122
  let shouldOptimize = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau = initialOptions.defaultTargetOptions) === null || _initialOptions$defau === void 0 ? void 0 : _initialOptions$defau.shouldOptimize) ?? mode === 'production';
122
123
  let publicUrl = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau2 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau2 === void 0 ? void 0 : _initialOptions$defau2.publicUrl) ?? '/';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.12.1-canary.3490+e250bc9ff",
3
+ "version": "2.12.1-canary.3492+4df4fe4cb",
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.3490+e250bc9ff",
24
- "@atlaspack/cache": "2.12.1-canary.3490+e250bc9ff",
25
- "@atlaspack/diagnostic": "2.12.1-canary.3490+e250bc9ff",
26
- "@atlaspack/events": "2.12.1-canary.3490+e250bc9ff",
27
- "@atlaspack/feature-flags": "2.12.1-canary.3490+e250bc9ff",
28
- "@atlaspack/fs": "2.12.1-canary.3490+e250bc9ff",
29
- "@atlaspack/graph": "3.2.1-canary.3490+e250bc9ff",
30
- "@atlaspack/logger": "2.12.1-canary.3490+e250bc9ff",
31
- "@atlaspack/package-manager": "2.12.1-canary.3490+e250bc9ff",
32
- "@atlaspack/plugin": "2.12.1-canary.3490+e250bc9ff",
33
- "@atlaspack/profiler": "2.12.1-canary.3490+e250bc9ff",
34
- "@atlaspack/rust": "2.12.1-canary.3490+e250bc9ff",
35
- "@atlaspack/types": "2.12.1-canary.3490+e250bc9ff",
36
- "@atlaspack/utils": "2.12.1-canary.3490+e250bc9ff",
37
- "@atlaspack/workers": "2.12.1-canary.3490+e250bc9ff",
23
+ "@atlaspack/build-cache": "2.12.1-canary.3492+4df4fe4cb",
24
+ "@atlaspack/cache": "2.12.1-canary.3492+4df4fe4cb",
25
+ "@atlaspack/diagnostic": "2.12.1-canary.3492+4df4fe4cb",
26
+ "@atlaspack/events": "2.12.1-canary.3492+4df4fe4cb",
27
+ "@atlaspack/feature-flags": "2.12.1-canary.3492+4df4fe4cb",
28
+ "@atlaspack/fs": "2.12.1-canary.3492+4df4fe4cb",
29
+ "@atlaspack/graph": "3.2.1-canary.3492+4df4fe4cb",
30
+ "@atlaspack/logger": "2.12.1-canary.3492+4df4fe4cb",
31
+ "@atlaspack/package-manager": "2.12.1-canary.3492+4df4fe4cb",
32
+ "@atlaspack/plugin": "2.12.1-canary.3492+4df4fe4cb",
33
+ "@atlaspack/profiler": "2.12.1-canary.3492+4df4fe4cb",
34
+ "@atlaspack/rust": "2.12.1-canary.3492+4df4fe4cb",
35
+ "@atlaspack/types": "2.12.1-canary.3492+4df4fe4cb",
36
+ "@atlaspack/utils": "2.12.1-canary.3492+4df4fe4cb",
37
+ "@atlaspack/workers": "2.12.1-canary.3492+4df4fe4cb",
38
38
  "@mischnic/json-sourcemap": "^0.1.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
@@ -65,5 +65,5 @@
65
65
  "browser": {
66
66
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
67
67
  },
68
- "gitHead": "e250bc9ffea331f02e6e3ba9ccdd52f8bf9f396c"
68
+ "gitHead": "4df4fe4cb9dd65932316b439ba69c76ca50bd56e"
69
69
  }
package/src/Atlaspack.js CHANGED
@@ -55,9 +55,12 @@ import {
55
55
  toProjectPath,
56
56
  fromProjectPathRelative,
57
57
  } from './projectPath';
58
+ import {LMDBLiteCache} from '@atlaspack/cache';
58
59
  import {tracer} from '@atlaspack/profiler';
59
60
  import {setFeatureFlags, DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
60
61
  import {AtlaspackV3, FileSystemV3} from './atlaspack-v3';
62
+ import createAssetGraphRequestJS from './requests/AssetGraphRequest';
63
+ import {createAssetGraphRequestRust} from './requests/AssetGraphRequestRust';
61
64
 
62
65
  registerCoreWithSerializer();
63
66
 
@@ -71,7 +74,6 @@ export default class Atlaspack {
71
74
  #initialized /*: boolean*/ = false;
72
75
  #disposable /*: Disposable */;
73
76
  #initialOptions /*: InitialAtlaspackOptions */;
74
- #atlaspackV3: AtlaspackV3;
75
77
  #reporterRunner /*: ReporterRunner*/;
76
78
  #resolvedOptions /*: ?AtlaspackOptions*/ = null;
77
79
  #optionsRef /*: SharedReference */;
@@ -93,6 +95,8 @@ export default class Atlaspack {
93
95
  #watcherCount /*: number*/ = 0;
94
96
  #requestedAssetIds /*: Set<string>*/ = new Set();
95
97
 
98
+ rustAtlaspack: AtlaspackV3 | null | void;
99
+
96
100
  isProfiling /*: boolean */;
97
101
 
98
102
  constructor(options: InitialAtlaspackOptions) {
@@ -133,6 +137,15 @@ export default class Atlaspack {
133
137
  // eslint-disable-next-line no-unused-vars
134
138
  let {entries, inputFS, outputFS, ...options} = this.#initialOptions;
135
139
 
140
+ const lmdb =
141
+ resolvedOptions.cache instanceof LMDBLiteCache
142
+ ? resolvedOptions.cache.getNativeRef()
143
+ : null;
144
+
145
+ // $FlowFixMe
146
+ const version = require('../package.json').version;
147
+ await lmdb?.put('current_session_version', Buffer.from(version));
148
+
136
149
  rustAtlaspack = new AtlaspackV3({
137
150
  ...options,
138
151
  corePath: path.join(__dirname, '..'),
@@ -155,8 +168,10 @@ export default class Atlaspack {
155
168
  shouldScopeHoist:
156
169
  resolvedOptions.defaultTargetOptions.shouldScopeHoist,
157
170
  },
171
+ lmdb: lmdb ?? null,
158
172
  });
159
173
  }
174
+ this.rustAtlaspack = rustAtlaspack;
160
175
 
161
176
  let {config} = await loadAtlaspackConfig(resolvedOptions);
162
177
  this.#config = new AtlaspackConfig(config, resolvedOptions);
@@ -552,6 +567,34 @@ export default class Atlaspack {
552
567
  await this._init();
553
568
  }
554
569
 
570
+ /**
571
+ * Build the asset graph
572
+ */
573
+ async unstable_buildAssetGraph(): Promise<void> {
574
+ await this._init();
575
+ const input = {
576
+ optionsRef: this.#optionsRef,
577
+ name: 'Main',
578
+ entries: this.#config.options.entries,
579
+ shouldBuildLazily: false,
580
+ lazyIncludes: [],
581
+ lazyExcludes: [],
582
+ requestedAssetIds: this.#requestedAssetIds,
583
+ };
584
+ await this.#requestTracker.runRequest(
585
+ this.rustAtlaspack != null
586
+ ? createAssetGraphRequestRust(this.rustAtlaspack)(input)
587
+ : createAssetGraphRequestJS(input),
588
+ );
589
+ // eslint-disable-next-line no-console
590
+ console.log('Done building asset graph!');
591
+ // eslint-disable-next-line no-console
592
+ console.log('Write request tracker to cache');
593
+ await this.writeRequestTrackerToCache();
594
+ // eslint-disable-next-line no-console
595
+ console.log('Done writing request tracker to cache');
596
+ }
597
+
555
598
  async unstable_transform(
556
599
  options: AtlaspackTransformOptions,
557
600
  ): Promise<Array<Asset>> {
@@ -1,13 +1,21 @@
1
1
  // @flow
2
2
 
3
+ import {
4
+ AtlaspackNapi,
5
+ type Lmdb,
6
+ type AtlaspackNapiOptions,
7
+ } from '@atlaspack/rust';
3
8
  import {workerPool} from './WorkerPool';
4
- import {AtlaspackNapi, type AtlaspackNapiOptions} from '@atlaspack/rust';
5
9
 
6
10
  export type AtlaspackV3Options = {|
7
11
  fs?: AtlaspackNapiOptions['fs'],
8
12
  nodeWorkers?: number,
9
13
  packageManager?: AtlaspackNapiOptions['packageManager'],
10
14
  threads?: number,
15
+ /**
16
+ * A reference to LMDB lite's rust object
17
+ */
18
+ lmdb: Lmdb | null,
11
19
  ...AtlaspackNapiOptions['options'],
12
20
  |};
13
21
 
@@ -19,6 +27,7 @@ export class AtlaspackV3 {
19
27
  nodeWorkers,
20
28
  packageManager,
21
29
  threads,
30
+ lmdb,
22
31
  ...options
23
32
  }: AtlaspackV3Options) {
24
33
  options.logLevel = options.logLevel || 'error';
@@ -29,13 +38,16 @@ export class AtlaspackV3 {
29
38
  browsers: [],
30
39
  };
31
40
 
32
- this._internal = new AtlaspackNapi({
33
- fs,
34
- nodeWorkers,
35
- packageManager,
36
- threads,
37
- options,
38
- });
41
+ this._internal = AtlaspackNapi.create(
42
+ {
43
+ fs,
44
+ nodeWorkers,
45
+ packageManager,
46
+ threads,
47
+ options,
48
+ },
49
+ lmdb,
50
+ );
39
51
  }
40
52
 
41
53
  async buildAssetGraph(): Promise<any> {
@@ -48,8 +48,6 @@ export default function createAssetRequest(
48
48
  const type = 'asset_request';
49
49
 
50
50
  function getId(input: AssetRequestInput) {
51
- // eslint-disable-next-line no-unused-vars
52
- let {optionsRef, ...hashInput} = input;
53
51
  return hashString(
54
52
  type +
55
53
  fromProjectPathRelative(input.filePath) +
@@ -109,18 +109,19 @@ export default async function resolveOptions(
109
109
  ? path.resolve(initialOptions.watchDir)
110
110
  : projectRoot;
111
111
 
112
+ const needsRustLmdbCache =
113
+ getFeatureFlag('useLmdbJsLite') || getFeatureFlag('atlaspackV3');
112
114
  const makeLMDBCache = () => {
113
- if (getFeatureFlag('useLmdbJsLite')) {
115
+ if (needsRustLmdbCache) {
114
116
  return new LMDBLiteCache(cacheDir);
115
117
  }
116
118
  return new LMDBCache(cacheDir);
117
119
  };
118
120
 
119
121
  let cache =
120
- initialOptions.cache ??
121
- (outputFS instanceof NodeFS
122
+ outputFS instanceof NodeFS
122
123
  ? makeLMDBCache()
123
- : new FSCache(outputFS, cacheDir));
124
+ : new FSCache(outputFS, cacheDir);
124
125
 
125
126
  let mode = initialOptions.mode ?? 'development';
126
127
  let shouldOptimize =