@atlaspack/core 2.14.1-dev.144 → 2.14.1-dev.146

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/lib/AssetGraph.js +17 -6
  3. package/lib/Atlaspack.js +24 -5
  4. package/lib/BundleGraph.js +6 -5
  5. package/lib/Dependency.js +6 -2
  6. package/lib/Environment.js +4 -3
  7. package/lib/EnvironmentManager.js +137 -0
  8. package/lib/InternalConfig.js +3 -2
  9. package/lib/PackagerRunner.js +52 -15
  10. package/lib/RequestTracker.js +337 -82
  11. package/lib/UncommittedAsset.js +20 -2
  12. package/lib/applyRuntimes.js +2 -1
  13. package/lib/assetUtils.js +2 -1
  14. package/lib/atlaspack-v3/worker/worker.js +8 -0
  15. package/lib/public/Asset.js +3 -2
  16. package/lib/public/Bundle.js +2 -1
  17. package/lib/public/BundleGraph.js +21 -5
  18. package/lib/public/Config.js +98 -3
  19. package/lib/public/Dependency.js +2 -1
  20. package/lib/public/MutableBundleGraph.js +2 -1
  21. package/lib/public/Target.js +2 -1
  22. package/lib/requests/AssetGraphRequest.js +13 -1
  23. package/lib/requests/AssetRequest.js +2 -1
  24. package/lib/requests/BundleGraphRequest.js +13 -1
  25. package/lib/requests/ConfigRequest.js +27 -4
  26. package/lib/requests/TargetRequest.js +18 -16
  27. package/lib/requests/WriteBundleRequest.js +15 -3
  28. package/lib/requests/WriteBundlesRequest.js +1 -0
  29. package/lib/resolveOptions.js +5 -6
  30. package/package.json +22 -18
  31. package/src/AssetGraph.js +12 -6
  32. package/src/Atlaspack.js +29 -13
  33. package/src/BundleGraph.js +13 -8
  34. package/src/Dependency.js +13 -5
  35. package/src/Environment.js +8 -5
  36. package/src/EnvironmentManager.js +145 -0
  37. package/src/InternalConfig.js +6 -5
  38. package/src/PackagerRunner.js +72 -20
  39. package/src/RequestTracker.js +567 -131
  40. package/src/UncommittedAsset.js +23 -3
  41. package/src/applyRuntimes.js +6 -1
  42. package/src/assetUtils.js +4 -3
  43. package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
  44. package/src/atlaspack-v3/worker/worker.js +7 -0
  45. package/src/public/Asset.js +9 -2
  46. package/src/public/Bundle.js +2 -1
  47. package/src/public/BundleGraph.js +22 -5
  48. package/src/public/Config.js +129 -14
  49. package/src/public/Dependency.js +2 -1
  50. package/src/public/MutableBundleGraph.js +2 -1
  51. package/src/public/Target.js +2 -1
  52. package/src/requests/AssetGraphRequest.js +13 -3
  53. package/src/requests/AssetRequest.js +2 -1
  54. package/src/requests/BundleGraphRequest.js +13 -3
  55. package/src/requests/ConfigRequest.js +33 -9
  56. package/src/requests/TargetRequest.js +19 -25
  57. package/src/requests/WriteBundleRequest.js +14 -8
  58. package/src/requests/WriteBundlesRequest.js +1 -0
  59. package/src/resolveOptions.js +6 -8
  60. package/src/types.js +9 -7
  61. package/test/Environment.test.js +43 -34
  62. package/test/EnvironmentManager.test.js +192 -0
  63. package/test/PublicEnvironment.test.js +10 -7
  64. package/test/RequestTracker.test.js +115 -3
  65. package/test/public/Config.test.js +108 -0
  66. package/test/requests/ConfigRequest.test.js +187 -3
  67. package/test/test-utils.js +4 -9
@@ -92,6 +92,14 @@ function _profiler() {
92
92
  };
93
93
  return data;
94
94
  }
95
+ var _EnvironmentManager = require("./EnvironmentManager");
96
+ function _featureFlags() {
97
+ const data = require("@atlaspack/feature-flags");
98
+ _featureFlags = function () {
99
+ return data;
100
+ };
101
+ return data;
102
+ }
95
103
  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); }
96
104
  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; }
97
105
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -390,15 +398,17 @@ class PackagerRunner {
390
398
  let fullPath = (0, _projectPath.fromProjectPath)(this.options.projectRoot, filePath);
391
399
  let sourceRoot = _path().default.relative(_path().default.dirname(fullPath), this.options.projectRoot);
392
400
  let inlineSources = false;
401
+ const bundleEnv = (0, _EnvironmentManager.fromEnvironmentId)(bundle.env);
393
402
  if (bundle.target) {
394
- if (bundle.env.sourceMap && bundle.env.sourceMap.sourceRoot !== undefined) {
395
- sourceRoot = bundle.env.sourceMap.sourceRoot;
396
- } else if (this.options.serveOptions && bundle.target.env.context === 'browser') {
403
+ const bundleTargetEnv = (0, _EnvironmentManager.fromEnvironmentId)(bundle.target.env);
404
+ if (bundleEnv.sourceMap && bundleEnv.sourceMap.sourceRoot !== undefined) {
405
+ sourceRoot = bundleEnv.sourceMap.sourceRoot;
406
+ } else if (this.options.serveOptions && bundleTargetEnv.context === 'browser') {
397
407
  sourceRoot = '/__parcel_source_root';
398
408
  }
399
- if (bundle.env.sourceMap && bundle.env.sourceMap.inlineSources !== undefined) {
400
- inlineSources = bundle.env.sourceMap.inlineSources;
401
- } else if (bundle.target.env.context !== 'node') {
409
+ if (bundleEnv.sourceMap && bundleEnv.sourceMap.inlineSources !== undefined) {
410
+ inlineSources = bundleEnv.sourceMap.inlineSources;
411
+ } else if (bundleTargetEnv.context !== 'node') {
402
412
  // inlining should only happen in production for browser targets by default
403
413
  inlineSources = this.options.mode === 'production';
404
414
  }
@@ -407,7 +417,7 @@ class PackagerRunner {
407
417
  // Set source root to 'atlaspack' so stack traces are clean in Sentry
408
418
  sourceRoot = 'atlaspack';
409
419
  }
410
- let isInlineMap = bundle.env.sourceMap && bundle.env.sourceMap.inline;
420
+ let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
411
421
  let stringified = await map.stringify({
412
422
  file: _path().default.basename(fullPath + '.map'),
413
423
  // $FlowFixMe
@@ -438,6 +448,10 @@ class PackagerRunner {
438
448
  devDepHashes += await this.getDevDepHashes(inlineBundle);
439
449
  }
440
450
  let invalidationHash = await (0, _assetUtils.getInvalidationHash)(invalidations, this.options);
451
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
452
+ const hash = (0, _rust().hashString)(_constants.ATLASPACK_VERSION + devDepHashes + invalidationHash + bundle.target.publicUrl + bundleGraph.getHash(bundle) + JSON.stringify(configResults) + JSON.stringify(globalInfoResults) + this.options.mode + (this.options.shouldBuildLazily ? 'lazy' : 'eager'));
453
+ return _path().default.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
454
+ }
441
455
  return (0, _rust().hashString)(_constants.ATLASPACK_VERSION + devDepHashes + invalidationHash + bundle.target.publicUrl + bundleGraph.getHash(bundle) + JSON.stringify(configResults) + JSON.stringify(globalInfoResults) + this.options.mode + (this.options.shouldBuildLazily ? 'lazy' : 'eager'));
442
456
  }
443
457
  async getDevDepHashes(bundle) {
@@ -461,25 +475,27 @@ class PackagerRunner {
461
475
  let contentKey = PackagerRunner.getContentKey(cacheKey);
462
476
  let mapKey = PackagerRunner.getMapKey(cacheKey);
463
477
  let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
464
- let contentExists = isLargeBlob || (await this.options.cache.has(contentKey));
478
+ let contentExists = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? isLargeBlob : isLargeBlob || (await this.options.cache.has(contentKey));
465
479
  if (!contentExists) {
466
480
  return null;
467
481
  }
468
- let mapExists = await this.options.cache.has(mapKey);
482
+ let mapExists = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? await this.options.cache.hasLargeBlob(mapKey) : await this.options.cache.has(mapKey);
469
483
  return {
470
484
  contents: isLargeBlob ? this.options.cache.getStream(contentKey) : (0, _utils().blobToStream)(await this.options.cache.getBlob(contentKey)),
471
- map: mapExists ? (0, _utils().blobToStream)(await this.options.cache.getBlob(mapKey)) : null
485
+ map: mapExists ? (0, _utils().blobToStream)((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? await this.options.cache.getLargeBlob(mapKey) : await this.options.cache.getBlob(mapKey)) : null
472
486
  };
473
487
  }
474
488
  async writeToCache(cacheKeys, type, contents, map) {
475
489
  let size = 0;
476
490
  let hash;
477
491
  let hashReferences = [];
478
- let isLargeBlob = false;
492
+ let isLargeBlob = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements');
479
493
 
480
494
  // TODO: don't replace hash references in binary files??
481
495
  if (contents instanceof _stream().Readable) {
482
- isLargeBlob = true;
496
+ if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
497
+ isLargeBlob = true;
498
+ }
483
499
  let boundaryStr = '';
484
500
  let h = new (_rust().Hash)();
485
501
  await this.options.cache.setStream(cacheKeys.content, (0, _utils().blobToStream)(contents).pipe(new (_utils().TapStream)(buf => {
@@ -495,15 +511,27 @@ class PackagerRunner {
495
511
  size = buffer.byteLength;
496
512
  hash = (0, _rust().hashBuffer)(buffer);
497
513
  hashReferences = contents.match(_constants.HASH_REF_REGEX) ?? [];
498
- await this.options.cache.setBlob(cacheKeys.content, buffer);
514
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
515
+ await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
516
+ } else {
517
+ await this.options.cache.setBlob(cacheKeys.content, buffer);
518
+ }
499
519
  } else {
500
520
  size = contents.length;
501
521
  hash = (0, _rust().hashBuffer)(contents);
502
522
  hashReferences = contents.toString().match(_constants.HASH_REF_REGEX) ?? [];
503
- await this.options.cache.setBlob(cacheKeys.content, contents);
523
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
524
+ await this.options.cache.setLargeBlob(cacheKeys.content, contents);
525
+ } else {
526
+ await this.options.cache.setBlob(cacheKeys.content, contents);
527
+ }
504
528
  }
505
529
  if (map != null) {
506
- await this.options.cache.setBlob(cacheKeys.map, map);
530
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
531
+ await this.options.cache.setLargeBlob(cacheKeys.map, map);
532
+ } else {
533
+ await this.options.cache.setBlob(cacheKeys.map, map);
534
+ }
507
535
  }
508
536
  let info = {
509
537
  type,
@@ -517,12 +545,21 @@ class PackagerRunner {
517
545
  return info;
518
546
  }
519
547
  static getContentKey(cacheKey) {
548
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
549
+ return `PackagerRunner/${_constants.ATLASPACK_VERSION}/${cacheKey}/content`;
550
+ }
520
551
  return (0, _rust().hashString)(`${cacheKey}:content`);
521
552
  }
522
553
  static getMapKey(cacheKey) {
554
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
555
+ return `PackagerRunner/${_constants.ATLASPACK_VERSION}/${cacheKey}/map`;
556
+ }
523
557
  return (0, _rust().hashString)(`${cacheKey}:map`);
524
558
  }
525
559
  static getInfoKey(cacheKey) {
560
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
561
+ return `PackagerRunner/${_constants.ATLASPACK_VERSION}/${cacheKey}/info`;
562
+ }
526
563
  return (0, _rust().hashString)(`${cacheKey}:info`);
527
564
  }
528
565
  }