@atlaspack/core 2.16.2-dev.73 → 2.16.2-dev.93

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,66 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.18.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#652](https://github.com/atlassian-labs/atlaspack/pull/652) [`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix bugs related to build aborts. Builds and cache writes will no longer be aborted.
8
+
9
+ - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
10
+ - @atlaspack/feature-flags@2.18.2
11
+ - @atlaspack/cache@3.2.9
12
+ - @atlaspack/fs@2.15.9
13
+ - @atlaspack/graph@3.5.4
14
+ - @atlaspack/utils@2.15.2
15
+ - @atlaspack/package-manager@2.14.14
16
+ - @atlaspack/profiler@2.14.12
17
+ - @atlaspack/types@2.15.4
18
+ - @atlaspack/workers@2.14.14
19
+ - @atlaspack/plugin@2.14.14
20
+
21
+ ## 2.18.4
22
+
23
+ ### Patch Changes
24
+
25
+ - [#650](https://github.com/atlassian-labs/atlaspack/pull/650) [`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb) Thanks [@alshdavid](https://github.com/alshdavid)! - Remove package.json#exports
26
+
27
+ - [#646](https://github.com/atlassian-labs/atlaspack/pull/646) [`6b1f5ff`](https://github.com/atlassian-labs/atlaspack/commit/6b1f5fff68d7131fae075e14f4d2c02606dc6058) Thanks [@alshdavid](https://github.com/alshdavid)! - Export WORKER_PATH from @atlaspack/core
28
+
29
+ - [#633](https://github.com/atlassian-labs/atlaspack/pull/633) [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b) Thanks [@sbhuiyan-atlassian](https://github.com/sbhuiyan-atlassian)! - Ported various HMR changes from Parcel
30
+
31
+ - [#648](https://github.com/atlassian-labs/atlaspack/pull/648) [`c8f7df4`](https://github.com/atlassian-labs/atlaspack/commit/c8f7df4eadfc4718040fceb065dae6e96a4051e7) Thanks [@alshdavid](https://github.com/alshdavid)! - Export ATLASPACK_VERSION and other internals
32
+
33
+ - [#626](https://github.com/atlassian-labs/atlaspack/pull/626) [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca) Thanks [@yamadapc](https://github.com/yamadapc)! - Clean-up tsconfig invalidation improvements feature-flag
34
+
35
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb), [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
36
+ - @atlaspack/workers@2.14.13
37
+ - @atlaspack/logger@2.14.11
38
+ - @atlaspack/feature-flags@2.18.1
39
+ - @atlaspack/fs@2.15.8
40
+ - @atlaspack/package-manager@2.14.13
41
+ - @atlaspack/types@2.15.3
42
+ - @atlaspack/cache@3.2.8
43
+ - @atlaspack/utils@2.15.1
44
+ - @atlaspack/graph@3.5.3
45
+ - @atlaspack/plugin@2.14.13
46
+ - @atlaspack/profiler@2.14.11
47
+
48
+ ## 2.18.3
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2), [`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
53
+ - @atlaspack/feature-flags@2.18.0
54
+ - @atlaspack/utils@2.15.0
55
+ - @atlaspack/cache@3.2.7
56
+ - @atlaspack/fs@2.15.7
57
+ - @atlaspack/graph@3.5.2
58
+ - @atlaspack/package-manager@2.14.12
59
+ - @atlaspack/workers@2.14.12
60
+ - @atlaspack/profiler@2.14.10
61
+ - @atlaspack/types@2.15.2
62
+ - @atlaspack/plugin@2.14.12
63
+
3
64
  ## 2.18.2
4
65
 
5
66
  ### Patch Changes
package/lib/AssetGraph.js CHANGED
@@ -443,6 +443,15 @@ class AssetGraph extends _graph().ContentGraph {
443
443
  ...depNode.value.meta,
444
444
  ...existing.value.resolverMeta
445
445
  };
446
+ if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
447
+ depNode.value.resolverMeta = existing.value.resolverMeta;
448
+ }
449
+ }
450
+ if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
451
+ if ((existing === null || existing === void 0 ? void 0 : existing.type) === 'dependency' && existing.value.resolverPriority != null) {
452
+ depNode.value.priority = existing.value.resolverPriority;
453
+ depNode.value.resolverPriority = existing.value.resolverPriority;
454
+ }
446
455
  }
447
456
  let dependentAsset = dependentAssets.find(a => a.uniqueKey === dep.specifier);
448
457
  if (dependentAsset) {
@@ -14,7 +14,13 @@ exports.validatePackageName = validatePackageName;
14
14
  // * We do not care about package names
15
15
  // * Validation makes interop between parcel/atlaspack confusing.
16
16
  //
17
- function validatePackageName() {}
17
+ function validatePackageName(
18
+ // eslint-disable-next-line no-unused-vars
19
+ pkg,
20
+ // eslint-disable-next-line no-unused-vars
21
+ pluginType,
22
+ // eslint-disable-next-line no-unused-vars
23
+ key) {}
18
24
  const validatePluginName = (pluginType, key) => {
19
25
  return val => {
20
26
  // allow plugin spread...
@@ -867,6 +867,7 @@ class BundleGraph {
867
867
  if (bundleHasReference(descendant)) {
868
868
  isReferenced = true;
869
869
  actions.stop();
870
+ return;
870
871
  }
871
872
  }, referencer);
872
873
  return isReferenced;
@@ -925,6 +926,7 @@ class BundleGraph {
925
926
  let childBundles = this.getBundlesInBundleGroup(node.value);
926
927
  if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
927
928
  actions.skipChildren();
929
+ return;
928
930
  }
929
931
  }
930
932
  }, [bundleGraphEdgeTypes.references, bundleGraphEdgeTypes.bundle]);
@@ -413,9 +413,10 @@ class PackagerRunner {
413
413
  inlineSources = this.options.mode === 'production';
414
414
  }
415
415
  }
416
+ let mapFilename = fullPath + '.map';
416
417
  let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
417
418
  let stringified = await map.stringify({
418
- file: _path().default.basename(fullPath + '.map'),
419
+ file: _path().default.basename(mapFilename),
419
420
  // $FlowFixMe
420
421
  fs: this.options.inputFS,
421
422
  rootDir: this.options.projectRoot,
@@ -703,8 +703,7 @@ class RequestGraph extends _graph().ContentGraph {
703
703
  //
704
704
  // Currently create events can invalidate a large number of nodes due to
705
705
  // "create above" invalidations.
706
- const isConfigKeyChange = (0, _featureFlags().getFeatureFlag)('granularTsConfigInvalidation') || type === 'delete' || type === 'update';
707
- if (configKeyNodes && isConfigKeyChange) {
706
+ if (configKeyNodes) {
708
707
  for (let nodeId of configKeyNodes) {
709
708
  let isInvalid = type === 'delete';
710
709
  if (type !== 'delete') {
@@ -723,7 +722,8 @@ class RequestGraph extends _graph().ContentGraph {
723
722
  }
724
723
  }
725
724
  const invalidationsAfter = this.getInvalidNodeCount();
726
- invalidationsByPath.set(_path, (invalidationsByPath.get(_path) ?? 0) + (invalidationsAfter - invalidationsBefore));
725
+ const invalidationsForEvent = invalidationsAfter - invalidationsBefore;
726
+ invalidationsByPath.set(_path, (invalidationsByPath.get(_path) ?? 0) + invalidationsForEvent);
727
727
  }
728
728
  if ((0, _featureFlags().getFeatureFlag)('fixQuadraticCacheInvalidation')) {
729
729
  cleanUpOrphans(this);
@@ -780,6 +780,9 @@ class RequestTracker {
780
780
 
781
781
  // TODO: refactor (abortcontroller should be created by RequestTracker)
782
782
  setSignal(signal) {
783
+ if ((0, _featureFlags().getFeatureFlag)('fixBuildAbortCorruption')) {
784
+ return;
785
+ }
783
786
  this.signal = signal;
784
787
  }
785
788
  startRequest(request) {
@@ -920,7 +923,9 @@ class RequestTracker {
920
923
  options: this.options,
921
924
  rustAtlaspack: this.rustAtlaspack
922
925
  });
923
- (0, _utils2.assertSignalNotAborted)(this.signal);
926
+ if (!(0, _featureFlags().getFeatureFlag)('fixBuildAbortCorruption')) {
927
+ (0, _utils2.assertSignalNotAborted)(this.signal);
928
+ }
924
929
  this.completeRequest(requestNodeId);
925
930
  deferred.resolve(true);
926
931
  return result;
@@ -958,40 +963,41 @@ class RequestTracker {
958
963
  }
959
964
  createAPI(requestId, previousInvalidations) {
960
965
  let subRequestContentKeys = new Set();
961
- return {
962
- api: {
963
- invalidateOnFileCreate: input => this.graph.invalidateOnFileCreate(requestId, input),
964
- invalidateOnConfigKeyChange: (filePath, configKey, contentHash) => this.graph.invalidateOnConfigKeyChange(requestId, filePath, configKey, contentHash),
965
- invalidateOnFileDelete: filePath => this.graph.invalidateOnFileDelete(requestId, filePath),
966
- invalidateOnFileUpdate: filePath => this.graph.invalidateOnFileUpdate(requestId, filePath),
967
- invalidateOnStartup: () => this.graph.invalidateOnStartup(requestId),
968
- invalidateOnBuild: () => this.graph.invalidateOnBuild(requestId),
969
- invalidateOnEnvChange: env => this.graph.invalidateOnEnvChange(requestId, env, this.options.env[env]),
970
- invalidateOnOptionChange: option => this.graph.invalidateOnOptionChange(requestId, option, this.options[option]),
971
- getInvalidations: () => previousInvalidations,
972
- storeResult: (result, cacheKey) => {
973
- this.storeResult(requestId, result, cacheKey);
974
- },
975
- getSubRequests: () => this.graph.getSubRequests(requestId),
976
- getInvalidSubRequests: () => this.graph.getInvalidSubRequests(requestId),
977
- getPreviousResult: ifMatch => {
978
- var _this$graph$getNode;
979
- let contentKey = (0, _nullthrows().default)((_this$graph$getNode = this.graph.getNode(requestId)) === null || _this$graph$getNode === void 0 ? void 0 : _this$graph$getNode.id);
980
- return this.getRequestResult(contentKey, ifMatch);
981
- },
982
- getRequestResult: id => this.getRequestResult(id),
983
- canSkipSubrequest: contentKey => {
984
- if (this.graph.hasContentKey(contentKey) && this.hasValidResult(this.graph.getNodeIdByContentKey(contentKey))) {
985
- subRequestContentKeys.add(contentKey);
986
- return true;
987
- }
988
- return false;
989
- },
990
- runRequest: (subRequest, opts) => {
991
- subRequestContentKeys.add(subRequest.id);
992
- return this.runRequest(subRequest, opts);
966
+ let api = {
967
+ invalidateOnFileCreate: input => this.graph.invalidateOnFileCreate(requestId, input),
968
+ invalidateOnConfigKeyChange: (filePath, configKey, contentHash) => this.graph.invalidateOnConfigKeyChange(requestId, filePath, configKey, contentHash),
969
+ invalidateOnFileDelete: filePath => this.graph.invalidateOnFileDelete(requestId, filePath),
970
+ invalidateOnFileUpdate: filePath => this.graph.invalidateOnFileUpdate(requestId, filePath),
971
+ invalidateOnStartup: () => this.graph.invalidateOnStartup(requestId),
972
+ invalidateOnBuild: () => this.graph.invalidateOnBuild(requestId),
973
+ invalidateOnEnvChange: env => this.graph.invalidateOnEnvChange(requestId, env, this.options.env[env]),
974
+ invalidateOnOptionChange: option => this.graph.invalidateOnOptionChange(requestId, option, this.options[option]),
975
+ getInvalidations: () => previousInvalidations,
976
+ storeResult: (result, cacheKey) => {
977
+ this.storeResult(requestId, result, cacheKey);
978
+ },
979
+ getSubRequests: () => this.graph.getSubRequests(requestId),
980
+ getInvalidSubRequests: () => this.graph.getInvalidSubRequests(requestId),
981
+ getPreviousResult: ifMatch => {
982
+ var _this$graph$getNode;
983
+ let contentKey = (0, _nullthrows().default)((_this$graph$getNode = this.graph.getNode(requestId)) === null || _this$graph$getNode === void 0 ? void 0 : _this$graph$getNode.id);
984
+ return this.getRequestResult(contentKey, ifMatch);
985
+ },
986
+ getRequestResult: id => this.getRequestResult(id),
987
+ canSkipSubrequest: contentKey => {
988
+ if (this.graph.hasContentKey(contentKey) && this.hasValidResult(this.graph.getNodeIdByContentKey(contentKey))) {
989
+ subRequestContentKeys.add(contentKey);
990
+ return true;
993
991
  }
992
+ return false;
994
993
  },
994
+ runRequest: (subRequest, opts) => {
995
+ subRequestContentKeys.add(subRequest.id);
996
+ return this.runRequest(subRequest, opts);
997
+ }
998
+ };
999
+ return {
1000
+ api,
995
1001
  subRequestContentKeys
996
1002
  };
997
1003
  }
@@ -1143,7 +1149,8 @@ function getWatcherOptions({
1143
1149
  watchDir,
1144
1150
  watchBackend
1145
1151
  }) {
1146
- const uniqueDirs = [...new Set([...watchIgnore, ...['.git', '.hg'], cacheDir])];
1152
+ const vcsDirs = ['.git', '.hg'];
1153
+ const uniqueDirs = [...new Set([...watchIgnore, ...vcsDirs, cacheDir])];
1147
1154
  const ignore = uniqueDirs.map(dir => _path2().default.resolve(watchDir, dir));
1148
1155
  return {
1149
1156
  ignore,
@@ -1337,13 +1344,15 @@ async function invalidateRequestGraph(requestGraph, options, events) {
1337
1344
  const invalidatedCount = invalidations.reduce((acc, invalidation) => acc + invalidation.count, 0);
1338
1345
  const requestCount = requestGraph.nodes.reduce((acc, node) => acc + ((node === null || node === void 0 ? void 0 : node.type) === REQUEST ? 1 : 0), 0);
1339
1346
  const nodeCount = requestGraph.nodes.length;
1347
+ const nodeInvalidationRatio = invalidatedCount / nodeCount;
1348
+ const requestInvalidationRatio = invalidatedCount / requestCount;
1340
1349
  return {
1341
1350
  invalidations,
1342
1351
  nodeCount,
1343
1352
  requestCount,
1344
1353
  invalidatedCount,
1345
- nodeInvalidationRatio: invalidatedCount / nodeCount,
1346
- requestInvalidationRatio: invalidatedCount / requestCount
1354
+ nodeInvalidationRatio,
1355
+ requestInvalidationRatio
1347
1356
  };
1348
1357
  }
1349
1358
  /**
@@ -173,12 +173,12 @@ class Transformation {
173
173
  });
174
174
 
175
175
  // Prefer `isSource` originating from the AssetRequest.
176
-
176
+ let isSource = isSourceOverride ?? summarizedIsSource;
177
177
  return new _UncommittedAsset.default({
178
178
  value: (0, _assetUtils.createAsset)(this.options.projectRoot, {
179
179
  code,
180
180
  filePath,
181
- isSource: isSourceOverride ?? summarizedIsSource,
181
+ isSource,
182
182
  type: _path().default.extname((0, _projectPath.fromProjectPathRelative)(filePath)).slice(1),
183
183
  pipeline,
184
184
  env,
@@ -44,13 +44,13 @@ class Environment {
44
44
 
45
45
  // TODO
46
46
  // eslint-disable-next-line no-unused-vars
47
- matchesEngines() {
47
+ matchesEngines(minVersions, defaultValue) {
48
48
  return true;
49
49
  }
50
50
 
51
51
  // TODO
52
52
  // eslint-disable-next-line no-unused-vars
53
- supports() {
53
+ supports(feature, defaultValue) {
54
54
  return true;
55
55
  }
56
56
  }
@@ -126,32 +126,32 @@ class MutableAsset {
126
126
  }
127
127
 
128
128
  // eslint-disable-next-line no-unused-vars
129
- addDependency() {
129
+ addDependency(options) {
130
130
  throw new Error('MutableAsset.addDependency()');
131
131
  }
132
132
 
133
133
  // eslint-disable-next-line no-unused-vars
134
- addURLDependency() {
134
+ addURLDependency(url, opts) {
135
135
  throw new Error('MutableAsset.addURLDependency()');
136
136
  }
137
137
 
138
138
  // eslint-disable-next-line no-unused-vars
139
- setEnvironment() {
139
+ setEnvironment(opts) {
140
140
  throw new Error('MutableAsset.setEnvironment()');
141
141
  }
142
142
 
143
143
  // eslint-disable-next-line no-unused-vars
144
- invalidateOnFileChange() {
144
+ invalidateOnFileChange(invalidation) {
145
145
  // TODO: Forward invalidations to Rust
146
146
  }
147
147
 
148
148
  // eslint-disable-next-line no-unused-vars
149
- invalidateOnFileCreate() {
149
+ invalidateOnFileCreate(invalidation) {
150
150
  // TODO: Forward invalidations to Rust
151
151
  }
152
152
 
153
153
  // eslint-disable-next-line no-unused-vars
154
- invalidateOnEnvChange() {
154
+ invalidateOnEnvChange(invalidation) {
155
155
  // TODO: Forward invalidations to Rust
156
156
  }
157
157
  invalidateOnStartup() {
@@ -40,21 +40,21 @@ class PluginConfig {
40
40
  }
41
41
 
42
42
  // eslint-disable-next-line no-unused-vars
43
- invalidateOnFileChange() {}
43
+ invalidateOnFileChange(filePath) {}
44
44
 
45
45
  // eslint-disable-next-line no-unused-vars
46
- invalidateOnFileCreate() {}
46
+ invalidateOnFileCreate(invalidations) {}
47
47
 
48
48
  // eslint-disable-next-line no-unused-vars
49
- invalidateOnEnvChange() {}
49
+ invalidateOnEnvChange(invalidation) {}
50
50
  invalidateOnStartup() {}
51
51
  invalidateOnBuild() {}
52
52
 
53
53
  // eslint-disable-next-line no-unused-vars
54
- addDevDependency() {}
54
+ addDevDependency(options) {}
55
55
 
56
56
  // eslint-disable-next-line no-unused-vars
57
- setCacheKey() {}
57
+ setCacheKey(key) {}
58
58
  getConfig(
59
59
  // eslint-disable-next-line no-unused-vars
60
60
  filePaths,
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ if (process.env.ATLASPACK_BUILD_ENV !== 'production' || process.env.ATLASPACK_SELF_BUILD) {
4
+ require('@atlaspack/babel-register');
5
+ }
3
6
  require('./worker');
@@ -47,7 +47,7 @@ const TYPE_COLORS = {
47
47
  };
48
48
  async function dumpGraphToGraphViz(graph, name, edgeTypes) {
49
49
  var _globalThis$ATLASPACK;
50
- if ("production" === 'production' && !process.env.ATLASPACK_BUILD_REPL) {
50
+ if (process.env.ATLASPACK_BUILD_ENV === 'production' && !process.env.ATLASPACK_BUILD_REPL) {
51
51
  return;
52
52
  }
53
53
  let mode = process.env.ATLASPACK_BUILD_REPL ? // $FlowFixMe
package/lib/index.js CHANGED
@@ -4,13 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
+ EnvironmentManager: true,
7
8
  Atlaspack: true,
8
9
  Parcel: true,
9
10
  BuildError: true,
10
11
  createWorkerFarm: true,
11
12
  INTERNAL_RESOLVE: true,
12
- INTERNAL_TRANSFORM: true
13
+ INTERNAL_TRANSFORM: true,
14
+ WORKER_PATH: true,
15
+ ATLASPACK_VERSION: true,
16
+ resolveOptions: true
13
17
  };
18
+ Object.defineProperty(exports, "ATLASPACK_VERSION", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _constants.ATLASPACK_VERSION;
22
+ }
23
+ });
14
24
  Object.defineProperty(exports, "Atlaspack", {
15
25
  enumerable: true,
16
26
  get: function () {
@@ -23,6 +33,7 @@ Object.defineProperty(exports, "BuildError", {
23
33
  return _Atlaspack.BuildError;
24
34
  }
25
35
  });
36
+ exports.EnvironmentManager = void 0;
26
37
  Object.defineProperty(exports, "INTERNAL_RESOLVE", {
27
38
  enumerable: true,
28
39
  get: function () {
@@ -41,6 +52,12 @@ Object.defineProperty(exports, "Parcel", {
41
52
  return _Atlaspack.default;
42
53
  }
43
54
  });
55
+ Object.defineProperty(exports, "WORKER_PATH", {
56
+ enumerable: true,
57
+ get: function () {
58
+ return _Atlaspack.WORKER_PATH;
59
+ }
60
+ });
44
61
  Object.defineProperty(exports, "createWorkerFarm", {
45
62
  enumerable: true,
46
63
  get: function () {
@@ -53,7 +70,17 @@ Object.defineProperty(exports, "default", {
53
70
  return _Atlaspack.default;
54
71
  }
55
72
  });
73
+ Object.defineProperty(exports, "resolveOptions", {
74
+ enumerable: true,
75
+ get: function () {
76
+ return _resolveOptions.default;
77
+ }
78
+ });
79
+ var EnvironmentManager = _interopRequireWildcard(require("./EnvironmentManager"));
80
+ exports.EnvironmentManager = EnvironmentManager;
56
81
  var _Atlaspack = _interopRequireWildcard(require("./Atlaspack"));
82
+ var _constants = require("./constants");
83
+ var _resolveOptions = _interopRequireDefault(require("./resolveOptions"));
57
84
  var _atlaspackV = require("./atlaspack-v3");
58
85
  Object.keys(_atlaspackV).forEach(function (key) {
59
86
  if (key === "default" || key === "__esModule") return;
@@ -66,5 +93,6 @@ Object.keys(_atlaspackV).forEach(function (key) {
66
93
  }
67
94
  });
68
95
  });
96
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
69
97
  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
98
  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; }
@@ -28,13 +28,6 @@ function _utils() {
28
28
  }
29
29
  var _Environment = _interopRequireDefault(require("./Environment"));
30
30
  var _projectPath = require("../projectPath");
31
- function _featureFlags() {
32
- const data = require("@atlaspack/feature-flags");
33
- _featureFlags = function () {
34
- return data;
35
- };
36
- return data;
37
- }
38
31
  var _EnvironmentManager = require("../EnvironmentManager");
39
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
33
  const internalConfigToConfig = new (_utils().DefaultWeakMap)(() => new WeakMap());
@@ -284,7 +277,7 @@ class PublicConfig {
284
277
  return this.#pkg;
285
278
  }
286
279
  let pkgConfig = await this.getConfig(['package.json'], {
287
- readTracking: (0, _featureFlags().getFeatureFlag)('granularTsConfigInvalidation')
280
+ readTracking: true
288
281
  });
289
282
  if (!pkgConfig) {
290
283
  return null;
@@ -27,6 +27,13 @@ var _assetUtils = require("../assetUtils");
27
27
  var _utils = require("../utils");
28
28
  var _projectPath = require("../projectPath");
29
29
  var _RequestTracker = require("../RequestTracker");
30
+ function _featureFlags() {
31
+ const data = require("@atlaspack/feature-flags");
32
+ _featureFlags = function () {
33
+ return data;
34
+ };
35
+ return data;
36
+ }
30
37
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
38
  // A cache of dev dep requests keyed by invalidations.
32
39
  // If the package manager returns the same invalidation object, then
@@ -89,7 +96,21 @@ async function createDevDependency(opts, requestDevDeps, options) {
89
96
  return devDepRequest;
90
97
  }
91
98
  async function getDevDepRequests(api) {
92
- let previousDevDepRequests = new Map(await Promise.all(api.getSubRequests().filter(req => req.requestType === _RequestTracker.requestTypes.dev_dep_request).map(async req => [req.id, (0, _nullthrows().default)(await api.getRequestResult(req.id))])));
99
+ async function getPreviousDevDepRequests() {
100
+ if ((0, _featureFlags().getFeatureFlag)('fixBuildAbortCorruption')) {
101
+ const allDevDepRequests = await Promise.all(api.getSubRequests().filter(req => req.requestType === _RequestTracker.requestTypes.dev_dep_request).map(async req => [req.id, await api.getRequestResult(req.id)]));
102
+ const nonNullDevDepRequests = [];
103
+ for (const [id, result] of allDevDepRequests) {
104
+ if (result != null) {
105
+ nonNullDevDepRequests.push([id, result]);
106
+ }
107
+ }
108
+ return new Map(nonNullDevDepRequests);
109
+ } else {
110
+ return new Map(await Promise.all(api.getSubRequests().filter(req => req.requestType === _RequestTracker.requestTypes.dev_dep_request).map(async req => [req.id, (0, _nullthrows().default)(await api.getRequestResult(req.id))])));
111
+ }
112
+ }
113
+ const previousDevDepRequests = await getPreviousDevDepRequests();
93
114
  return {
94
115
  devDeps: new Map([...previousDevDepRequests.entries()].filter(([id]) => api.canSkipSubrequest(id)).map(([, req]) => [`${req.specifier}:${(0, _projectPath.fromProjectPathRelative)(req.resolveFrom)}`, req.hash])),
95
116
  invalidDevDeps: await Promise.all([...previousDevDepRequests.entries()].filter(([id]) => !api.canSkipSubrequest(id)).flatMap(([, req]) => {
@@ -26,6 +26,13 @@ function _logger() {
26
26
  };
27
27
  return data;
28
28
  }
29
+ function _featureFlags() {
30
+ const data = require("@atlaspack/feature-flags");
31
+ _featureFlags = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
29
36
  function _nullthrows() {
30
37
  const data = _interopRequireDefault(require("nullthrows"));
31
38
  _nullthrows = function () {
@@ -259,6 +266,9 @@ class ResolverRunner {
259
266
  }
260
267
  if (result.priority != null) {
261
268
  dependency.priority = _types.Priority[result.priority];
269
+ if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
270
+ dependency.resolverPriority = dependency.priority;
271
+ }
262
272
  }
263
273
  if (result.invalidateOnEnvChange) {
264
274
  invalidateOnEnvChange.push(...result.invalidateOnEnvChange);
@@ -139,7 +139,7 @@ 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 = function createCache() {
142
+ function createCache() {
143
143
  if (initialOptions.cache) {
144
144
  return initialOptions.cache;
145
145
  }
@@ -150,7 +150,8 @@ async function resolveOptions(initialOptions) {
150
150
  }
151
151
  }
152
152
  return new (_cache().LMDBLiteCache)(cacheDir);
153
- }();
153
+ }
154
+ let cache = createCache();
154
155
  let mode = initialOptions.mode ?? 'development';
155
156
  let shouldOptimize = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau = initialOptions.defaultTargetOptions) === null || _initialOptions$defau === void 0 ? void 0 : _initialOptions$defau.shouldOptimize) ?? mode === 'production';
156
157
  let publicUrl = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau2 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau2 === void 0 ? void 0 : _initialOptions$defau2.publicUrl) ?? '/';
package/lib/worker.js CHANGED
@@ -172,7 +172,24 @@ async function childInit() {
172
172
  await (_rust().init === null || _rust().init === void 0 ? void 0 : (0, _rust().init)());
173
173
  }
174
174
  const PKG_RE = /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/;
175
- function invalidateRequireCache() {
175
+ function invalidateRequireCache(workerApi, file) {
176
+ if (process.env.ATLASPACK_BUILD_ENV === 'test') {
177
+ // Delete this module and all children in the same node_modules folder
178
+ let module = require.cache[file];
179
+ if (module) {
180
+ var _file$match;
181
+ delete require.cache[file];
182
+ let pkg = (_file$match = file.match(PKG_RE)) === null || _file$match === void 0 ? void 0 : _file$match[1];
183
+ for (let child of module.children) {
184
+ var _child$id$match;
185
+ if (pkg === ((_child$id$match = child.id.match(PKG_RE)) === null || _child$id$match === void 0 ? void 0 : _child$id$match[1])) {
186
+ invalidateRequireCache(workerApi, child.id);
187
+ }
188
+ }
189
+ }
190
+ atlaspackConfigCache.clear();
191
+ return;
192
+ }
176
193
  throw new Error('invalidateRequireCache is only for tests');
177
194
  }
178
195
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.16.2-dev.73+84eec3484",
3
+ "version": "2.16.2-dev.93+207d003c0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,21 +21,21 @@
21
21
  "check-ts": "tsc --noEmit index.d.ts"
22
22
  },
23
23
  "dependencies": {
24
- "@atlaspack/build-cache": "2.13.3-dev.141+84eec3484",
25
- "@atlaspack/cache": "3.1.1-dev.73+84eec3484",
26
- "@atlaspack/diagnostic": "2.14.1-dev.141+84eec3484",
27
- "@atlaspack/events": "2.14.1-dev.141+84eec3484",
28
- "@atlaspack/feature-flags": "2.14.1-dev.141+84eec3484",
29
- "@atlaspack/fs": "2.14.5-dev.73+84eec3484",
30
- "@atlaspack/graph": "3.4.1-dev.141+84eec3484",
31
- "@atlaspack/logger": "2.14.5-dev.73+84eec3484",
32
- "@atlaspack/package-manager": "2.14.5-dev.73+84eec3484",
33
- "@atlaspack/plugin": "2.14.5-dev.73+84eec3484",
34
- "@atlaspack/profiler": "2.14.1-dev.141+84eec3484",
35
- "@atlaspack/rust": "3.2.1-dev.73+84eec3484",
36
- "@atlaspack/types": "2.14.5-dev.73+84eec3484",
37
- "@atlaspack/utils": "2.14.5-dev.73+84eec3484",
38
- "@atlaspack/workers": "2.14.5-dev.73+84eec3484",
24
+ "@atlaspack/build-cache": "2.13.3-dev.161+207d003c0",
25
+ "@atlaspack/cache": "3.1.1-dev.93+207d003c0",
26
+ "@atlaspack/diagnostic": "2.14.1-dev.161+207d003c0",
27
+ "@atlaspack/events": "2.14.1-dev.161+207d003c0",
28
+ "@atlaspack/feature-flags": "2.14.1-dev.161+207d003c0",
29
+ "@atlaspack/fs": "2.14.5-dev.93+207d003c0",
30
+ "@atlaspack/graph": "3.4.1-dev.161+207d003c0",
31
+ "@atlaspack/logger": "2.14.5-dev.93+207d003c0",
32
+ "@atlaspack/package-manager": "2.14.5-dev.93+207d003c0",
33
+ "@atlaspack/plugin": "2.14.5-dev.93+207d003c0",
34
+ "@atlaspack/profiler": "2.14.1-dev.161+207d003c0",
35
+ "@atlaspack/rust": "3.2.1-dev.93+207d003c0",
36
+ "@atlaspack/types": "2.14.5-dev.93+207d003c0",
37
+ "@atlaspack/utils": "2.14.5-dev.93+207d003c0",
38
+ "@atlaspack/workers": "2.14.5-dev.93+207d003c0",
39
39
  "@mischnic/json-sourcemap": "^0.1.0",
40
40
  "@parcel/source-map": "^2.1.1",
41
41
  "base-x": "^3.0.8",
@@ -56,20 +56,9 @@
56
56
  "rfdc": "1",
57
57
  "tempy": "^0.2.1"
58
58
  },
59
- "exports": {
60
- "./*": "./*",
61
- ".": {
62
- "types": "./index.d.ts",
63
- "default": "./lib/index.js"
64
- },
65
- "./worker": {
66
- "@atlaspack::sources": "./src/worker.js",
67
- "default": "./lib/worker.js"
68
- }
69
- },
70
59
  "browser": {
71
60
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
72
61
  },
73
62
  "type": "commonjs",
74
- "gitHead": "84eec348413c647de4872f902c4bc8ff54c347f3"
63
+ "gitHead": "207d003c0f1d4ffa6a1c52d2f8841d998616c523"
75
64
  }
package/src/AssetGraph.js CHANGED
@@ -538,6 +538,19 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
538
538
  ...depNode.value.meta,
539
539
  ...existing.value.resolverMeta,
540
540
  };
541
+
542
+ if (getFeatureFlag('hmrImprovements')) {
543
+ depNode.value.resolverMeta = existing.value.resolverMeta;
544
+ }
545
+ }
546
+ if (getFeatureFlag('hmrImprovements')) {
547
+ if (
548
+ existing?.type === 'dependency' &&
549
+ existing.value.resolverPriority != null
550
+ ) {
551
+ depNode.value.priority = existing.value.resolverPriority;
552
+ depNode.value.resolverPriority = existing.value.resolverPriority;
553
+ }
541
554
  }
542
555
  let dependentAsset = dependentAssets.find(
543
556
  (a) => a.uniqueKey === dep.specifier,
@@ -1123,11 +1123,7 @@ export class RequestGraph extends ContentGraph<
1123
1123
  //
1124
1124
  // Currently create events can invalidate a large number of nodes due to
1125
1125
  // "create above" invalidations.
1126
- const isConfigKeyChange =
1127
- getFeatureFlag('granularTsConfigInvalidation') ||
1128
- type === 'delete' ||
1129
- type === 'update';
1130
- if (configKeyNodes && isConfigKeyChange) {
1126
+ if (configKeyNodes) {
1131
1127
  for (let nodeId of configKeyNodes) {
1132
1128
  let isInvalid = type === 'delete';
1133
1129
 
@@ -1239,6 +1235,9 @@ export default class RequestTracker {
1239
1235
 
1240
1236
  // TODO: refactor (abortcontroller should be created by RequestTracker)
1241
1237
  setSignal(signal?: AbortSignal) {
1238
+ if (getFeatureFlag('fixBuildAbortCorruption')) {
1239
+ return;
1240
+ }
1242
1241
  this.signal = signal;
1243
1242
  }
1244
1243
 
@@ -1422,7 +1421,10 @@ export default class RequestTracker {
1422
1421
  rustAtlaspack: this.rustAtlaspack,
1423
1422
  });
1424
1423
 
1425
- assertSignalNotAborted(this.signal);
1424
+ if (!getFeatureFlag('fixBuildAbortCorruption')) {
1425
+ assertSignalNotAborted(this.signal);
1426
+ }
1427
+
1426
1428
  this.completeRequest(requestNodeId);
1427
1429
 
1428
1430
  deferred.resolve(true);
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // @flow
2
+ import * as EnvironmentManager from './EnvironmentManager';
2
3
 
3
4
  export {
4
5
  default,
@@ -8,6 +9,9 @@ export {
8
9
  createWorkerFarm,
9
10
  INTERNAL_RESOLVE,
10
11
  INTERNAL_TRANSFORM,
12
+ WORKER_PATH,
11
13
  } from './Atlaspack';
12
-
14
+ export {ATLASPACK_VERSION} from './constants';
15
+ export {default as resolveOptions} from './resolveOptions';
13
16
  export * from './atlaspack-v3';
17
+ export {EnvironmentManager};
@@ -20,7 +20,6 @@ import {
20
20
  } from '@atlaspack/utils';
21
21
  import Environment from './Environment';
22
22
  import {fromProjectPath, toProjectPath} from '../projectPath';
23
- import {getFeatureFlag} from '@atlaspack/feature-flags';
24
23
  import {fromEnvironmentId} from '../EnvironmentManager';
25
24
 
26
25
  const internalConfigToConfig: DefaultWeakMap<
@@ -362,7 +361,7 @@ export default class PublicConfig implements IConfig {
362
361
  }
363
362
 
364
363
  let pkgConfig = await this.getConfig<PackageJSON>(['package.json'], {
365
- readTracking: getFeatureFlag('granularTsConfigInvalidation'),
364
+ readTracking: true,
366
365
  });
367
366
  if (!pkgConfig) {
368
367
  return null;
@@ -1,4 +1,5 @@
1
- // @flow
1
+ // @flow strict-local
2
+
2
3
  import type {
3
4
  DependencySpecifier,
4
5
  SemverRange,
@@ -24,6 +25,7 @@ import {
24
25
  toProjectPath,
25
26
  } from '../projectPath';
26
27
  import {requestTypes} from '../RequestTracker';
28
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
27
29
 
28
30
  // A cache of dev dep requests keyed by invalidations.
29
31
  // If the package manager returns the same invalidation object, then
@@ -116,17 +118,47 @@ type DevDepRequests = {|
116
118
  export async function getDevDepRequests<TResult: RequestResult>(
117
119
  api: RunAPI<TResult>,
118
120
  ): Promise<DevDepRequests> {
119
- let previousDevDepRequests: Map<string, DevDepRequestResult> = new Map(
120
- await Promise.all(
121
- api
122
- .getSubRequests()
123
- .filter((req) => req.requestType === requestTypes.dev_dep_request)
124
- .map(async (req) => [
125
- req.id,
126
- nullthrows(await api.getRequestResult<DevDepRequestResult>(req.id)),
127
- ]),
128
- ),
129
- );
121
+ async function getPreviousDevDepRequests() {
122
+ if (getFeatureFlag('fixBuildAbortCorruption')) {
123
+ const allDevDepRequests = await Promise.all(
124
+ api
125
+ .getSubRequests()
126
+ .filter((req) => req.requestType === requestTypes.dev_dep_request)
127
+ .map(
128
+ async (
129
+ req,
130
+ ): Promise<[string, DevDepRequestResult | null | void]> => [
131
+ req.id,
132
+ await api.getRequestResult<DevDepRequestResult>(req.id),
133
+ ],
134
+ ),
135
+ );
136
+ const nonNullDevDepRequests = [];
137
+ for (const [id, result] of allDevDepRequests) {
138
+ if (result != null) {
139
+ nonNullDevDepRequests.push([id, result]);
140
+ }
141
+ }
142
+
143
+ return new Map(nonNullDevDepRequests);
144
+ } else {
145
+ return new Map(
146
+ await Promise.all(
147
+ api
148
+ .getSubRequests()
149
+ .filter((req) => req.requestType === requestTypes.dev_dep_request)
150
+ .map(async (req) => [
151
+ req.id,
152
+ nullthrows(
153
+ await api.getRequestResult<DevDepRequestResult>(req.id),
154
+ ),
155
+ ]),
156
+ ),
157
+ );
158
+ }
159
+ }
160
+
161
+ const previousDevDepRequests = await getPreviousDevDepRequests();
130
162
 
131
163
  return {
132
164
  devDeps: new Map(
@@ -24,6 +24,7 @@ import ThrowableDiagnostic, {
24
24
  md,
25
25
  } from '@atlaspack/diagnostic';
26
26
  import {PluginLogger} from '@atlaspack/logger';
27
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
27
28
  import nullthrows from 'nullthrows';
28
29
  import path from 'path';
29
30
  import {normalizePath} from '@atlaspack/utils';
@@ -320,6 +321,9 @@ export class ResolverRunner {
320
321
 
321
322
  if (result.priority != null) {
322
323
  dependency.priority = Priority[result.priority];
324
+ if (getFeatureFlag('hmrImprovements')) {
325
+ dependency.resolverPriority = dependency.priority;
326
+ }
323
327
  }
324
328
 
325
329
  if (result.invalidateOnEnvChange) {
package/src/types.js CHANGED
@@ -145,6 +145,7 @@ export type Dependency = {|
145
145
  customPackageConditions?: Array<string>,
146
146
  meta: Meta,
147
147
  resolverMeta?: ?Meta,
148
+ resolverPriority?: $Values<typeof Priority>,
148
149
  target: ?Target,
149
150
  sourceAssetId: ?string,
150
151
  sourcePath: ?ProjectPath,