@atlaspack/core 2.14.1-dev.43 → 2.14.1-dev.47

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,38 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#486](https://github.com/atlassian-labs/atlaspack/pull/486) [`87087f4`](https://github.com/atlassian-labs/atlaspack/commit/87087f44f348ac583a27ea0819122e191ba80f8d) Thanks [@yamadapc](https://github.com/yamadapc)! - Add environment variable to skip cache invalidation
8
+
9
+ ### Patch Changes
10
+
11
+ - [#450](https://github.com/atlassian-labs/atlaspack/pull/450) [`b9d41b1`](https://github.com/atlassian-labs/atlaspack/commit/b9d41b175ad5771651a5b0278a5a0147e669234a) Thanks [@benjervis](https://github.com/benjervis)! - Remove the Atlaspack engines compatibility check
12
+
13
+ - [#420](https://github.com/atlassian-labs/atlaspack/pull/420) [`e1422ad`](https://github.com/atlassian-labs/atlaspack/commit/e1422ad0a801faaa4bc4f1023bed042ffe236e9b) Thanks [@JakeLane](https://github.com/JakeLane)! - Support async script runtime in conditional bundling
14
+
15
+ - [#472](https://github.com/atlassian-labs/atlaspack/pull/472) [`7e357fb`](https://github.com/atlassian-labs/atlaspack/commit/7e357fb173e7958da330e3721667fa5749420952) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix segmentation fault on exit on certain cases
16
+
17
+ - [#478](https://github.com/atlassian-labs/atlaspack/pull/478) [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b) Thanks [@yamadapc](https://github.com/yamadapc)! - The first attempt at Version Packages didn't include the built artifacts.
18
+ This has hopefully been fixed, so this change will force those packages to re-release.
19
+ - Updated dependencies [[`80bd57b`](https://github.com/atlassian-labs/atlaspack/commit/80bd57b9f9e966563957dee0780d956a682eb2d4), [`ae70b81`](https://github.com/atlassian-labs/atlaspack/commit/ae70b810384cf58f9c57d341ab4c925c7bb2060c), [`ce13d5e`](https://github.com/atlassian-labs/atlaspack/commit/ce13d5e885d55518ee6318e7a72e3a6e4e5126f2), [`4aab060`](https://github.com/atlassian-labs/atlaspack/commit/4aab0605c0d4ee8e0dcc3ffa1162eae5b360b677), [`c0a61a9`](https://github.com/atlassian-labs/atlaspack/commit/c0a61a92405b6830fe39cc17622cc2e97bf02dd7), [`cb35e7d`](https://github.com/atlassian-labs/atlaspack/commit/cb35e7d2b90b372de8401792915f12f410508d24), [`e1422ad`](https://github.com/atlassian-labs/atlaspack/commit/e1422ad0a801faaa4bc4f1023bed042ffe236e9b), [`6ec11f1`](https://github.com/atlassian-labs/atlaspack/commit/6ec11f10a9366fb8a9fc0475c7678235056bd80e), [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b)]:
20
+ - @atlaspack/fs@2.14.1
21
+ - @atlaspack/rust@3.0.1
22
+ - @atlaspack/utils@2.14.1
23
+ - @atlaspack/feature-flags@2.14.1
24
+ - @atlaspack/diagnostic@2.14.1
25
+ - @atlaspack/graph@3.4.1
26
+ - @atlaspack/logger@2.14.1
27
+ - @atlaspack/package-manager@2.14.1
28
+ - @atlaspack/plugin@2.14.1
29
+ - @atlaspack/profiler@2.14.1
30
+ - @atlaspack/types@2.14.1
31
+ - @atlaspack/workers@2.14.1
32
+ - @atlaspack/events@2.14.1
33
+ - @atlaspack/build-cache@2.13.3
34
+ - @atlaspack/cache@2.13.3
35
+
3
36
  ## 2.14.0
4
37
 
5
38
  ### Minor Changes
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 }; }
@@ -125,7 +126,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
125
126
  (0, _registerCoreWithSerializer.registerCoreWithSerializer)();
126
127
  const INTERNAL_TRANSFORM = exports.INTERNAL_TRANSFORM = Symbol('internal_transform');
127
128
  const INTERNAL_RESOLVE = exports.INTERNAL_RESOLVE = Symbol('internal_resolve');
128
- const WORKER_PATH = exports.WORKER_PATH = _path().default.join( /*#__ATLASPACK_IGNORE__*/__dirname, 'worker.js');
129
+ const WORKER_PATH = exports.WORKER_PATH = _path().default.join(__dirname, 'worker.js');
129
130
  class Atlaspack {
130
131
  #requestTracker /*: RequestTracker*/;
131
132
  #config /*: AtlaspackConfig*/;
@@ -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)();
@@ -832,7 +832,7 @@ class BundleGraph {
832
832
  // If this asset is referenced by any async dependency, it's referenced.
833
833
  return true;
834
834
  }
835
- let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId, _graph().ALL_EDGE_TYPES).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
835
+ let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
836
836
  (0, _assert().default)(node.type === 'dependency');
837
837
  return node.value;
838
838
  });
@@ -1100,7 +1100,7 @@ async function loadRequestGraph(options) {
1100
1100
  });
1101
1101
  }, 5000);
1102
1102
  let startTime = Date.now();
1103
- let events = await options.inputFS.getEventsSince(options.watchDir, snapshotPath, opts);
1103
+ let events = process.env.ATLASPACK_BYPASS_CACHE_INVALIDATION === 'true' ? [] : await options.inputFS.getEventsSince(options.watchDir, snapshotPath, opts);
1104
1104
  clearTimeout(timeout);
1105
1105
  _logger().default.verbose({
1106
1106
  origin: '@atlaspack/core',
@@ -25,8 +25,6 @@ function _diagnostic() {
25
25
  };
26
26
  return data;
27
27
  }
28
- var _package = require("../package.json");
29
- var _internalPlugins = _interopRequireDefault(require("./internal-plugins"));
30
28
  function _utils() {
31
29
  const data = require("@atlaspack/utils");
32
30
  _utils = function () {
@@ -41,18 +39,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
41
39
  const NODE_MODULES = `${_path().default.sep}node_modules${_path().default.sep}`;
42
40
  const CONFIG = Symbol.for('parcel-plugin-config');
43
41
  async function loadPlugin(pluginName, configPath, keyPath, options) {
44
- if (_internalPlugins.default && _internalPlugins.default[pluginName]) {
45
- let plugin = _internalPlugins.default[pluginName]();
46
- plugin = plugin.default[CONFIG];
47
- if (!plugin) {
48
- throw new Error(`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`);
49
- }
50
- return {
51
- plugin,
52
- version: _package.version,
53
- resolveFrom: (0, _projectPath.toProjectPathUnsafe)(options.projectRoot)
54
- };
55
- }
56
42
  let resolveFrom = configPath;
57
43
 
58
44
  // Config packages can reference plugins, but cannot contain other plugins within them.
@@ -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;
@@ -40,7 +40,7 @@ function _diagnostic() {
40
40
  return data;
41
41
  }
42
42
  function _json() {
43
- const data = _interopRequireDefault(require("json5"));
43
+ const data = require("json5");
44
44
  _json = function () {
45
45
  return data;
46
46
  };
@@ -179,7 +179,7 @@ function create(config, options) {
179
179
  async function parseAndProcessConfig(configPath, contents, options) {
180
180
  let config;
181
181
  try {
182
- config = _json().default.parse(contents);
182
+ config = (0, _json().parse)(contents);
183
183
  } catch (e) {
184
184
  let pos = {
185
185
  line: e.lineNumber,
@@ -139,7 +139,19 @@ 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
+ let cache = function createCache() {
143
+ if (initialOptions.cache) {
144
+ return initialOptions.cache;
145
+ }
146
+ const needsRustLmdbCache = (0, _featureFlags().getFeatureFlag)('atlaspackV3');
147
+ if (!needsRustLmdbCache && !(outputFS instanceof _fs().NodeFS)) {
148
+ return new (_cache().FSCache)(outputFS, cacheDir);
149
+ }
150
+ if (needsRustLmdbCache || (0, _featureFlags().getFeatureFlag)('useLmdbJsLite')) {
151
+ return new (_cache().LMDBLiteCache)(cacheDir);
152
+ }
153
+ return new (_cache().LMDBCache)(cacheDir);
154
+ }();
143
155
  let mode = initialOptions.mode ?? 'development';
144
156
  let shouldOptimize = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau = initialOptions.defaultTargetOptions) === null || _initialOptions$defau === void 0 ? void 0 : _initialOptions$defau.shouldOptimize) ?? mode === 'production';
145
157
  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.43+e1584ed4e",
3
+ "version": "2.14.1-dev.47+0a3b08abf",
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.43+e1584ed4e",
24
- "@atlaspack/cache": "2.13.3-dev.43+e1584ed4e",
25
- "@atlaspack/diagnostic": "2.14.1-dev.43+e1584ed4e",
26
- "@atlaspack/events": "2.14.1-dev.43+e1584ed4e",
27
- "@atlaspack/feature-flags": "2.14.1-dev.43+e1584ed4e",
28
- "@atlaspack/fs": "2.14.1-dev.43+e1584ed4e",
29
- "@atlaspack/graph": "3.4.1-dev.43+e1584ed4e",
30
- "@atlaspack/logger": "2.14.1-dev.43+e1584ed4e",
31
- "@atlaspack/package-manager": "2.14.1-dev.43+e1584ed4e",
32
- "@atlaspack/plugin": "2.14.1-dev.43+e1584ed4e",
33
- "@atlaspack/profiler": "2.14.1-dev.43+e1584ed4e",
34
- "@atlaspack/rust": "3.0.1-dev.43+e1584ed4e",
35
- "@atlaspack/types": "2.14.1-dev.43+e1584ed4e",
36
- "@atlaspack/utils": "2.14.1-dev.43+e1584ed4e",
37
- "@atlaspack/workers": "2.14.1-dev.43+e1584ed4e",
23
+ "@atlaspack/build-cache": "2.13.3-dev.47+0a3b08abf",
24
+ "@atlaspack/cache": "2.13.3-dev.47+0a3b08abf",
25
+ "@atlaspack/diagnostic": "2.14.1-dev.47+0a3b08abf",
26
+ "@atlaspack/events": "2.14.1-dev.47+0a3b08abf",
27
+ "@atlaspack/feature-flags": "2.14.1-dev.47+0a3b08abf",
28
+ "@atlaspack/fs": "2.14.1-dev.47+0a3b08abf",
29
+ "@atlaspack/graph": "3.4.1-dev.47+0a3b08abf",
30
+ "@atlaspack/logger": "2.14.1-dev.47+0a3b08abf",
31
+ "@atlaspack/package-manager": "2.14.1-dev.47+0a3b08abf",
32
+ "@atlaspack/plugin": "2.14.1-dev.47+0a3b08abf",
33
+ "@atlaspack/profiler": "2.14.1-dev.47+0a3b08abf",
34
+ "@atlaspack/rust": "3.0.1-dev.47+0a3b08abf",
35
+ "@atlaspack/types": "2.14.1-dev.47+0a3b08abf",
36
+ "@atlaspack/utils": "2.14.1-dev.47+0a3b08abf",
37
+ "@atlaspack/workers": "2.14.1-dev.47+0a3b08abf",
38
38
  "@mischnic/json-sourcemap": "^0.1.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
@@ -48,7 +48,7 @@
48
48
  "semver": "^7.5.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@atlaspack/babel-register": "2.14.0",
51
+ "@atlaspack/babel-register": "2.14.1",
52
52
  "@types/node": ">= 18",
53
53
  "graphviz": "^0.0.9",
54
54
  "jest-diff": "*",
@@ -67,5 +67,5 @@
67
67
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
68
  },
69
69
  "type": "commonjs",
70
- "gitHead": "e1584ed4eba00a5920c981f8622f8c04ee3c73c3"
70
+ "gitHead": "0a3b08abfeb2f12a780b4f6b6e616e3ffe52d951"
71
71
  }
package/src/Atlaspack.js CHANGED
@@ -58,20 +58,22 @@ 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
 
69
74
  export const INTERNAL_TRANSFORM: symbol = Symbol('internal_transform');
70
75
  export const INTERNAL_RESOLVE: symbol = Symbol('internal_resolve');
71
- export const WORKER_PATH: string = path.join(
72
- /*#__ATLASPACK_IGNORE__*/ __dirname,
73
- 'worker.js',
74
- );
76
+ export const WORKER_PATH: string = path.join(__dirname, 'worker.js');
75
77
 
76
78
  export default class Atlaspack {
77
79
  #requestTracker /*: RequestTracker*/;
@@ -120,6 +122,10 @@ export default class Atlaspack {
120
122
  };
121
123
  setFeatureFlags(featureFlags);
122
124
 
125
+ if (getFeatureFlag('enableRustWorkerThreadDylibHack')) {
126
+ loadRustWorkerThreadDylibHack();
127
+ }
128
+
123
129
  await initSourcemaps;
124
130
  await initRust?.();
125
131
 
@@ -1315,7 +1315,7 @@ export default class BundleGraph {
1315
1315
  }
1316
1316
 
1317
1317
  let dependencies = this._graph
1318
- .getNodeIdsConnectedTo(assetNodeId, ALL_EDGE_TYPES)
1318
+ .getNodeIdsConnectedTo(assetNodeId)
1319
1319
  .map((id) => nullthrows(this._graph.getNode(id)))
1320
1320
  .filter((node) => node.type === 'dependency')
1321
1321
  .map((node) => {
@@ -1697,11 +1697,14 @@ async function loadRequestGraph(options): Async<RequestGraph> {
1697
1697
  });
1698
1698
  }, 5000);
1699
1699
  let startTime = Date.now();
1700
- let events = await options.inputFS.getEventsSince(
1701
- options.watchDir,
1702
- snapshotPath,
1703
- opts,
1704
- );
1700
+ let events =
1701
+ process.env.ATLASPACK_BYPASS_CACHE_INVALIDATION === 'true'
1702
+ ? []
1703
+ : await options.inputFS.getEventsSince(
1704
+ options.watchDir,
1705
+ snapshotPath,
1706
+ opts,
1707
+ );
1705
1708
  clearTimeout(timeout);
1706
1709
 
1707
1710
  logger.verbose({
@@ -8,14 +8,8 @@ import ThrowableDiagnostic, {
8
8
  generateJSONCodeHighlights,
9
9
  md,
10
10
  } from '@atlaspack/diagnostic';
11
- import {version as ATLASPACK_VERSION} from '../package.json';
12
- import atlaspackInternalPlugins from './internal-plugins';
13
11
  import {findAlternativeNodeModules} from '@atlaspack/utils';
14
- import {
15
- type ProjectPath,
16
- toProjectPath,
17
- toProjectPathUnsafe,
18
- } from './projectPath';
12
+ import {type ProjectPath, toProjectPath} from './projectPath';
19
13
 
20
14
  const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
21
15
  const CONFIG = Symbol.for('parcel-plugin-config');
@@ -30,21 +24,6 @@ export default async function loadPlugin<T>(
30
24
  version: Semver,
31
25
  resolveFrom: ProjectPath,
32
26
  |}> {
33
- if (atlaspackInternalPlugins && atlaspackInternalPlugins[pluginName]) {
34
- let plugin = atlaspackInternalPlugins[pluginName]();
35
- plugin = plugin.default[CONFIG];
36
- if (!plugin) {
37
- throw new Error(
38
- `Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`,
39
- );
40
- }
41
- return {
42
- plugin,
43
- version: ATLASPACK_VERSION,
44
- resolveFrom: toProjectPathUnsafe(options.projectRoot),
45
- };
46
- }
47
-
48
27
  let resolveFrom = configPath;
49
28
 
50
29
  // Config packages can reference plugins, but cannot contain other plugins within them.
@@ -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
 
@@ -30,7 +30,7 @@ import ThrowableDiagnostic, {
30
30
  md,
31
31
  errorToDiagnostic,
32
32
  } from '@atlaspack/diagnostic';
33
- import json5 from 'json5';
33
+ import {parse} from 'json5';
34
34
  import path from 'path';
35
35
  import invariant from 'assert';
36
36
 
@@ -216,7 +216,7 @@ export async function parseAndProcessConfig(
216
216
  ): Promise<AtlaspackConfigChain> {
217
217
  let config: RawAtlaspackConfig;
218
218
  try {
219
- config = json5.parse(contents);
219
+ config = parse(contents);
220
220
  } catch (e) {
221
221
  let pos = {
222
222
  line: e.lineNumber,
@@ -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,25 @@ 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
+ function createCache() {
150
+ if (initialOptions.cache) {
151
+ return initialOptions.cache;
152
+ }
153
+
154
+ const needsRustLmdbCache = getFeatureFlag('atlaspackV3');
155
+
156
+ if (!needsRustLmdbCache && !(outputFS instanceof NodeFS)) {
157
+ return new FSCache(outputFS, cacheDir);
158
+ }
159
+
160
+ if (needsRustLmdbCache || getFeatureFlag('useLmdbJsLite')) {
161
+ return new LMDBLiteCache(cacheDir);
162
+ }
163
+
164
+ return new LMDBCache(cacheDir);
165
+ }
166
+
167
+ let cache = createCache();
153
168
 
154
169
  let mode = initialOptions.mode ?? 'development';
155
170
  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
+ }
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- // This file is overridden in super package builds
8
- // $FlowFixMe
9
- var _default = exports.default = {};
@@ -1,4 +0,0 @@
1
- // @flow
2
- // This file is overridden in super package builds
3
- // $FlowFixMe
4
- export default {};