@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.
- package/CHANGELOG.md +201 -0
- package/lib/AssetGraph.js +17 -6
- package/lib/Atlaspack.js +24 -5
- package/lib/BundleGraph.js +6 -5
- package/lib/Dependency.js +6 -2
- package/lib/Environment.js +4 -3
- package/lib/EnvironmentManager.js +137 -0
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +52 -15
- package/lib/RequestTracker.js +337 -82
- package/lib/UncommittedAsset.js +20 -2
- package/lib/applyRuntimes.js +2 -1
- package/lib/assetUtils.js +2 -1
- package/lib/atlaspack-v3/worker/worker.js +8 -0
- package/lib/public/Asset.js +3 -2
- package/lib/public/Bundle.js +2 -1
- package/lib/public/BundleGraph.js +21 -5
- package/lib/public/Config.js +98 -3
- package/lib/public/Dependency.js +2 -1
- package/lib/public/MutableBundleGraph.js +2 -1
- package/lib/public/Target.js +2 -1
- package/lib/requests/AssetGraphRequest.js +13 -1
- package/lib/requests/AssetRequest.js +2 -1
- package/lib/requests/BundleGraphRequest.js +13 -1
- package/lib/requests/ConfigRequest.js +27 -4
- package/lib/requests/TargetRequest.js +18 -16
- package/lib/requests/WriteBundleRequest.js +15 -3
- package/lib/requests/WriteBundlesRequest.js +1 -0
- package/lib/resolveOptions.js +5 -6
- package/package.json +22 -18
- package/src/AssetGraph.js +12 -6
- package/src/Atlaspack.js +29 -13
- package/src/BundleGraph.js +13 -8
- package/src/Dependency.js +13 -5
- package/src/Environment.js +8 -5
- package/src/EnvironmentManager.js +145 -0
- package/src/InternalConfig.js +6 -5
- package/src/PackagerRunner.js +72 -20
- package/src/RequestTracker.js +567 -131
- package/src/UncommittedAsset.js +23 -3
- package/src/applyRuntimes.js +6 -1
- package/src/assetUtils.js +4 -3
- package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
- package/src/atlaspack-v3/worker/worker.js +7 -0
- package/src/public/Asset.js +9 -2
- package/src/public/Bundle.js +2 -1
- package/src/public/BundleGraph.js +22 -5
- package/src/public/Config.js +129 -14
- package/src/public/Dependency.js +2 -1
- package/src/public/MutableBundleGraph.js +2 -1
- package/src/public/Target.js +2 -1
- package/src/requests/AssetGraphRequest.js +13 -3
- package/src/requests/AssetRequest.js +2 -1
- package/src/requests/BundleGraphRequest.js +13 -3
- package/src/requests/ConfigRequest.js +33 -9
- package/src/requests/TargetRequest.js +19 -25
- package/src/requests/WriteBundleRequest.js +14 -8
- package/src/requests/WriteBundlesRequest.js +1 -0
- package/src/resolveOptions.js +6 -8
- package/src/types.js +9 -7
- package/test/Environment.test.js +43 -34
- package/test/EnvironmentManager.test.js +192 -0
- package/test/PublicEnvironment.test.js +10 -7
- package/test/RequestTracker.test.js +115 -3
- package/test/public/Config.test.js +108 -0
- package/test/requests/ConfigRequest.test.js +187 -3
- package/test/test-utils.js +4 -9
package/lib/PackagerRunner.js
CHANGED
|
@@ -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
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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 (
|
|
400
|
-
inlineSources =
|
|
401
|
-
} else if (
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|