@atlaspack/core 2.17.3 → 2.17.4

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.
@@ -32,6 +32,13 @@ var _Dependency = _interopRequireWildcard(require("./Dependency"));
32
32
  var _Target = require("./Target");
33
33
  var _utils = require("../utils");
34
34
  var _BundleGroup = _interopRequireWildcard(require("./BundleGroup"));
35
+ function _featureFlags() {
36
+ const data = require("@atlaspack/feature-flags");
37
+ _featureFlags = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
35
42
  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); }
36
43
  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; }
37
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -263,11 +270,20 @@ class BundleGraph {
263
270
  }
264
271
  for (let bundle of bundles) {
265
272
  const conditions = bundleConditions.get(bundle.id) ?? new Map();
266
- conditions.set(cond.key, {
267
- bundle,
268
- ifTrueBundles,
269
- ifFalseBundles
270
- });
273
+ const currentCondition = conditions.get(cond.key);
274
+ if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingReporterSameConditionFix')) {
275
+ conditions.set(cond.key, {
276
+ bundle,
277
+ ifTrueBundles: [...((currentCondition === null || currentCondition === void 0 ? void 0 : currentCondition.ifTrueBundles) ?? []), ...ifTrueBundles],
278
+ ifFalseBundles: [...((currentCondition === null || currentCondition === void 0 ? void 0 : currentCondition.ifFalseBundles) ?? []), ...ifFalseBundles]
279
+ });
280
+ } else {
281
+ conditions.set(cond.key, {
282
+ bundle,
283
+ ifTrueBundles,
284
+ ifFalseBundles
285
+ });
286
+ }
271
287
  bundleConditions.set(bundle.id, conditions);
272
288
  }
273
289
  }
@@ -27,6 +27,13 @@ function _utils() {
27
27
  }
28
28
  var _Environment = _interopRequireDefault(require("./Environment"));
29
29
  var _projectPath = require("../projectPath");
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
  const internalConfigToConfig = new (_utils().DefaultWeakMap)(() => new WeakMap());
32
39
  class PublicConfig {
@@ -126,6 +133,27 @@ class PublicConfig {
126
133
  };
127
134
  }
128
135
  }
136
+ if ((0, _featureFlags().getFeatureFlag)('granularTsConfigInvalidation')) {
137
+ const configKey = options === null || options === void 0 ? void 0 : options.configKey;
138
+ if (configKey != null) {
139
+ for (let fileName of fileNames) {
140
+ let config = await this.getConfigFrom(searchPath, [fileName], {
141
+ exclude: true
142
+ });
143
+ if (config && config.contents[configKey]) {
144
+ // Invalidate only when the package key changes
145
+ this.invalidateOnConfigKeyChange(config.filePath, configKey);
146
+ return {
147
+ contents: config.contents[configKey],
148
+ filePath: config.filePath
149
+ };
150
+ }
151
+ }
152
+
153
+ // fall through so that file above invalidations are registered
154
+ }
155
+ }
156
+
129
157
  if (fileNames.length === 0) {
130
158
  return null;
131
159
  }
@@ -26,6 +26,13 @@ function _nullthrows() {
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 _utils() {
30
37
  const data = require("@atlaspack/utils");
31
38
  _utils = function () {
@@ -116,7 +123,12 @@ class AssetGraphBuilder {
116
123
  this.shouldBuildLazily = shouldBuildLazily ?? false;
117
124
  this.lazyIncludes = lazyIncludes ?? [];
118
125
  this.lazyExcludes = lazyExcludes ?? [];
119
- this.cacheKey = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-AssetGraph';
126
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
127
+ const key = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
128
+ this.cacheKey = `AssetGraph/${_constants.ATLASPACK_VERSION}/${options.mode}/${key}`;
129
+ } else {
130
+ this.cacheKey = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-AssetGraph';
131
+ }
120
132
  this.isSingleChangeRebuild = api.getInvalidSubRequests().filter(req => req.requestType === 'asset_request').length === 1;
121
133
  this.queue = new (_utils().PromiseQueue)();
122
134
  assetGraph.onNodeRemoved = nodeId => {
@@ -32,6 +32,13 @@ function _logger() {
32
32
  };
33
33
  return data;
34
34
  }
35
+ function _featureFlags() {
36
+ const data = require("@atlaspack/feature-flags");
37
+ _featureFlags = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
35
42
  function _diagnostic() {
36
43
  const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
37
44
  _diagnostic = function () {
@@ -225,7 +232,12 @@ class BundlerRunner {
225
232
  this.devDepRequests = new Map();
226
233
  this.configs = new Map();
227
234
  this.pluginOptions = new _PluginOptions.default((0, _utils2.optionsProxy)(this.options, api.invalidateOnOptionChange));
228
- this.cacheKey = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-BundleGraph';
235
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
236
+ const key = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
237
+ this.cacheKey = `BundleGraph/${_constants.ATLASPACK_VERSION}/${options.mode}/${key}`;
238
+ } else {
239
+ this.cacheKey = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-BundleGraph';
240
+ }
229
241
  }
230
242
  async loadConfigs() {
231
243
  // Load all configs up front so we can use them in the cache key
@@ -61,6 +61,13 @@ function _profiler() {
61
61
  return data;
62
62
  }
63
63
  var _RequestTracker = require("../RequestTracker");
64
+ function _featureFlags() {
65
+ const data = require("@atlaspack/feature-flags");
66
+ _featureFlags = function () {
67
+ return data;
68
+ };
69
+ return data;
70
+ }
64
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); }
65
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; }
66
73
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -145,8 +152,10 @@ async function run({
145
152
  } = await (0, _DevDepRequest.getDevDepRequests)(api);
146
153
  (0, _DevDepRequest.invalidateDevDeps)(invalidDevDeps, options, config);
147
154
  await writeFiles(contentStream, info, hashRefToNameHash, options, config, outputFS, filePath, writeOptions, devDeps, api);
148
- if (mapKey && bundle.env.sourceMap && !bundle.env.sourceMap.inline && (await options.cache.has(mapKey))) {
149
- await writeFiles((0, _utils().blobToStream)(await options.cache.getBlob(mapKey)), info, hashRefToNameHash, options, config, outputFS, (0, _projectPath.toProjectPathUnsafe)((0, _projectPath.fromProjectPathRelative)(filePath) + '.map'), writeOptions, devDeps, api);
155
+ const hasSourceMap = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? await options.cache.hasLargeBlob(mapKey) : await options.cache.has(mapKey);
156
+ if (mapKey && bundle.env.sourceMap && !bundle.env.sourceMap.inline && hasSourceMap) {
157
+ const mapEntry = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? await options.cache.getLargeBlob(mapKey) : await options.cache.getBlob(mapKey);
158
+ await writeFiles((0, _utils().blobToStream)(mapEntry), info, hashRefToNameHash, options, config, outputFS, (0, _projectPath.toProjectPathUnsafe)((0, _projectPath.fromProjectPathRelative)(filePath) + '.map'), writeOptions, devDeps, api);
150
159
  }
151
160
  let res = {
152
161
  filePath,
@@ -144,8 +144,10 @@ async function resolveOptions(initialOptions) {
144
144
  return initialOptions.cache;
145
145
  }
146
146
  const needsRustLmdbCache = (0, _featureFlags().getFeatureFlag)('atlaspackV3');
147
- if (!needsRustLmdbCache && !(outputFS instanceof _fs().NodeFS)) {
148
- return new (_cache().FSCache)(outputFS, cacheDir);
147
+ if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
148
+ if (!needsRustLmdbCache && !(outputFS instanceof _fs().NodeFS)) {
149
+ return new (_cache().FSCache)(outputFS, cacheDir);
150
+ }
149
151
  }
150
152
  return new (_cache().LMDBLiteCache)(cacheDir);
151
153
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.17.3",
3
+ "version": "2.17.4",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,20 +23,20 @@
23
23
  "dependencies": {
24
24
  "@mischnic/json-sourcemap": "^0.1.0",
25
25
  "@atlaspack/build-cache": "2.13.3",
26
- "@atlaspack/cache": "3.2.3",
26
+ "@atlaspack/cache": "3.2.4",
27
27
  "@atlaspack/diagnostic": "2.14.1",
28
28
  "@atlaspack/events": "2.14.1",
29
- "@atlaspack/feature-flags": "2.15.1",
30
- "@atlaspack/fs": "2.15.3",
31
- "@atlaspack/graph": "3.4.6",
32
- "@atlaspack/logger": "2.14.8",
33
- "@atlaspack/package-manager": "2.14.8",
34
- "@atlaspack/plugin": "2.14.8",
35
- "@atlaspack/profiler": "2.14.6",
36
- "@atlaspack/rust": "3.3.3",
37
- "@atlaspack/types": "2.14.8",
38
- "@atlaspack/utils": "2.14.8",
39
- "@atlaspack/workers": "2.14.8",
29
+ "@atlaspack/feature-flags": "2.16.0",
30
+ "@atlaspack/fs": "2.15.4",
31
+ "@atlaspack/graph": "3.4.7",
32
+ "@atlaspack/logger": "2.14.9",
33
+ "@atlaspack/package-manager": "2.14.9",
34
+ "@atlaspack/plugin": "2.14.9",
35
+ "@atlaspack/profiler": "2.14.7",
36
+ "@atlaspack/rust": "3.3.4",
37
+ "@atlaspack/types": "2.14.9",
38
+ "@atlaspack/utils": "2.14.9",
39
+ "@atlaspack/workers": "2.14.9",
40
40
  "@parcel/source-map": "^2.1.1",
41
41
  "base-x": "^3.0.8",
42
42
  "browserslist": "^4.6.6",
package/src/Atlaspack.js CHANGED
@@ -533,10 +533,11 @@ export default class Atlaspack {
533
533
  nativeInvalid = await this.rustAtlaspack.respondToFsEvents(events);
534
534
  }
535
535
 
536
- let isInvalid = await this.#requestTracker.respondToFSEvents(
537
- events,
538
- Number.POSITIVE_INFINITY,
539
- );
536
+ let {didInvalidate: isInvalid} =
537
+ await this.#requestTracker.respondToFSEvents(
538
+ events,
539
+ Number.POSITIVE_INFINITY,
540
+ );
540
541
 
541
542
  if (
542
543
  (nativeInvalid || isInvalid) &&
@@ -63,6 +63,7 @@ import {getInvalidationId, getInvalidationHash} from './assetUtils';
63
63
  import {optionsProxy} from './utils';
64
64
  import {invalidateDevDeps} from './requests/DevDepRequest';
65
65
  import {tracer, PluginTracer} from '@atlaspack/profiler';
66
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
66
67
 
67
68
  type Opts = {|
68
69
  config: AtlaspackConfig,
@@ -658,6 +659,21 @@ export default class PackagerRunner {
658
659
  this.options,
659
660
  );
660
661
 
662
+ if (getFeatureFlag('cachePerformanceImprovements')) {
663
+ const hash = hashString(
664
+ ATLASPACK_VERSION +
665
+ devDepHashes +
666
+ invalidationHash +
667
+ bundle.target.publicUrl +
668
+ bundleGraph.getHash(bundle) +
669
+ JSON.stringify(configResults) +
670
+ JSON.stringify(globalInfoResults) +
671
+ this.options.mode +
672
+ (this.options.shouldBuildLazily ? 'lazy' : 'eager'),
673
+ );
674
+ return path.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
675
+ }
676
+
661
677
  return hashString(
662
678
  ATLASPACK_VERSION +
663
679
  devDepHashes +
@@ -700,20 +716,27 @@ export default class PackagerRunner {
700
716
  let mapKey = PackagerRunner.getMapKey(cacheKey);
701
717
 
702
718
  let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
703
- let contentExists =
704
- isLargeBlob || (await this.options.cache.has(contentKey));
719
+ let contentExists = getFeatureFlag('cachePerformanceImprovements')
720
+ ? isLargeBlob
721
+ : isLargeBlob || (await this.options.cache.has(contentKey));
705
722
  if (!contentExists) {
706
723
  return null;
707
724
  }
708
725
 
709
- let mapExists = await this.options.cache.has(mapKey);
726
+ let mapExists = getFeatureFlag('cachePerformanceImprovements')
727
+ ? await this.options.cache.hasLargeBlob(mapKey)
728
+ : await this.options.cache.has(mapKey);
710
729
 
711
730
  return {
712
731
  contents: isLargeBlob
713
732
  ? this.options.cache.getStream(contentKey)
714
733
  : blobToStream(await this.options.cache.getBlob(contentKey)),
715
734
  map: mapExists
716
- ? blobToStream(await this.options.cache.getBlob(mapKey))
735
+ ? blobToStream(
736
+ getFeatureFlag('cachePerformanceImprovements')
737
+ ? await this.options.cache.getLargeBlob(mapKey)
738
+ : await this.options.cache.getBlob(mapKey),
739
+ )
717
740
  : null,
718
741
  };
719
742
  }
@@ -727,11 +750,14 @@ export default class PackagerRunner {
727
750
  let size = 0;
728
751
  let hash;
729
752
  let hashReferences = [];
730
- let isLargeBlob = false;
753
+ let isLargeBlob = getFeatureFlag('cachePerformanceImprovements');
731
754
 
732
755
  // TODO: don't replace hash references in binary files??
733
756
  if (contents instanceof Readable) {
734
- isLargeBlob = true;
757
+ if (!getFeatureFlag('cachePerformanceImprovements')) {
758
+ isLargeBlob = true;
759
+ }
760
+
735
761
  let boundaryStr = '';
736
762
  let h = new Hash();
737
763
  await this.options.cache.setStream(
@@ -754,17 +780,32 @@ export default class PackagerRunner {
754
780
  size = buffer.byteLength;
755
781
  hash = hashBuffer(buffer);
756
782
  hashReferences = contents.match(HASH_REF_REGEX) ?? [];
757
- await this.options.cache.setBlob(cacheKeys.content, buffer);
783
+
784
+ if (getFeatureFlag('cachePerformanceImprovements')) {
785
+ await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
786
+ } else {
787
+ await this.options.cache.setBlob(cacheKeys.content, buffer);
788
+ }
758
789
  } else {
759
790
  size = contents.length;
760
791
  hash = hashBuffer(contents);
761
792
  hashReferences = contents.toString().match(HASH_REF_REGEX) ?? [];
762
- await this.options.cache.setBlob(cacheKeys.content, contents);
793
+
794
+ if (getFeatureFlag('cachePerformanceImprovements')) {
795
+ await this.options.cache.setLargeBlob(cacheKeys.content, contents);
796
+ } else {
797
+ await this.options.cache.setBlob(cacheKeys.content, contents);
798
+ }
763
799
  }
764
800
 
765
801
  if (map != null) {
766
- await this.options.cache.setBlob(cacheKeys.map, map);
802
+ if (getFeatureFlag('cachePerformanceImprovements')) {
803
+ await this.options.cache.setLargeBlob(cacheKeys.map, map);
804
+ } else {
805
+ await this.options.cache.setBlob(cacheKeys.map, map);
806
+ }
767
807
  }
808
+
768
809
  let info = {
769
810
  type,
770
811
  size,
@@ -773,19 +814,29 @@ export default class PackagerRunner {
773
814
  cacheKeys,
774
815
  isLargeBlob,
775
816
  };
817
+
776
818
  await this.options.cache.set(cacheKeys.info, info);
777
819
  return info;
778
820
  }
779
821
 
780
822
  static getContentKey(cacheKey: string): string {
823
+ if (getFeatureFlag('cachePerformanceImprovements')) {
824
+ return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/content`;
825
+ }
781
826
  return hashString(`${cacheKey}:content`);
782
827
  }
783
828
 
784
829
  static getMapKey(cacheKey: string): string {
830
+ if (getFeatureFlag('cachePerformanceImprovements')) {
831
+ return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/map`;
832
+ }
785
833
  return hashString(`${cacheKey}:map`);
786
834
  }
787
835
 
788
836
  static getInfoKey(cacheKey: string): string {
837
+ if (getFeatureFlag('cachePerformanceImprovements')) {
838
+ return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/info`;
839
+ }
789
840
  return hashString(`${cacheKey}:info`);
790
841
  }
791
842
  }