@atlaspack/core 2.14.1-dev.11 → 2.14.1-dev.127

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/_empty.js ADDED
File without 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(__dirname, 'worker.js');
129
+ const WORKER_PATH = exports.WORKER_PATH = _path().default.join( /*#__ATLASPACK_IGNORE__*/__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)();
@@ -207,7 +211,6 @@ class Atlaspack {
207
211
  await lmdb.put('current_session_version', Buffer.from(version));
208
212
  rustAtlaspack = await _atlaspackV.AtlaspackV3.create({
209
213
  ...options,
210
- corePath: _path().default.join(__dirname, '..'),
211
214
  threads: process.env.NODE_ENV === 'test' ? 2 : undefined,
212
215
  entries: Array.isArray(entries) ? entries : entries == null ? undefined : [entries],
213
216
  env: resolvedOptions.env,
@@ -832,7 +832,10 @@ 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).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
835
+ let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId,
836
+ // TODO: This seems like bug with library builds when assets are present
837
+ // in other files. Guarding the fix for now exclusively for super builds
838
+ process.env.ATLASPACK_SUPER_BUILD === 'true' ? _graph().ALL_EDGE_TYPES : undefined).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
836
839
  (0, _assert().default)(node.type === 'dependency');
837
840
  return node.value;
838
841
  });
@@ -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',
@@ -19,7 +19,46 @@ function _diagnostic() {
19
19
  };
20
20
  return data;
21
21
  }
22
+ var _isSuperPackage = require("../isSuperPackage");
23
+ function _path() {
24
+ const data = _interopRequireDefault(require("path"));
25
+ _path = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
22
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+ function getJsPaths() {
32
+ const dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
33
+ if ((0, _isSuperPackage.isSuperPackage)()) {
34
+ // dirname: atlaspack/lib/core/core/atlaspack-v3
35
+ // core: atlaspack/lib/core/core/index.js
36
+ const corePath = _path().default.join(dirname, '..');
37
+ // esmodule helpers: atlaspack/lib/transformers/js/esmodule-helpers.js
38
+ const esmoduleHelpersPath = _path().default.join(dirname, '../../../transformers/js/esmodule-helpers.js');
39
+
40
+ // empty file: atlaspack/lib/core/core/_empty.js
41
+ const emptyFile = _path().default.join(dirname, '_empty.js');
42
+ return {
43
+ corePath,
44
+ esmoduleHelpersSpecifier: _path().default.relative(corePath, esmoduleHelpersPath),
45
+ esmoduleHelpersIncludeNodeModules: 'atlaspack',
46
+ emptyFile
47
+ };
48
+ }
49
+
50
+ // dirname: @atlaspack/core/lib/atlaspack-v3
51
+ // core: @atlaspack/core
52
+ const corePath = _path().default.join(dirname, '../..');
53
+ // empty file: atlaspack/lib/core/core/_empty.js
54
+ const emptyFile = _path().default.join(dirname, '_empty.js');
55
+ return {
56
+ corePath,
57
+ esmoduleHelpersSpecifier: '@atlaspack/transformer-js/src/esmodule-helpers.js',
58
+ esmoduleHelpersIncludeNodeModules: '@atlaspack/transformer-js',
59
+ emptyFile
60
+ };
61
+ }
23
62
  class AtlaspackV3 {
24
63
  constructor(atlaspack_napi) {
25
64
  this._atlaspack_napi = atlaspack_napi;
@@ -40,7 +79,10 @@ class AtlaspackV3 {
40
79
  fs,
41
80
  packageManager,
42
81
  threads,
43
- options,
82
+ options: {
83
+ ...options,
84
+ jsPaths: getJsPaths()
85
+ },
44
86
  napiWorkerPool
45
87
  }, lmdb);
46
88
  if (error !== null) {
@@ -33,7 +33,7 @@ function _rust() {
33
33
  return data;
34
34
  }
35
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
- const WORKER_PATH = _path().default.join(__dirname, 'worker', 'index.js');
36
+ const WORKER_PATH = _path().default.join( /*#__ATLASPACK_IGNORE__*/__dirname, 'worker', 'napi-worker.js');
37
37
  const ATLASPACK_NAPI_WORKERS = _process().default.env.ATLASPACK_NAPI_WORKERS && parseInt(_process().default.env.ATLASPACK_NAPI_WORKERS, 10);
38
38
  class NapiWorkerPool {
39
39
  #workers;
@@ -48,6 +48,7 @@ function _module() {
48
48
  }
49
49
  var _jsCallable = require("../jsCallable");
50
50
  var _compat = require("./compat");
51
+ var _internalPlugins = _interopRequireDefault(require("../../internal-plugins"));
51
52
  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); }
52
53
  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; }
53
54
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -66,10 +67,16 @@ class AtlaspackWorker {
66
67
  specifier,
67
68
  resolveFrom
68
69
  }) => {
69
- let customRequire = _module().createRequire(resolveFrom);
70
- let resolvedPath = customRequire.resolve(specifier);
71
- // $FlowFixMe
72
- let resolvedModule = await import(resolvedPath);
70
+ let resolvedModule;
71
+ if (_internalPlugins.default && _internalPlugins.default[specifier]) {
72
+ // If the plugin is available inside the package then use it
73
+ resolvedModule = _internalPlugins.default[specifier]();
74
+ } else {
75
+ let customRequire = _module().createRequire(resolveFrom);
76
+ let resolvedPath = customRequire.resolve(specifier);
77
+ // $FlowFixMe
78
+ resolvedModule = await import(resolvedPath);
79
+ }
73
80
  let instance = undefined;
74
81
  if (resolvedModule.default && resolvedModule.default[CONFIG]) {
75
82
  instance = resolvedModule.default[CONFIG];
package/lib/index.js CHANGED
@@ -9,7 +9,8 @@ var _exportNames = {
9
9
  BuildError: true,
10
10
  createWorkerFarm: true,
11
11
  INTERNAL_RESOLVE: true,
12
- INTERNAL_TRANSFORM: true
12
+ INTERNAL_TRANSFORM: true,
13
+ isSuperPackage: true
13
14
  };
14
15
  Object.defineProperty(exports, "Atlaspack", {
15
16
  enumerable: true,
@@ -53,7 +54,14 @@ Object.defineProperty(exports, "default", {
53
54
  return _Atlaspack.default;
54
55
  }
55
56
  });
57
+ Object.defineProperty(exports, "isSuperPackage", {
58
+ enumerable: true,
59
+ get: function () {
60
+ return _isSuperPackage.isSuperPackage;
61
+ }
62
+ });
56
63
  var _Atlaspack = _interopRequireWildcard(require("./Atlaspack"));
64
+ var _isSuperPackage = require("./isSuperPackage");
57
65
  var _atlaspackV = require("./atlaspack-v3");
58
66
  Object.keys(_atlaspackV).forEach(function (key) {
59
67
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,9 @@
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 = {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ let fs = require('fs');
4
+ let {
5
+ findAncestorFile
6
+ } = require('@atlaspack/rust');
7
+ let dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
8
+ function isSuperPackage() {
9
+ if (!dirname) {
10
+ return false;
11
+ }
12
+ let packageJson = JSON.parse(
13
+ // $FlowFixMe
14
+ fs.readFileSync(findAncestorFile(['package.json'], dirname, '/'), 'utf8'));
15
+ return packageJson.name === 'atlaspack';
16
+ }
17
+ let result;
18
+ module.exports.isSuperPackage = () => {
19
+ if (result == null) {
20
+ result = isSuperPackage();
21
+ }
22
+ return result;
23
+ };
@@ -25,6 +25,8 @@ function _diagnostic() {
25
25
  };
26
26
  return data;
27
27
  }
28
+ var _package = require("../package.json");
29
+ var _internalPlugins = _interopRequireDefault(require("./internal-plugins"));
28
30
  function _utils() {
29
31
  const data = require("@atlaspack/utils");
30
32
  _utils = function () {
@@ -39,6 +41,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
39
41
  const NODE_MODULES = `${_path().default.sep}node_modules${_path().default.sep}`;
40
42
  const CONFIG = Symbol.for('parcel-plugin-config');
41
43
  async function loadPlugin(pluginName, configPath, keyPath, options) {
44
+ if (_internalPlugins.default && _internalPlugins.default[pluginName]) {
45
+ let plugin = _internalPlugins.default[pluginName]();
46
+ plugin = plugin.default || plugin;
47
+ plugin = plugin[CONFIG];
48
+ if (!plugin) {
49
+ throw new Error(`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`);
50
+ }
51
+ return {
52
+ plugin,
53
+ version: _package.version,
54
+ resolveFrom: (0, _projectPath.toProjectPathUnsafe)(options.projectRoot)
55
+ };
56
+ }
42
57
  let resolveFrom = configPath;
43
58
 
44
59
  // 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 = require("json5");
43
+ const data = _interopRequireDefault(require("json5"));
44
44
  _json = function () {
45
45
  return data;
46
46
  };
@@ -60,11 +60,13 @@ function _assert() {
60
60
  };
61
61
  return data;
62
62
  }
63
+ var _internalPlugins = _interopRequireDefault(require("../internal-plugins"));
63
64
  var _AtlaspackConfig = require("../AtlaspackConfig");
64
65
  var _AtlaspackConfig2 = _interopRequireDefault(require("../AtlaspackConfig.schema"));
65
66
  var _projectPath = require("../projectPath");
66
67
  var _RequestTracker = require("../RequestTracker");
67
68
  var _utils2 = require("../utils");
69
+ var _isSuperPackage = require("../isSuperPackage");
68
70
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
69
71
  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); }
70
72
  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; }
@@ -134,28 +136,38 @@ async function resolveAtlaspackConfig(options) {
134
136
  let resolveFrom = getResolveFrom(options.inputFS, options.projectRoot);
135
137
  let configPath = options.config != null ? (await options.packageManager.resolve(options.config, resolveFrom)).resolved : await (0, _utils().resolveConfig)(options.inputFS, resolveFrom, ['.parcelrc'], options.projectRoot);
136
138
  let usedDefault = false;
137
- if (configPath == null && options.defaultConfig != null) {
139
+ let config, extendedFiles;
140
+ if (configPath == null && options.defaultConfig != null && (0, _isSuperPackage.isSuperPackage)() && options.defaultConfig.endsWith('.js')) {
138
141
  usedDefault = true;
139
- configPath = (await options.packageManager.resolve(options.defaultConfig, resolveFrom)).resolved;
140
- }
141
- if (configPath == null) {
142
- return null;
143
- }
144
- let contents;
145
- try {
146
- contents = await options.inputFS.readFile(configPath, 'utf8');
147
- } catch (e) {
148
- throw new (_diagnostic().default)({
149
- diagnostic: {
150
- message: (0, _diagnostic().md)`Could not find parcel config at ${_path().default.relative(options.projectRoot, configPath)}`,
151
- origin: '@atlaspack/core'
152
- }
153
- });
142
+ // Load the super package default config
143
+ let result = await processConfigChain(_internalPlugins.default['@atlaspack/config-default'](),
144
+ // $FlowFixMe
145
+ options.defaultConfig, options);
146
+ config = result.config;
147
+ extendedFiles = result.extendedFiles;
148
+ } else {
149
+ if (configPath == null && options.defaultConfig != null) {
150
+ usedDefault = true;
151
+ configPath = (await options.packageManager.resolve(options.defaultConfig, resolveFrom)).resolved;
152
+ }
153
+ if (configPath == null) {
154
+ return null;
155
+ }
156
+ let contents;
157
+ try {
158
+ contents = await options.inputFS.readFile(configPath, 'utf8');
159
+ } catch (e) {
160
+ throw new (_diagnostic().default)({
161
+ diagnostic: {
162
+ message: (0, _diagnostic().md)`Could not find parcel config at ${_path().default.relative(options.projectRoot, configPath)}`,
163
+ origin: '@atlaspack/core'
164
+ }
165
+ });
166
+ }
167
+ let result = await parseAndProcessConfig(configPath, contents, options);
168
+ config = result.config;
169
+ extendedFiles = result.extendedFiles;
154
170
  }
155
- let {
156
- config,
157
- extendedFiles
158
- } = await parseAndProcessConfig(configPath, contents, options);
159
171
  if (options.additionalReporters.length > 0) {
160
172
  config.reporters = [...options.additionalReporters.map(({
161
173
  packageName,
@@ -179,7 +191,7 @@ function create(config, options) {
179
191
  async function parseAndProcessConfig(configPath, contents, options) {
180
192
  let config;
181
193
  try {
182
- config = (0, _json().parse)(contents);
194
+ config = _json().default.parse(contents);
183
195
  } catch (e) {
184
196
  let pos = {
185
197
  line: e.lineNumber,
@@ -304,13 +316,16 @@ async function processConfigChain(configFile, filePath, options) {
304
316
  for (let ext of exts) {
305
317
  try {
306
318
  let key = Array.isArray(configFile.extends) ? `/extends/${i}` : '/extends';
307
- let resolved = await resolveExtends(ext, filePath, key, options);
308
- extendedFiles.push(resolved);
309
- let {
310
- extendedFiles: moreExtendedFiles,
311
- config: nextConfig
312
- } = await processExtendedConfig(filePath, key, ext, resolved, options);
313
- extendedFiles = extendedFiles.concat(moreExtendedFiles);
319
+ let nextConfig;
320
+ if (_internalPlugins.default[ext]) {
321
+ nextConfig = (await processConfigChain(_internalPlugins.default[ext](), /*#__ATLASPACK_IGNORE__*/__dirname, options)).config;
322
+ } else {
323
+ let resolved = await resolveExtends(ext, filePath, key, options);
324
+ extendedFiles.push(resolved);
325
+ let result = await processExtendedConfig(filePath, key, ext, resolved, options);
326
+ extendedFiles = extendedFiles.concat(result.extendedFiles);
327
+ nextConfig = result.config;
328
+ }
314
329
  extStartConfig = extStartConfig ? mergeConfigs(extStartConfig, nextConfig) : nextConfig;
315
330
  } catch (err) {
316
331
  errors.push(err);
@@ -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/lib/worker.js CHANGED
@@ -78,15 +78,15 @@ require("@atlaspack/package-manager");
78
78
  require("@atlaspack/fs");
79
79
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
80
80
  // register with serializer
81
+ // Repl builds are currently not enabled
81
82
  // $FlowFixMe
82
- if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
83
- /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
84
- require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
85
- // $FlowFixMe
86
- require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
87
- /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
88
- }
89
-
83
+ // if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
84
+ // /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
85
+ // require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
86
+ // // $FlowFixMe
87
+ // require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
88
+ // /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
89
+ // }
90
90
  (0, _registerCoreWithSerializer.registerCoreWithSerializer)();
91
91
 
92
92
  // Remove the workerApi type from the TransformationOpts and ValidationOpts types:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.14.1-dev.11+633800dee",
3
+ "version": "2.14.1-dev.127+f61711fb0",
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.11+633800dee",
24
- "@atlaspack/cache": "2.13.3-dev.11+633800dee",
25
- "@atlaspack/diagnostic": "2.14.1-dev.11+633800dee",
26
- "@atlaspack/events": "2.14.1-dev.11+633800dee",
27
- "@atlaspack/feature-flags": "2.14.1-dev.11+633800dee",
28
- "@atlaspack/fs": "2.14.1-dev.11+633800dee",
29
- "@atlaspack/graph": "3.4.1-dev.11+633800dee",
30
- "@atlaspack/logger": "2.14.1-dev.11+633800dee",
31
- "@atlaspack/package-manager": "2.14.1-dev.11+633800dee",
32
- "@atlaspack/plugin": "2.14.1-dev.11+633800dee",
33
- "@atlaspack/profiler": "2.14.1-dev.11+633800dee",
34
- "@atlaspack/rust": "3.0.1-dev.11+633800dee",
35
- "@atlaspack/types": "2.14.1-dev.11+633800dee",
36
- "@atlaspack/utils": "2.14.1-dev.11+633800dee",
37
- "@atlaspack/workers": "2.14.1-dev.11+633800dee",
23
+ "@atlaspack/build-cache": "2.13.3-dev.127+f61711fb0",
24
+ "@atlaspack/cache": "2.13.3-dev.127+f61711fb0",
25
+ "@atlaspack/diagnostic": "2.14.1-dev.127+f61711fb0",
26
+ "@atlaspack/events": "2.14.1-dev.127+f61711fb0",
27
+ "@atlaspack/feature-flags": "2.14.1-dev.127+f61711fb0",
28
+ "@atlaspack/fs": "2.14.1-dev.127+f61711fb0",
29
+ "@atlaspack/graph": "3.4.1-dev.127+f61711fb0",
30
+ "@atlaspack/logger": "2.14.1-dev.127+f61711fb0",
31
+ "@atlaspack/package-manager": "2.14.1-dev.127+f61711fb0",
32
+ "@atlaspack/plugin": "2.14.1-dev.127+f61711fb0",
33
+ "@atlaspack/profiler": "2.14.1-dev.127+f61711fb0",
34
+ "@atlaspack/rust": "3.0.1-dev.127+f61711fb0",
35
+ "@atlaspack/types": "2.14.1-dev.127+f61711fb0",
36
+ "@atlaspack/utils": "2.14.1-dev.127+f61711fb0",
37
+ "@atlaspack/workers": "2.14.1-dev.127+f61711fb0",
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": "*",
@@ -63,9 +63,12 @@
63
63
  "default": "./lib/worker.js"
64
64
  }
65
65
  },
66
+ "atlaspackReferences": [
67
+ "_empty.js"
68
+ ],
66
69
  "browser": {
67
70
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
71
  },
69
72
  "type": "commonjs",
70
- "gitHead": "633800dee24b76fed158966a802c0ea5dcab65d5"
73
+ "gitHead": "f61711fb077f3c473aa49f56b1226da60f61b7df"
71
74
  }
package/src/Atlaspack.js CHANGED
@@ -58,17 +58,25 @@ 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(__dirname, 'worker.js');
76
+ export const WORKER_PATH: string = path.join(
77
+ /*#__ATLASPACK_IGNORE__*/ __dirname,
78
+ 'worker.js',
79
+ );
72
80
 
73
81
  export default class Atlaspack {
74
82
  #requestTracker /*: RequestTracker*/;
@@ -117,6 +125,10 @@ export default class Atlaspack {
117
125
  };
118
126
  setFeatureFlags(featureFlags);
119
127
 
128
+ if (getFeatureFlag('enableRustWorkerThreadDylibHack')) {
129
+ loadRustWorkerThreadDylibHack();
130
+ }
131
+
120
132
  await initSourcemaps;
121
133
  await initRust?.();
122
134
 
@@ -164,7 +176,6 @@ export default class Atlaspack {
164
176
 
165
177
  rustAtlaspack = await AtlaspackV3.create({
166
178
  ...options,
167
- corePath: path.join(__dirname, '..'),
168
179
  threads: process.env.NODE_ENV === 'test' ? 2 : undefined,
169
180
  entries: Array.isArray(entries)
170
181
  ? entries
@@ -1315,7 +1315,14 @@ export default class BundleGraph {
1315
1315
  }
1316
1316
 
1317
1317
  let dependencies = this._graph
1318
- .getNodeIdsConnectedTo(assetNodeId)
1318
+ .getNodeIdsConnectedTo(
1319
+ assetNodeId,
1320
+ // TODO: This seems like bug with library builds when assets are present
1321
+ // in other files. Guarding the fix for now exclusively for super builds
1322
+ process.env.ATLASPACK_SUPER_BUILD === 'true'
1323
+ ? ALL_EDGE_TYPES
1324
+ : undefined,
1325
+ )
1319
1326
  .map((id) => nullthrows(this._graph.getNode(id)))
1320
1327
  .filter((node) => node.type === 'dependency')
1321
1328
  .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({
@@ -12,6 +12,8 @@ import {NapiWorkerPool} from './NapiWorkerPool';
12
12
  import ThrowableDiagnostic from '@atlaspack/diagnostic';
13
13
  import type {Event} from '@parcel/watcher';
14
14
  import type {NapiWorkerPool as INapiWorkerPool} from '@atlaspack/types';
15
+ import {isSuperPackage} from '../isSuperPackage';
16
+ import path from 'path';
15
17
 
16
18
  export type AtlaspackV3Options = {|
17
19
  fs?: AtlaspackNapiOptions['fs'],
@@ -23,9 +25,53 @@ export type AtlaspackV3Options = {|
23
25
  lmdb: Lmdb,
24
26
  featureFlags?: {[string]: string | boolean},
25
27
  napiWorkerPool?: INapiWorkerPool,
26
- ...AtlaspackNapiOptions['options'],
28
+ ...$Diff<
29
+ AtlaspackNapiOptions['options'],
30
+ {|
31
+ jsPaths: AtlaspackNapiOptions['options']['jsPaths'],
32
+ |},
33
+ >,
27
34
  |};
28
35
 
36
+ function getJsPaths(): AtlaspackNapiOptions['options']['jsPaths'] {
37
+ const dirname = /*#__ATLASPACK_IGNORE__*/ __dirname;
38
+
39
+ if (isSuperPackage()) {
40
+ // dirname: atlaspack/lib/core/core/atlaspack-v3
41
+ // core: atlaspack/lib/core/core/index.js
42
+ const corePath = path.join(dirname, '..');
43
+ // esmodule helpers: atlaspack/lib/transformers/js/esmodule-helpers.js
44
+ const esmoduleHelpersPath = path.join(
45
+ dirname,
46
+ '../../../transformers/js/esmodule-helpers.js',
47
+ );
48
+
49
+ // empty file: atlaspack/lib/core/core/_empty.js
50
+ const emptyFile = path.join(dirname, '_empty.js');
51
+
52
+ return {
53
+ corePath,
54
+ esmoduleHelpersSpecifier: path.relative(corePath, esmoduleHelpersPath),
55
+ esmoduleHelpersIncludeNodeModules: 'atlaspack',
56
+ emptyFile,
57
+ };
58
+ }
59
+
60
+ // dirname: @atlaspack/core/lib/atlaspack-v3
61
+ // core: @atlaspack/core
62
+ const corePath = path.join(dirname, '../..');
63
+ // empty file: atlaspack/lib/core/core/_empty.js
64
+ const emptyFile = path.join(dirname, '_empty.js');
65
+
66
+ return {
67
+ corePath,
68
+ esmoduleHelpersSpecifier:
69
+ '@atlaspack/transformer-js/src/esmodule-helpers.js',
70
+ esmoduleHelpersIncludeNodeModules: '@atlaspack/transformer-js',
71
+ emptyFile,
72
+ };
73
+ }
74
+
29
75
  export class AtlaspackV3 {
30
76
  _atlaspack_napi: AtlaspackNapi;
31
77
 
@@ -52,7 +98,10 @@ export class AtlaspackV3 {
52
98
  fs,
53
99
  packageManager,
54
100
  threads,
55
- options,
101
+ options: {
102
+ ...options,
103
+ jsPaths: getJsPaths(),
104
+ },
56
105
  napiWorkerPool,
57
106
  },
58
107
  lmdb,
@@ -6,7 +6,11 @@ import process from 'process';
6
6
  import type {Transferable} from '@atlaspack/rust';
7
7
  import {getAvailableThreads} from '@atlaspack/rust';
8
8
 
9
- const WORKER_PATH = path.join(__dirname, 'worker', 'index.js');
9
+ const WORKER_PATH = path.join(
10
+ /*#__ATLASPACK_IGNORE__*/ __dirname,
11
+ 'worker',
12
+ 'napi-worker.js',
13
+ );
10
14
  const ATLASPACK_NAPI_WORKERS =
11
15
  process.env.ATLASPACK_NAPI_WORKERS &&
12
16
  parseInt(process.env.ATLASPACK_NAPI_WORKERS, 10);
@@ -25,6 +25,7 @@ import {
25
25
  bundleBehaviorMap,
26
26
  dependencyPriorityMap,
27
27
  } from './compat';
28
+ import atlaspackInternalPlugins from '../../internal-plugins';
28
29
 
29
30
  const CONFIG = Symbol.for('parcel-plugin-config');
30
31
 
@@ -41,10 +42,16 @@ export class AtlaspackWorker {
41
42
 
42
43
  loadPlugin: JsCallable<[LoadPluginOptions], Promise<void>> = jsCallable(
43
44
  async ({kind, specifier, resolveFrom}) => {
44
- let customRequire = module.createRequire(resolveFrom);
45
- let resolvedPath = customRequire.resolve(specifier);
46
- // $FlowFixMe
47
- let resolvedModule = await import(resolvedPath);
45
+ let resolvedModule;
46
+ if (atlaspackInternalPlugins && atlaspackInternalPlugins[specifier]) {
47
+ // If the plugin is available inside the package then use it
48
+ resolvedModule = atlaspackInternalPlugins[specifier]();
49
+ } else {
50
+ let customRequire = module.createRequire(resolveFrom);
51
+ let resolvedPath = customRequire.resolve(specifier);
52
+ // $FlowFixMe
53
+ resolvedModule = await import(resolvedPath);
54
+ }
48
55
 
49
56
  let instance = undefined;
50
57
  if (resolvedModule.default && resolvedModule.default[CONFIG]) {
package/src/index.js CHANGED
@@ -10,4 +10,6 @@ export {
10
10
  INTERNAL_TRANSFORM,
11
11
  } from './Atlaspack';
12
12
 
13
+ export {isSuperPackage} from './isSuperPackage';
14
+
13
15
  export * from './atlaspack-v3';
@@ -0,0 +1,4 @@
1
+ // @flow
2
+ // This file is overridden in super package builds
3
+ // $FlowFixMe
4
+ export default {};
@@ -0,0 +1,28 @@
1
+ // @flow strict-local
2
+ let fs = require('fs');
3
+ let {findAncestorFile} = require('@atlaspack/rust');
4
+
5
+ let dirname = /*#__ATLASPACK_IGNORE__*/ __dirname;
6
+
7
+ function isSuperPackage(): boolean {
8
+ if (!dirname) {
9
+ return false;
10
+ }
11
+
12
+ let packageJson = JSON.parse(
13
+ // $FlowFixMe
14
+ fs.readFileSync(findAncestorFile(['package.json'], dirname, '/'), 'utf8'),
15
+ );
16
+
17
+ return packageJson.name === 'atlaspack';
18
+ }
19
+
20
+ let result;
21
+
22
+ module.exports.isSuperPackage = (): boolean => {
23
+ if (result == null) {
24
+ result = isSuperPackage();
25
+ }
26
+
27
+ return result;
28
+ };
@@ -8,8 +8,14 @@ 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';
11
13
  import {findAlternativeNodeModules} from '@atlaspack/utils';
12
- import {type ProjectPath, toProjectPath} from './projectPath';
14
+ import {
15
+ type ProjectPath,
16
+ toProjectPath,
17
+ toProjectPathUnsafe,
18
+ } from './projectPath';
13
19
 
14
20
  const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
15
21
  const CONFIG = Symbol.for('parcel-plugin-config');
@@ -24,6 +30,22 @@ export default async function loadPlugin<T>(
24
30
  version: Semver,
25
31
  resolveFrom: ProjectPath,
26
32
  |}> {
33
+ if (atlaspackInternalPlugins && atlaspackInternalPlugins[pluginName]) {
34
+ let plugin = atlaspackInternalPlugins[pluginName]();
35
+ plugin = plugin.default || plugin;
36
+ plugin = plugin[CONFIG];
37
+ if (!plugin) {
38
+ throw new Error(
39
+ `Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`,
40
+ );
41
+ }
42
+ return {
43
+ plugin,
44
+ version: ATLASPACK_VERSION,
45
+ resolveFrom: toProjectPathUnsafe(options.projectRoot),
46
+ };
47
+ }
48
+
27
49
  let resolveFrom = configPath;
28
50
 
29
51
  // 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,15 +30,17 @@ import ThrowableDiagnostic, {
30
30
  md,
31
31
  errorToDiagnostic,
32
32
  } from '@atlaspack/diagnostic';
33
- import {parse} from 'json5';
33
+ import json5 from 'json5';
34
34
  import path from 'path';
35
35
  import invariant from 'assert';
36
36
 
37
+ import atlaspackInternalPlugins from '../internal-plugins';
37
38
  import {AtlaspackConfig} from '../AtlaspackConfig';
38
39
  import AtlaspackConfigSchema from '../AtlaspackConfig.schema';
39
40
  import {toProjectPath} from '../projectPath';
40
41
  import {requestTypes} from '../RequestTracker';
41
42
  import {optionsProxy} from '../utils';
43
+ import {isSuperPackage} from '../isSuperPackage';
42
44
 
43
45
  type ConfigMap<K, V> = {[K]: V, ...};
44
46
 
@@ -159,34 +161,60 @@ export async function resolveAtlaspackConfig(
159
161
  );
160
162
 
161
163
  let usedDefault = false;
162
- if (configPath == null && options.defaultConfig != null) {
164
+ let config, extendedFiles;
165
+
166
+ if (
167
+ configPath == null &&
168
+ options.defaultConfig != null &&
169
+ isSuperPackage() &&
170
+ options.defaultConfig.endsWith('.js')
171
+ ) {
163
172
  usedDefault = true;
164
- configPath = (
165
- await options.packageManager.resolve(options.defaultConfig, resolveFrom)
166
- ).resolved;
167
- }
173
+ // Load the super package default config
174
+ let result: AtlaspackConfigChain = await processConfigChain(
175
+ atlaspackInternalPlugins['@atlaspack/config-default'](),
176
+ // $FlowFixMe
177
+ options.defaultConfig,
178
+ options,
179
+ );
180
+ config = result.config;
181
+ extendedFiles = result.extendedFiles;
182
+ } else {
183
+ if (configPath == null && options.defaultConfig != null) {
184
+ usedDefault = true;
168
185
 
169
- if (configPath == null) {
170
- return null;
171
- }
186
+ configPath = (
187
+ await options.packageManager.resolve(options.defaultConfig, resolveFrom)
188
+ ).resolved;
189
+ }
172
190
 
173
- let contents;
174
- try {
175
- contents = await options.inputFS.readFile(configPath, 'utf8');
176
- } catch (e) {
177
- throw new ThrowableDiagnostic({
178
- diagnostic: {
179
- message: md`Could not find parcel config at ${path.relative(
180
- options.projectRoot,
181
- configPath,
182
- )}`,
183
- origin: '@atlaspack/core',
184
- },
185
- });
186
- }
191
+ if (configPath == null) {
192
+ return null;
193
+ }
194
+
195
+ let contents;
196
+ try {
197
+ contents = await options.inputFS.readFile(configPath, 'utf8');
198
+ } catch (e) {
199
+ throw new ThrowableDiagnostic({
200
+ diagnostic: {
201
+ message: md`Could not find parcel config at ${path.relative(
202
+ options.projectRoot,
203
+ configPath,
204
+ )}`,
205
+ origin: '@atlaspack/core',
206
+ },
207
+ });
208
+ }
187
209
 
188
- let {config, extendedFiles}: AtlaspackConfigChain =
189
- await parseAndProcessConfig(configPath, contents, options);
210
+ let result: AtlaspackConfigChain = await parseAndProcessConfig(
211
+ configPath,
212
+ contents,
213
+ options,
214
+ );
215
+ config = result.config;
216
+ extendedFiles = result.extendedFiles;
217
+ }
190
218
 
191
219
  if (options.additionalReporters.length > 0) {
192
220
  config.reporters = [
@@ -216,7 +244,7 @@ export async function parseAndProcessConfig(
216
244
  ): Promise<AtlaspackConfigChain> {
217
245
  let config: RawAtlaspackConfig;
218
246
  try {
219
- config = parse(contents);
247
+ config = json5.parse(contents);
220
248
  } catch (e) {
221
249
  let pos = {
222
250
  line: e.lineNumber,
@@ -446,11 +474,29 @@ export async function processConfigChain(
446
474
  let key = Array.isArray(configFile.extends)
447
475
  ? `/extends/${i}`
448
476
  : '/extends';
449
- let resolved = await resolveExtends(ext, filePath, key, options);
450
- extendedFiles.push(resolved);
451
- let {extendedFiles: moreExtendedFiles, config: nextConfig} =
452
- await processExtendedConfig(filePath, key, ext, resolved, options);
453
- extendedFiles = extendedFiles.concat(moreExtendedFiles);
477
+
478
+ let nextConfig;
479
+ if (atlaspackInternalPlugins[ext]) {
480
+ nextConfig = (
481
+ await processConfigChain(
482
+ atlaspackInternalPlugins[ext](),
483
+ /*#__ATLASPACK_IGNORE__*/ __dirname,
484
+ options,
485
+ )
486
+ ).config;
487
+ } else {
488
+ let resolved = await resolveExtends(ext, filePath, key, options);
489
+ extendedFiles.push(resolved);
490
+ let result = await processExtendedConfig(
491
+ filePath,
492
+ key,
493
+ ext,
494
+ resolved,
495
+ options,
496
+ );
497
+ extendedFiles = extendedFiles.concat(result.extendedFiles);
498
+ nextConfig = result.config;
499
+ }
454
500
  extStartConfig = extStartConfig
455
501
  ? mergeConfigs(extStartConfig, nextConfig)
456
502
  : nextConfig;
@@ -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
+ }
package/src/worker.js CHANGED
@@ -32,14 +32,15 @@ import '@atlaspack/cache'; // register with serializer
32
32
  import '@atlaspack/package-manager';
33
33
  import '@atlaspack/fs';
34
34
 
35
+ // Repl builds are currently not enabled
35
36
  // $FlowFixMe
36
- if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
37
- /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
38
- require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
39
- // $FlowFixMe
40
- require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
41
- /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
42
- }
37
+ // if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
38
+ // /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
39
+ // require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
40
+ // // $FlowFixMe
41
+ // require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
42
+ // /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
43
+ // }
43
44
 
44
45
  registerCoreWithSerializer();
45
46