@atlaspack/core 2.14.1-dev.9 → 2.15.0

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 }; }
@@ -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)();
@@ -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',
@@ -33,7 +33,6 @@ function _utils() {
33
33
  return data;
34
34
  }
35
35
  var _projectPath = require("./projectPath");
36
- var _package = require("../package.json");
37
36
  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); }
38
37
  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; }
39
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -62,10 +61,9 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
62
61
  }
63
62
  });
64
63
  }
65
- let resolved, pkg;
64
+ let pkg;
66
65
  try {
67
66
  ({
68
- resolved,
69
67
  pkg
70
68
  } = await options.packageManager.resolve(pluginName, resolveFrom, {
71
69
  shouldAutoInstall: options.shouldAutoInstall
@@ -93,9 +91,6 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
93
91
  }
94
92
  });
95
93
  }
96
-
97
- // Remove plugin version compatiblility validation in canary builds as they don't use semver
98
-
99
94
  let plugin = await options.packageManager.require(pluginName, resolveFrom, {
100
95
  shouldAutoInstall: options.shouldAutoInstall
101
96
  });
@@ -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,8 +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
- 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);
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
+ }();
144
155
  let mode = initialOptions.mode ?? 'development';
145
156
  let shouldOptimize = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau = initialOptions.defaultTargetOptions) === null || _initialOptions$defau === void 0 ? void 0 : _initialOptions$defau.shouldOptimize) ?? mode === 'production';
146
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.9+6d1d32abe",
3
+ "version": "2.15.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,22 +20,22 @@
20
20
  "check-ts": "tsc --noEmit index.d.ts"
21
21
  },
22
22
  "dependencies": {
23
- "@atlaspack/build-cache": "2.13.3-dev.9+6d1d32abe",
24
- "@atlaspack/cache": "2.13.3-dev.9+6d1d32abe",
25
- "@atlaspack/diagnostic": "2.14.1-dev.9+6d1d32abe",
26
- "@atlaspack/events": "2.14.1-dev.9+6d1d32abe",
27
- "@atlaspack/feature-flags": "2.14.1-dev.9+6d1d32abe",
28
- "@atlaspack/fs": "2.14.1-dev.9+6d1d32abe",
29
- "@atlaspack/graph": "3.4.1-dev.9+6d1d32abe",
30
- "@atlaspack/logger": "2.14.1-dev.9+6d1d32abe",
31
- "@atlaspack/package-manager": "2.14.1-dev.9+6d1d32abe",
32
- "@atlaspack/plugin": "2.14.1-dev.9+6d1d32abe",
33
- "@atlaspack/profiler": "2.14.1-dev.9+6d1d32abe",
34
- "@atlaspack/rust": "3.0.1-dev.9+6d1d32abe",
35
- "@atlaspack/types": "2.14.1-dev.9+6d1d32abe",
36
- "@atlaspack/utils": "2.14.1-dev.9+6d1d32abe",
37
- "@atlaspack/workers": "2.14.1-dev.9+6d1d32abe",
38
23
  "@mischnic/json-sourcemap": "^0.1.0",
24
+ "@atlaspack/build-cache": "2.13.3",
25
+ "@atlaspack/cache": "2.13.3",
26
+ "@atlaspack/diagnostic": "2.14.1",
27
+ "@atlaspack/events": "2.14.1",
28
+ "@atlaspack/feature-flags": "2.14.1",
29
+ "@atlaspack/fs": "2.14.1",
30
+ "@atlaspack/graph": "3.4.1",
31
+ "@atlaspack/logger": "2.14.1",
32
+ "@atlaspack/package-manager": "2.14.1",
33
+ "@atlaspack/plugin": "2.14.1",
34
+ "@atlaspack/profiler": "2.14.1",
35
+ "@atlaspack/rust": "3.0.1",
36
+ "@atlaspack/types": "2.14.1",
37
+ "@atlaspack/utils": "2.14.1",
38
+ "@atlaspack/workers": "2.14.1",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
41
41
  "browserslist": "^4.6.6",
@@ -48,11 +48,11 @@
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
- "graphviz": "^0.0.9",
54
- "jest-diff": "*",
55
53
  "rfdc": "1",
54
+ "jest-diff": "*",
55
+ "graphviz": "^0.0.9",
56
56
  "tempy": "^0.2.1"
57
57
  },
58
58
  "exports": {
@@ -66,6 +66,5 @@
66
66
  "browser": {
67
67
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
68
  },
69
- "type": "commonjs",
70
- "gitHead": "6d1d32abed2fbfdf4c318f311a0ac3aea9210e4a"
69
+ "type": "commonjs"
71
70
  }
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
 
@@ -117,6 +122,10 @@ export default class Atlaspack {
117
122
  };
118
123
  setFeatureFlags(featureFlags);
119
124
 
125
+ if (getFeatureFlag('enableRustWorkerThreadDylibHack')) {
126
+ loadRustWorkerThreadDylibHack();
127
+ }
128
+
120
129
  await initSourcemaps;
121
130
  await initRust?.();
122
131
 
@@ -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({
@@ -3,16 +3,13 @@ import type {FilePath, PackageName, Semver} from '@atlaspack/types';
3
3
  import type {AtlaspackOptions} from './types';
4
4
 
5
5
  import path from 'path';
6
- import semver from 'semver';
7
- import logger from '@atlaspack/logger';
8
6
  import nullthrows from 'nullthrows';
9
7
  import ThrowableDiagnostic, {
10
8
  generateJSONCodeHighlights,
11
9
  md,
12
10
  } from '@atlaspack/diagnostic';
13
- import {findAlternativeNodeModules, resolveConfig} from '@atlaspack/utils';
11
+ import {findAlternativeNodeModules} from '@atlaspack/utils';
14
12
  import {type ProjectPath, toProjectPath} from './projectPath';
15
- import {version as ATLASPACK_VERSION} from '../package.json';
16
13
 
17
14
  const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
18
15
  const CONFIG = Symbol.for('parcel-plugin-config');
@@ -56,13 +53,11 @@ export default async function loadPlugin<T>(
56
53
  });
57
54
  }
58
55
 
59
- let resolved, pkg;
56
+ let pkg;
60
57
  try {
61
- ({resolved, pkg} = await options.packageManager.resolve(
62
- pluginName,
63
- resolveFrom,
64
- {shouldAutoInstall: options.shouldAutoInstall},
65
- ));
58
+ ({pkg} = await options.packageManager.resolve(pluginName, resolveFrom, {
59
+ shouldAutoInstall: options.shouldAutoInstall,
60
+ }));
66
61
  } catch (err) {
67
62
  if (err.code !== 'MODULE_NOT_FOUND') {
68
63
  throw err;
@@ -102,61 +97,6 @@ export default async function loadPlugin<T>(
102
97
  });
103
98
  }
104
99
 
105
- // Remove plugin version compatiblility validation in canary builds as they don't use semver
106
- if (!process.env.SKIP_PLUGIN_COMPATIBILITY_CHECK) {
107
- if (!pluginName.startsWith('.')) {
108
- // Validate the plugin engines field
109
- let key = 'atlaspack';
110
- let atlaspackVersionRange;
111
- if (pkg?.engines?.atlaspack) {
112
- atlaspackVersionRange = pkg.engines.atlaspack;
113
- } else if (pkg?.engines?.parcel) {
114
- key = 'parcel';
115
- atlaspackVersionRange = pkg.engines.parcel;
116
- }
117
-
118
- if (!atlaspackVersionRange) {
119
- logger.warn({
120
- origin: '@atlaspack/core',
121
- message: `The plugin "${pluginName}" needs to specify a \`package.json#engines.atlaspack\` field with the supported Atlaspack version range.`,
122
- });
123
- }
124
-
125
- if (
126
- atlaspackVersionRange &&
127
- !semver.satisfies(ATLASPACK_VERSION, atlaspackVersionRange)
128
- ) {
129
- let pkgFile = nullthrows(
130
- await resolveConfig(
131
- options.inputFS,
132
- resolved,
133
- ['package.json'],
134
- options.projectRoot,
135
- ),
136
- );
137
- let pkgContents = await options.inputFS.readFile(pkgFile, 'utf8');
138
- throw new ThrowableDiagnostic({
139
- diagnostic: {
140
- message: md`The plugin "${pluginName}" is not compatible with the current version of Atlaspack. Requires "${atlaspackVersionRange}" but the current version is "${ATLASPACK_VERSION}".`,
141
- origin: '@atlaspack/core',
142
- codeFrames: [
143
- {
144
- filePath: pkgFile,
145
- language: 'json5',
146
- code: pkgContents,
147
- codeHighlights: generateJSONCodeHighlights(pkgContents, [
148
- {
149
- key: `/engines/${key}`,
150
- },
151
- ]),
152
- },
153
- ],
154
- },
155
- });
156
- }
157
- }
158
- }
159
-
160
100
  let plugin = await options.packageManager.require(pluginName, resolveFrom, {
161
101
  shouldAutoInstall: options.shouldAutoInstall,
162
102
  });
@@ -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
 
@@ -146,14 +146,25 @@ export default async function resolveOptions(
146
146
  ? path.resolve(initialOptions.watchDir)
147
147
  : projectRoot;
148
148
 
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);
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();
157
168
 
158
169
  let mode = initialOptions.mode ?? 'development';
159
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
+ }
@@ -3,10 +3,6 @@
3
3
  import assert from 'assert';
4
4
  import path from 'path';
5
5
 
6
- import logger from '@atlaspack/logger';
7
- import {inputFS} from '@atlaspack/test-utils';
8
- import sinon from 'sinon';
9
-
10
6
  import {AtlaspackConfig} from '../src/AtlaspackConfig';
11
7
  import {toProjectPath} from '../src/projectPath';
12
8
  import {parseAndProcessConfig} from '../src/requests/AtlaspackConfigRequest';
@@ -127,167 +123,6 @@ describe('AtlaspackConfig', () => {
127
123
  });
128
124
 
129
125
  describe('loadPlugin', () => {
130
- it('should warn if a plugin needs to specify an engines.atlaspack field in package.json', async () => {
131
- let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
132
- let configFilePath = toProjectPath(
133
- projectRoot,
134
- path.join(projectRoot, '.parcelrc'),
135
- );
136
-
137
- let config = new AtlaspackConfig(
138
- {
139
- filePath: configFilePath,
140
- bundler: undefined,
141
- transformers: {
142
- '*.js': [
143
- {
144
- packageName: 'atlaspack-transformer-no-engines',
145
- resolveFrom: configFilePath,
146
- keyPath: '/transformers/*.js/0',
147
- },
148
- ],
149
- },
150
- },
151
- {...DEFAULT_OPTIONS, projectRoot},
152
- );
153
-
154
- let warnStub = sinon.stub(logger, 'warn');
155
- let {plugin} = await config.loadPlugin({
156
- packageName: 'atlaspack-transformer-no-engines',
157
- resolveFrom: configFilePath,
158
- keyPath: '/transformers/*.js/0',
159
- });
160
-
161
- assert.equal(typeof plugin?.transform, 'function');
162
- assert(warnStub.calledOnce);
163
- assert.deepEqual(warnStub.getCall(0).args[0], {
164
- origin: '@atlaspack/core',
165
- message:
166
- 'The plugin "atlaspack-transformer-no-engines" needs to specify a `package.json#engines.atlaspack` field with the supported Atlaspack version range.',
167
- });
168
- warnStub.restore();
169
- });
170
-
171
- it('should error if a plugin specifies an invalid engines.atlaspack field in package.json', async () => {
172
- let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
173
- let configFilePath = toProjectPath(
174
- projectRoot,
175
- path.join(projectRoot, '.parcelrc'),
176
- );
177
-
178
- let config = new AtlaspackConfig(
179
- {
180
- filePath: configFilePath,
181
- bundler: undefined,
182
- transformers: {},
183
- },
184
- {...DEFAULT_OPTIONS, projectRoot},
185
- );
186
-
187
- // $FlowFixMe[untyped-import]
188
- let atlaspackVersion = require('../package.json').version;
189
- let pkgJSON = path.join(
190
- projectRoot,
191
- 'node_modules',
192
- 'atlaspack-transformer-bad-engines',
193
- 'package.json',
194
- );
195
- let code = inputFS.readFileSync(pkgJSON, 'utf8');
196
-
197
- // $FlowFixMe
198
- await assert.rejects(
199
- () =>
200
- config.loadPlugin({
201
- packageName: 'atlaspack-transformer-bad-engines',
202
- resolveFrom: configFilePath,
203
- keyPath: '/transformers/*.js/0',
204
- }),
205
- {
206
- name: 'Error',
207
- diagnostics: [
208
- {
209
- message: `The plugin "atlaspack-transformer-bad-engines" is not compatible with the current version of Atlaspack. Requires "1.x" but the current version is "${atlaspackVersion}".`,
210
- origin: '@atlaspack/core',
211
- codeFrames: [
212
- {
213
- filePath: pkgJSON,
214
- language: 'json5',
215
- code,
216
- codeHighlights: [
217
- {
218
- start: {line: 5, column: 5},
219
- end: {line: 5, column: 22},
220
- message: undefined,
221
- },
222
- ],
223
- },
224
- ],
225
- },
226
- ],
227
- },
228
- );
229
- });
230
-
231
- it('should error if a plugin specifies an invalid engines.parcel field in package.json', async () => {
232
- let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
233
- let configFilePath = toProjectPath(
234
- projectRoot,
235
- path.join(projectRoot, '.parcelrc'),
236
- );
237
-
238
- let config = new AtlaspackConfig(
239
- {
240
- filePath: configFilePath,
241
- bundler: undefined,
242
- transformers: {},
243
- },
244
- {...DEFAULT_OPTIONS, projectRoot},
245
- );
246
-
247
- // $FlowFixMe[untyped-import]
248
- let atlaspackVersion = require('../package.json').version;
249
- let pkgJSON = path.join(
250
- projectRoot,
251
- 'node_modules',
252
- 'atlaspack-transformer-bad-parcel-engines',
253
- 'package.json',
254
- );
255
- let code = inputFS.readFileSync(pkgJSON, 'utf8');
256
-
257
- // $FlowFixMe
258
- await assert.rejects(
259
- () =>
260
- config.loadPlugin({
261
- packageName: 'atlaspack-transformer-bad-parcel-engines',
262
- resolveFrom: configFilePath,
263
- keyPath: '/transformers/*.js/0',
264
- }),
265
- {
266
- name: 'Error',
267
- diagnostics: [
268
- {
269
- message: `The plugin "atlaspack-transformer-bad-parcel-engines" is not compatible with the current version of Atlaspack. Requires "1.x" but the current version is "${atlaspackVersion}".`,
270
- origin: '@atlaspack/core',
271
- codeFrames: [
272
- {
273
- filePath: pkgJSON,
274
- language: 'json5',
275
- code,
276
- codeHighlights: [
277
- {
278
- start: {line: 5, column: 5},
279
- end: {line: 5, column: 19},
280
- message: undefined,
281
- },
282
- ],
283
- },
284
- ],
285
- },
286
- ],
287
- },
288
- );
289
- });
290
-
291
126
  it('should error with a codeframe if a plugin is not resolved', async () => {
292
127
  let configFilePath = path.join(
293
128
  __dirname,
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright (c) 2024 Atlassian US., Inc.
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
@@ -1,7 +0,0 @@
1
- const {Transformer} = require('@atlaspack/plugin');
2
-
3
- module.exports = new Transformer({
4
- transform(asset) {
5
- return [asset];
6
- }
7
- });
@@ -1,7 +0,0 @@
1
- {
2
- "name": "atlaspack-transformer-bad-engines",
3
- "version": "1.0.0",
4
- "engines": {
5
- "atlaspack": "1.x"
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- const {Transformer} = require('@atlaspack/plugin');
2
-
3
- module.exports = new Transformer({
4
- transform(asset) {
5
- return [asset];
6
- }
7
- });
@@ -1,7 +0,0 @@
1
- {
2
- "name": "atlaspack-transformer-bad-parcel-engines",
3
- "version": "1.0.0",
4
- "engines": {
5
- "parcel": "1.x"
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- const {Transformer} = require('@atlaspack/plugin');
2
-
3
- module.exports = new Transformer({
4
- transform(asset) {
5
- return [asset];
6
- }
7
- });
@@ -1,4 +0,0 @@
1
- {
2
- "name": "atlaspack-transformer-no-engines",
3
- "version": "1.0.0"
4
- }