@atlaspack/core 2.14.1-dev.53 → 2.14.1-dev.82

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
@@ -118,6 +118,7 @@ function _featureFlags() {
118
118
  var _atlaspackV = require("./atlaspack-v3");
119
119
  var _AssetGraphRequest = _interopRequireDefault(require("./requests/AssetGraphRequest"));
120
120
  var _AssetGraphRequestRust = require("./requests/AssetGraphRequestRust");
121
+ var _rustWorkerThreadDylibHack = require("./rustWorkerThreadDylibHack");
121
122
  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); }
122
123
  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; }
123
124
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -165,6 +166,9 @@ class Atlaspack {
165
166
  ...this.#initialOptions.featureFlags
166
167
  };
167
168
  (0, _featureFlags().setFeatureFlags)(featureFlags);
169
+ if ((0, _featureFlags().getFeatureFlag)('enableRustWorkerThreadDylibHack')) {
170
+ (0, _rustWorkerThreadDylibHack.loadRustWorkerThreadDylibHack)();
171
+ }
168
172
  await _sourceMap().init;
169
173
  await (_rust().init === null || _rust().init === void 0 ? void 0 : (0, _rust().init)());
170
174
  this.#disposable = new (_events().Disposable)();
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  let fs = require('fs');
4
- let path = require('path');
5
4
  let {
6
5
  findAncestorFile
7
6
  } = require('@atlaspack/rust');
8
7
  let dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
9
- module.exports.isSuperPackage = () => {
8
+ function isSuperPackage() {
10
9
  if (!dirname) {
11
10
  return false;
12
11
  }
13
12
  let packageJson = JSON.parse(fs.readFileSync(findAncestorFile(['package.json'], dirname, '/')));
14
13
  return packageJson.name === '@atlaspack/super';
14
+ }
15
+ let result;
16
+ module.exports.isSuperPackage = () => {
17
+ if (result == null) {
18
+ result = isSuperPackage();
19
+ }
20
+ return result;
15
21
  };
@@ -262,12 +262,13 @@ class BundleGraph {
262
262
  ifFalseBundles.push(...depToBundles(cond.ifFalseDependency));
263
263
  }
264
264
  for (let bundle of bundles) {
265
- const conditions = bundleConditions.get(bundle) ?? new Map();
265
+ const conditions = bundleConditions.get(bundle.id) ?? new Map();
266
266
  conditions.set(cond.key, {
267
+ bundle,
267
268
  ifTrueBundles,
268
269
  ifFalseBundles
269
270
  });
270
- bundleConditions.set(bundle, conditions);
271
+ bundleConditions.set(bundle.id, conditions);
271
272
  }
272
273
  }
273
274
  return bundleConditions;
@@ -139,7 +139,8 @@ async function resolveOptions(initialOptions) {
139
139
  // where symlinked dependencies outside the project root need to trigger HMR
140
140
  // updates. Default to the project root if not provided.
141
141
  let watchDir = initialOptions.watchDir != null ? _path().default.resolve(initialOptions.watchDir) : projectRoot;
142
- let cache = outputFS instanceof _fs().NodeFS ? new (_cache().LMDBLiteCache)(cacheDir) : new (_cache().FSCache)(outputFS, cacheDir);
142
+ const needsRustLmdbCache = (0, _featureFlags().getFeatureFlag)('useLmdbJsLite') || (0, _featureFlags().getFeatureFlag)('atlaspackV3');
143
+ let cache = needsRustLmdbCache ? new (_cache().LMDBLiteCache)(cacheDir) : outputFS instanceof _fs().NodeFS ? new (_cache().LMDBCache)(cacheDir) : new (_cache().FSCache)(outputFS, cacheDir);
143
144
  let mode = initialOptions.mode ?? 'development';
144
145
  let shouldOptimize = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau = initialOptions.defaultTargetOptions) === null || _initialOptions$defau === void 0 ? void 0 : _initialOptions$defau.shouldOptimize) ?? mode === 'production';
145
146
  let publicUrl = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau2 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau2 === void 0 ? void 0 : _initialOptions$defau2.publicUrl) ?? '/';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.loadRustWorkerThreadDylibHack = loadRustWorkerThreadDylibHack;
7
+ /**
8
+ * This is a workaround for https://github.com/rust-lang/rust/issues/91979
9
+ * when running atlaspack with parcel bindings, it is possible that the parcel
10
+ * dylib will be loaded from a node worker thread, which causes a crash on exit.
11
+ *
12
+ * This is a workaround to ensure that the parcel dylib is loaded in the main
13
+ * thread, which fixes the crash.
14
+ */
15
+ function loadRustWorkerThreadDylibHack() {
16
+ try {
17
+ // $FlowFixMe
18
+ require('@parcel/rust'); // eslint-disable-line
19
+ } catch (err) {
20
+ /* ignore */
21
+ }
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.14.1-dev.53+75290c6cb",
3
+ "version": "2.14.1-dev.82+5e3ca3e0c",
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.13.3-dev.53+75290c6cb",
24
- "@atlaspack/cache": "2.13.3-dev.53+75290c6cb",
25
- "@atlaspack/diagnostic": "2.14.1-dev.53+75290c6cb",
26
- "@atlaspack/events": "2.14.1-dev.53+75290c6cb",
27
- "@atlaspack/feature-flags": "2.14.1-dev.53+75290c6cb",
28
- "@atlaspack/fs": "2.14.1-dev.53+75290c6cb",
29
- "@atlaspack/graph": "3.4.1-dev.53+75290c6cb",
30
- "@atlaspack/logger": "2.14.1-dev.53+75290c6cb",
31
- "@atlaspack/package-manager": "2.14.1-dev.53+75290c6cb",
32
- "@atlaspack/plugin": "2.14.1-dev.53+75290c6cb",
33
- "@atlaspack/profiler": "2.14.1-dev.53+75290c6cb",
34
- "@atlaspack/rust": "3.0.1-dev.53+75290c6cb",
35
- "@atlaspack/types": "2.14.1-dev.53+75290c6cb",
36
- "@atlaspack/utils": "2.14.1-dev.53+75290c6cb",
37
- "@atlaspack/workers": "2.14.1-dev.53+75290c6cb",
23
+ "@atlaspack/build-cache": "2.13.3-dev.82+5e3ca3e0c",
24
+ "@atlaspack/cache": "2.13.3-dev.82+5e3ca3e0c",
25
+ "@atlaspack/diagnostic": "2.14.1-dev.82+5e3ca3e0c",
26
+ "@atlaspack/events": "2.14.1-dev.82+5e3ca3e0c",
27
+ "@atlaspack/feature-flags": "2.14.1-dev.82+5e3ca3e0c",
28
+ "@atlaspack/fs": "2.14.1-dev.82+5e3ca3e0c",
29
+ "@atlaspack/graph": "3.4.1-dev.82+5e3ca3e0c",
30
+ "@atlaspack/logger": "2.14.1-dev.82+5e3ca3e0c",
31
+ "@atlaspack/package-manager": "2.14.1-dev.82+5e3ca3e0c",
32
+ "@atlaspack/plugin": "2.14.1-dev.82+5e3ca3e0c",
33
+ "@atlaspack/profiler": "2.14.1-dev.82+5e3ca3e0c",
34
+ "@atlaspack/rust": "3.0.1-dev.82+5e3ca3e0c",
35
+ "@atlaspack/types": "2.14.1-dev.82+5e3ca3e0c",
36
+ "@atlaspack/utils": "2.14.1-dev.82+5e3ca3e0c",
37
+ "@atlaspack/workers": "2.14.1-dev.82+5e3ca3e0c",
38
38
  "@mischnic/json-sourcemap": "^0.1.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
@@ -67,5 +67,5 @@
67
67
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
68
  },
69
69
  "type": "commonjs",
70
- "gitHead": "75290c6cb03e7253ab1f9bfc6859d518a7d313cc"
70
+ "gitHead": "5e3ca3e0cbbd49f4e67ac8d9b8aeebba1c3e76ef"
71
71
  }
package/src/Atlaspack.js CHANGED
@@ -58,11 +58,16 @@ import {
58
58
  fromProjectPathRelative,
59
59
  } from './projectPath';
60
60
  import {tracer} from '@atlaspack/profiler';
61
- import {setFeatureFlags, DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
61
+ import {
62
+ getFeatureFlag,
63
+ setFeatureFlags,
64
+ DEFAULT_FEATURE_FLAGS,
65
+ } from '@atlaspack/feature-flags';
62
66
  import {AtlaspackV3, FileSystemV3} from './atlaspack-v3';
63
67
  import createAssetGraphRequestJS from './requests/AssetGraphRequest';
64
68
  import {createAssetGraphRequestRust} from './requests/AssetGraphRequestRust';
65
69
  import type {AssetGraphRequestResult} from './requests/AssetGraphRequest';
70
+ import {loadRustWorkerThreadDylibHack} from './rustWorkerThreadDylibHack';
66
71
 
67
72
  registerCoreWithSerializer();
68
73
 
@@ -120,6 +125,10 @@ export default class Atlaspack {
120
125
  };
121
126
  setFeatureFlags(featureFlags);
122
127
 
128
+ if (getFeatureFlag('enableRustWorkerThreadDylibHack')) {
129
+ loadRustWorkerThreadDylibHack();
130
+ }
131
+
123
132
  await initSourcemaps;
124
133
  await initRust?.();
125
134
 
@@ -1,9 +1,9 @@
1
1
  let fs = require('fs');
2
- let path = require('path');
3
2
  let {findAncestorFile} = require('@atlaspack/rust');
3
+
4
4
  let dirname = /*#__ATLASPACK_IGNORE__*/ __dirname;
5
5
 
6
- module.exports.isSuperPackage = () => {
6
+ function isSuperPackage() {
7
7
  if (!dirname) {
8
8
  return false;
9
9
  }
@@ -13,4 +13,14 @@ module.exports.isSuperPackage = () => {
13
13
  );
14
14
 
15
15
  return packageJson.name === '@atlaspack/super';
16
+ }
17
+
18
+ let result;
19
+
20
+ module.exports.isSuperPackage = () => {
21
+ if (result == null) {
22
+ result = isSuperPackage();
23
+ }
24
+
25
+ return result;
16
26
  };
@@ -444,10 +444,11 @@ export default class BundleGraph<TBundle: IBundle>
444
444
  // be used by a webserver to understand which conditions are used by which bundles,
445
445
  // and which bundles those conditions require depending on what they evaluate to.
446
446
  getConditionalBundleMapping(): Map<
447
- TBundle,
447
+ string,
448
448
  Map<
449
449
  string,
450
450
  {|
451
+ bundle: TBundle,
451
452
  ifTrueBundles: Array<TBundle>,
452
453
  ifFalseBundles: Array<TBundle>,
453
454
  |},
@@ -486,14 +487,15 @@ export default class BundleGraph<TBundle: IBundle>
486
487
  }
487
488
 
488
489
  for (let bundle of bundles) {
489
- const conditions = bundleConditions.get(bundle) ?? new Map();
490
+ const conditions = bundleConditions.get(bundle.id) ?? new Map();
490
491
 
491
492
  conditions.set(cond.key, {
493
+ bundle,
492
494
  ifTrueBundles,
493
495
  ifFalseBundles,
494
496
  });
495
497
 
496
- bundleConditions.set(bundle, conditions);
498
+ bundleConditions.set(bundle.id, conditions);
497
499
  }
498
500
  }
499
501
 
@@ -12,7 +12,7 @@ import type {AtlaspackOptions} from './types';
12
12
  import path from 'path';
13
13
  import {hashString} from '@atlaspack/rust';
14
14
  import {NodeFS, NodeVCSAwareFS} from '@atlaspack/fs';
15
- import {LMDBLiteCache, FSCache} from '@atlaspack/cache';
15
+ import {LMDBCache, LMDBLiteCache, FSCache} from '@atlaspack/cache';
16
16
  import {getFeatureFlag, getFeatureFlagValue} from '@atlaspack/feature-flags';
17
17
  import {NodePackageManager} from '@atlaspack/package-manager';
18
18
  import {
@@ -146,10 +146,14 @@ export default async function resolveOptions(
146
146
  ? path.resolve(initialOptions.watchDir)
147
147
  : projectRoot;
148
148
 
149
- let cache =
150
- outputFS instanceof NodeFS
151
- ? new LMDBLiteCache(cacheDir)
152
- : new FSCache(outputFS, cacheDir);
149
+ const needsRustLmdbCache =
150
+ getFeatureFlag('useLmdbJsLite') || getFeatureFlag('atlaspackV3');
151
+
152
+ let cache = needsRustLmdbCache
153
+ ? new LMDBLiteCache(cacheDir)
154
+ : outputFS instanceof NodeFS
155
+ ? new LMDBCache(cacheDir)
156
+ : new FSCache(outputFS, cacheDir);
153
157
 
154
158
  let mode = initialOptions.mode ?? 'development';
155
159
  let shouldOptimize =
@@ -0,0 +1,18 @@
1
+ // @flow strict-local
2
+
3
+ /**
4
+ * This is a workaround for https://github.com/rust-lang/rust/issues/91979
5
+ * when running atlaspack with parcel bindings, it is possible that the parcel
6
+ * dylib will be loaded from a node worker thread, which causes a crash on exit.
7
+ *
8
+ * This is a workaround to ensure that the parcel dylib is loaded in the main
9
+ * thread, which fixes the crash.
10
+ */
11
+ export function loadRustWorkerThreadDylibHack() {
12
+ try {
13
+ // $FlowFixMe
14
+ require('@parcel/rust'); // eslint-disable-line
15
+ } catch (err) {
16
+ /* ignore */
17
+ }
18
+ }