@atlaspack/core 2.27.0 → 2.28.0
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 +29 -0
- package/dist/Atlaspack.js +5 -1
- package/dist/BundleGraph.js +105 -0
- package/dist/CommittedAsset.js +1 -1
- package/dist/Transformation.js +3 -2
- package/dist/UncommittedAsset.js +3 -3
- package/dist/assetUtils.js +2 -1
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +1 -1
- package/dist/atlaspack-v3/worker/worker.js +1 -1
- package/dist/public/BundleGraph.js +12 -0
- package/dist/requests/BundleGraphRequest.js +5 -3
- package/dist/resolveOptions.js +1 -0
- package/dist/worker.js +1 -1
- package/lib/Atlaspack.js +5 -1
- package/lib/BundleGraph.js +107 -0
- package/lib/CommittedAsset.js +1 -1
- package/lib/Transformation.js +9 -4
- package/lib/UncommittedAsset.js +3 -3
- package/lib/assetUtils.js +8 -1
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +1 -1
- package/lib/atlaspack-v3/worker/worker.js +1 -1
- package/lib/public/BundleGraph.js +13 -0
- package/lib/requests/BundleGraphRequest.js +4 -2
- package/lib/resolveOptions.js +1 -0
- package/lib/types/BundleGraph.d.ts +2 -0
- package/lib/types/CommittedAsset.d.ts +1 -1
- package/lib/types/PackagerRunner.d.ts +1 -1
- package/lib/types/UncommittedAsset.d.ts +1 -1
- package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +1 -1
- package/lib/types/public/Asset.d.ts +1 -1
- package/lib/types/public/BundleGraph.d.ts +2 -0
- package/lib/types/types.d.ts +1 -0
- package/lib/worker.js +1 -1
- package/package.json +14 -14
- package/src/Atlaspack.ts +6 -2
- package/src/BundleGraph.ts +152 -0
- package/src/CommittedAsset.ts +1 -1
- package/src/PackagerRunner.ts +1 -1
- package/src/Transformation.ts +3 -2
- package/src/UncommittedAsset.ts +3 -3
- package/src/assetUtils.ts +2 -1
- package/src/atlaspack-v3/worker/compat/mutable-asset.ts +1 -1
- package/src/atlaspack-v3/worker/worker.ts +1 -1
- package/src/public/Asset.ts +1 -1
- package/src/public/BundleGraph.ts +21 -0
- package/src/requests/BundleGraphRequest.ts +9 -7
- package/src/resolveOptions.ts +1 -0
- package/src/types.ts +1 -0
- package/src/worker.ts +1 -1
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Blob, FilePath, BundleResult, Async } from '@atlaspack/types';
|
|
2
|
-
import type SourceMap from '@
|
|
2
|
+
import type SourceMap from '@atlaspack/source-map';
|
|
3
3
|
import type { Bundle as InternalBundle, Config, DevDepRequest, AtlaspackOptions, ReportFn, RequestInvalidation, DevDepRequestRef } from './types';
|
|
4
4
|
import type { AtlaspackConfig, LoadedPlugin } from './AtlaspackConfig';
|
|
5
5
|
import type InternalBundleGraph from './BundleGraph';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AST, Blob, DependencyOptions, FileCreateInvalidation, GenerateOutput, PackageName, TransformerResult } from '@atlaspack/types';
|
|
2
2
|
import type { Asset, Dependency, AtlaspackOptions, Invalidations } from './types';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
|
-
import SourceMap from '@
|
|
4
|
+
import SourceMap from '@atlaspack/source-map';
|
|
5
5
|
import { ProjectPath } from './projectPath';
|
|
6
6
|
type UncommittedAssetOptions = {
|
|
7
7
|
value: Asset;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import SourceMap from '@
|
|
1
|
+
import SourceMap from '@atlaspack/source-map';
|
|
2
2
|
import * as napi from '@atlaspack/rust';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
4
|
import type { MutableAsset as IMutableAsset, Stats, FileSystem, FilePath, Environment, Meta, BundleBehavior, ASTGenerator, AST, Dependency, DependencyOptions, FileCreateInvalidation, EnvironmentOptions } from '@atlaspack/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type SourceMap from '@
|
|
1
|
+
import type SourceMap from '@atlaspack/source-map';
|
|
2
2
|
import type { Readable } from 'stream';
|
|
3
3
|
import type { FileSystem } from '@atlaspack/fs';
|
|
4
4
|
import type { Asset as IAsset, AST, ASTGenerator, Dependency as IDependency, DependencyOptions, Environment as IEnvironment, EnvironmentOptions, FileCreateInvalidation, FilePath, Meta, MutableAsset as IMutableAsset, Stats, MutableAssetSymbols as IMutableAssetSymbols, AssetSymbols as IAssetSymbols, BundleBehavior } from '@atlaspack/types';
|
|
@@ -30,6 +30,8 @@ export default class BundleGraph<TBundle extends IBundle> implements IBundleGrap
|
|
|
30
30
|
getDependencies(asset: IAsset): Array<IDependency>;
|
|
31
31
|
isAssetReachableFromBundle(asset: IAsset, bundle: IBundle): boolean;
|
|
32
32
|
isAssetReferenced(bundle: IBundle, asset: IAsset): boolean;
|
|
33
|
+
isAssetReferencedFastCheck(bundle: IBundle, asset: IAsset): boolean | null;
|
|
34
|
+
getReferencedAssets(bundle: IBundle): Set<IAsset>;
|
|
33
35
|
hasParentBundleOfType(bundle: IBundle, type: string): boolean;
|
|
34
36
|
getBundlesInBundleGroup(bundleGroup: IBundleGroup, opts?: {
|
|
35
37
|
includeInline: boolean;
|
package/lib/types/types.d.ts
CHANGED
|
@@ -241,6 +241,7 @@ export type AtlaspackOptions = {
|
|
|
241
241
|
logLevel: LogLevel;
|
|
242
242
|
projectRoot: FilePath;
|
|
243
243
|
shouldProfile: boolean;
|
|
244
|
+
nativeProfiler: 'instruments' | 'samply' | undefined;
|
|
244
245
|
shouldTrace: boolean;
|
|
245
246
|
shouldPatchConsole: boolean;
|
|
246
247
|
detailedReport?: DetailedReportOptions | null | undefined;
|
package/lib/worker.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
26
26
|
"@atlaspack/build-cache": "2.13.6",
|
|
27
|
-
"@atlaspack/cache": "3.2.
|
|
27
|
+
"@atlaspack/cache": "3.2.34",
|
|
28
28
|
"@atlaspack/diagnostic": "2.14.4",
|
|
29
29
|
"@atlaspack/events": "2.14.4",
|
|
30
|
-
"@atlaspack/feature-flags": "2.
|
|
31
|
-
"@atlaspack/fs": "2.15.
|
|
32
|
-
"@atlaspack/graph": "3.6.
|
|
33
|
-
"@atlaspack/logger": "2.14.
|
|
34
|
-
"@atlaspack/package-manager": "2.14.
|
|
35
|
-
"@atlaspack/plugin": "2.14.
|
|
36
|
-
"@atlaspack/profiler": "2.
|
|
37
|
-
"@atlaspack/rust": "3.
|
|
38
|
-
"@atlaspack/types": "2.15.
|
|
39
|
-
"@atlaspack/utils": "3.
|
|
40
|
-
"@atlaspack/workers": "2.14.
|
|
41
|
-
"@
|
|
30
|
+
"@atlaspack/feature-flags": "2.27.0",
|
|
31
|
+
"@atlaspack/fs": "2.15.34",
|
|
32
|
+
"@atlaspack/graph": "3.6.1",
|
|
33
|
+
"@atlaspack/logger": "2.14.31",
|
|
34
|
+
"@atlaspack/package-manager": "2.14.39",
|
|
35
|
+
"@atlaspack/plugin": "2.14.39",
|
|
36
|
+
"@atlaspack/profiler": "2.15.0",
|
|
37
|
+
"@atlaspack/rust": "3.11.0",
|
|
38
|
+
"@atlaspack/types": "2.15.29",
|
|
39
|
+
"@atlaspack/utils": "3.2.0",
|
|
40
|
+
"@atlaspack/workers": "2.14.39",
|
|
41
|
+
"@atlaspack/source-map": "3.1.0",
|
|
42
42
|
"base-x": "^3.0.8",
|
|
43
43
|
"browserslist": "^4.6.6",
|
|
44
44
|
"clone": "^2.1.1",
|
package/src/Atlaspack.ts
CHANGED
|
@@ -43,7 +43,7 @@ import createPathRequest from './requests/PathRequest';
|
|
|
43
43
|
import {createEnvironment} from './Environment';
|
|
44
44
|
import {createDependency} from './Dependency';
|
|
45
45
|
import {Disposable} from '@atlaspack/events';
|
|
46
|
-
import {init as initSourcemaps} from '@
|
|
46
|
+
import {init as initSourcemaps} from '@atlaspack/source-map';
|
|
47
47
|
import {LMDBLiteCache} from '@atlaspack/cache';
|
|
48
48
|
import {
|
|
49
49
|
// @ts-expect-error TS2305
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
toProjectPath,
|
|
58
58
|
fromProjectPathRelative,
|
|
59
59
|
} from './projectPath';
|
|
60
|
-
import {tracer} from '@atlaspack/profiler';
|
|
60
|
+
import {tracer, NativeProfiler} from '@atlaspack/profiler';
|
|
61
61
|
import {setFeatureFlags, DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
|
|
62
62
|
import {AtlaspackV3, FileSystemV3} from './atlaspack-v3';
|
|
63
63
|
import createAssetGraphRequestJS from './requests/AssetGraphRequest';
|
|
@@ -407,6 +407,10 @@ export default class Atlaspack {
|
|
|
407
407
|
if (options.shouldProfile) {
|
|
408
408
|
await this.startProfiling();
|
|
409
409
|
}
|
|
410
|
+
if (options.nativeProfiler) {
|
|
411
|
+
const nativeProfiler = new NativeProfiler();
|
|
412
|
+
await nativeProfiler.startProfiling(options.nativeProfiler);
|
|
413
|
+
}
|
|
410
414
|
if (options.shouldTrace) {
|
|
411
415
|
tracer.enable();
|
|
412
416
|
// We need to ensure the tracer is disabled when Atlaspack is disposed as it is a module level object.
|
package/src/BundleGraph.ts
CHANGED
|
@@ -1435,6 +1435,158 @@ export default class BundleGraph {
|
|
|
1435
1435
|
});
|
|
1436
1436
|
}
|
|
1437
1437
|
|
|
1438
|
+
// New method: Fast checks only (no caching of results)
|
|
1439
|
+
isAssetReferencedFastCheck(bundle: Bundle, asset: Asset): boolean | null {
|
|
1440
|
+
// Fast Check #1: If asset is in multiple bundles in same target, it's referenced
|
|
1441
|
+
let bundlesWithAsset = this.getBundlesWithAsset(asset).filter(
|
|
1442
|
+
(b) =>
|
|
1443
|
+
b.target.name === bundle.target.name &&
|
|
1444
|
+
b.target.distDir === bundle.target.distDir,
|
|
1445
|
+
);
|
|
1446
|
+
|
|
1447
|
+
if (bundlesWithAsset.length > 1) {
|
|
1448
|
+
return true;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
|
|
1452
|
+
let assetNodeId = nullthrows(this._graph.getNodeIdByContentKey(asset.id));
|
|
1453
|
+
|
|
1454
|
+
if (
|
|
1455
|
+
this._graph
|
|
1456
|
+
.getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references)
|
|
1457
|
+
.map((id) => this._graph.getNode(id))
|
|
1458
|
+
.some(
|
|
1459
|
+
(node) =>
|
|
1460
|
+
node?.type === 'dependency' &&
|
|
1461
|
+
(node.value.priority === Priority.lazy ||
|
|
1462
|
+
node.value.priority === Priority.conditional) &&
|
|
1463
|
+
node.value.specifierType !== SpecifierType.url,
|
|
1464
|
+
)
|
|
1465
|
+
) {
|
|
1466
|
+
return true;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
// Fast checks failed - return null to indicate expensive computation needed
|
|
1470
|
+
return null;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
getReferencedAssets(bundle: Bundle): Set<Asset> {
|
|
1474
|
+
let referencedAssets = new Set<Asset>();
|
|
1475
|
+
|
|
1476
|
+
// Build a map of all assets in this bundle with their dependencies
|
|
1477
|
+
// This allows us to check all assets in a single traversal
|
|
1478
|
+
let assetDependenciesMap = new Map<Asset, Array<Dependency>>();
|
|
1479
|
+
|
|
1480
|
+
this.traverseAssets(bundle, (asset) => {
|
|
1481
|
+
// Always do fast checks (no caching)
|
|
1482
|
+
let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
|
|
1483
|
+
|
|
1484
|
+
if (fastCheckResult === true) {
|
|
1485
|
+
referencedAssets.add(asset);
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
// Fast checks failed (fastCheckResult === null), need expensive computation
|
|
1490
|
+
// Check if it's actually referenced via traversal
|
|
1491
|
+
|
|
1492
|
+
// Store dependencies for later batch checking
|
|
1493
|
+
let dependencies = this._graph
|
|
1494
|
+
.getNodeIdsConnectedTo(
|
|
1495
|
+
nullthrows(this._graph.getNodeIdByContentKey(asset.id)),
|
|
1496
|
+
)
|
|
1497
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1498
|
+
.filter((node) => node.type === 'dependency')
|
|
1499
|
+
.map((node) => {
|
|
1500
|
+
invariant(node.type === 'dependency');
|
|
1501
|
+
return node.value;
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1504
|
+
if (dependencies.length > 0) {
|
|
1505
|
+
assetDependenciesMap.set(asset, dependencies);
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1508
|
+
|
|
1509
|
+
// If no assets need the expensive check, return early
|
|
1510
|
+
if (assetDependenciesMap.size === 0) {
|
|
1511
|
+
return referencedAssets;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
// Get the assets we need to check once
|
|
1515
|
+
let assetsToCheck = Array.from(assetDependenciesMap.keys());
|
|
1516
|
+
|
|
1517
|
+
// Helper function to check if all assets from assetDependenciesMap are in referencedAssets
|
|
1518
|
+
const allAssetsReferenced = (): boolean =>
|
|
1519
|
+
assetsToCheck.length <= referencedAssets.size &&
|
|
1520
|
+
assetsToCheck.every((asset) => referencedAssets.has(asset));
|
|
1521
|
+
|
|
1522
|
+
// Do ONE traversal to check all remaining assets
|
|
1523
|
+
// We can share visitedBundles across all assets because we check every asset
|
|
1524
|
+
// against every visited bundle, which matches the original per-asset behavior
|
|
1525
|
+
let siblingBundles = new Set(
|
|
1526
|
+
this.getBundleGroupsContainingBundle(bundle).flatMap((bundleGroup) =>
|
|
1527
|
+
this.getBundlesInBundleGroup(bundleGroup, {includeInline: true}),
|
|
1528
|
+
),
|
|
1529
|
+
);
|
|
1530
|
+
|
|
1531
|
+
let visitedBundles: Set<Bundle> = new Set();
|
|
1532
|
+
|
|
1533
|
+
// Single traversal from all referencers
|
|
1534
|
+
for (let referencer of siblingBundles) {
|
|
1535
|
+
this.traverseBundles((descendant, _, actions) => {
|
|
1536
|
+
if (descendant.id === bundle.id) {
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
if (visitedBundles.has(descendant)) {
|
|
1541
|
+
actions.skipChildren();
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
visitedBundles.add(descendant);
|
|
1546
|
+
|
|
1547
|
+
if (
|
|
1548
|
+
descendant.type !== bundle.type ||
|
|
1549
|
+
fromEnvironmentId(descendant.env).context !==
|
|
1550
|
+
fromEnvironmentId(bundle.env).context
|
|
1551
|
+
) {
|
|
1552
|
+
// Don't skip children - they might be the right type!
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
// Check ALL assets at once in this descendant bundle
|
|
1557
|
+
for (let [asset, dependencies] of assetDependenciesMap) {
|
|
1558
|
+
// Skip if already marked as referenced
|
|
1559
|
+
if (referencedAssets.has(asset)) {
|
|
1560
|
+
continue;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
// Check if this descendant bundle references the asset
|
|
1564
|
+
if (
|
|
1565
|
+
!this.bundleHasAsset(descendant, asset) &&
|
|
1566
|
+
dependencies.some((dependency) =>
|
|
1567
|
+
this.bundleHasDependency(descendant, dependency),
|
|
1568
|
+
)
|
|
1569
|
+
) {
|
|
1570
|
+
referencedAssets.add(asset);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// If all assets from assetDependenciesMap are now marked as referenced, we can stop early
|
|
1575
|
+
if (allAssetsReferenced()) {
|
|
1576
|
+
actions.stop();
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
}, referencer);
|
|
1580
|
+
|
|
1581
|
+
// If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
|
|
1582
|
+
if (allAssetsReferenced()) {
|
|
1583
|
+
break;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
return referencedAssets;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1438
1590
|
hasParentBundleOfType(bundle: Bundle, type: string): boolean {
|
|
1439
1591
|
let parents = this.getParentBundles(bundle);
|
|
1440
1592
|
return (
|
package/src/CommittedAsset.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {Readable} from 'stream';
|
|
|
3
3
|
import {deserializeRaw} from '@atlaspack/build-cache';
|
|
4
4
|
import type {AST, Blob} from '@atlaspack/types';
|
|
5
5
|
import {bufferStream, blobToStream, streamFromPromise} from '@atlaspack/utils';
|
|
6
|
-
import SourceMap from '@
|
|
6
|
+
import SourceMap from '@atlaspack/source-map';
|
|
7
7
|
|
|
8
8
|
import {generateFromAST} from './assetUtils';
|
|
9
9
|
import type {Asset, Dependency, AtlaspackOptions} from './types';
|
package/src/PackagerRunner.ts
CHANGED
package/src/Transformation.ts
CHANGED
|
@@ -69,6 +69,7 @@ import {
|
|
|
69
69
|
import {invalidateOnFileCreateToInternal, createInvalidations} from './utils';
|
|
70
70
|
import invariant from 'assert';
|
|
71
71
|
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
72
|
+
import SourceMap from '@atlaspack/source-map';
|
|
72
73
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
73
74
|
|
|
74
75
|
type GenerateFunc = (input: UncommittedAsset) => Promise<GenerateOutput>;
|
|
@@ -460,7 +461,7 @@ export default class Transformation {
|
|
|
460
461
|
if (asset.isASTDirty && asset.generate) {
|
|
461
462
|
let output = await asset.generate();
|
|
462
463
|
asset.content = output.content;
|
|
463
|
-
asset.mapBuffer = output.map
|
|
464
|
+
asset.mapBuffer = SourceMap.safeToBuffer(output.map);
|
|
464
465
|
}
|
|
465
466
|
|
|
466
467
|
asset.clearAST();
|
|
@@ -634,7 +635,7 @@ export default class Transformation {
|
|
|
634
635
|
) {
|
|
635
636
|
let output = await asset.generate();
|
|
636
637
|
asset.content = output.content;
|
|
637
|
-
asset.mapBuffer = output.map
|
|
638
|
+
asset.mapBuffer = SourceMap.safeToBuffer(output.map);
|
|
638
639
|
}
|
|
639
640
|
|
|
640
641
|
// Load config for the transformer.
|
package/src/UncommittedAsset.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {Asset, Dependency, AtlaspackOptions, Invalidations} from './types';
|
|
|
11
11
|
|
|
12
12
|
import invariant from 'assert';
|
|
13
13
|
import {Readable} from 'stream';
|
|
14
|
-
import SourceMap from '@
|
|
14
|
+
import SourceMap from '@atlaspack/source-map';
|
|
15
15
|
import {serializeRaw} from '@atlaspack/build-cache';
|
|
16
16
|
import {
|
|
17
17
|
blobToStream,
|
|
@@ -249,7 +249,7 @@ export default class UncommittedAsset {
|
|
|
249
249
|
|
|
250
250
|
if (map) {
|
|
251
251
|
this.map = map;
|
|
252
|
-
this.mapBuffer =
|
|
252
|
+
this.mapBuffer = SourceMap.safeToBuffer(map);
|
|
253
253
|
this.setCode(code.replace(SOURCEMAP_RE, ''));
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -425,7 +425,7 @@ export default class UncommittedAsset {
|
|
|
425
425
|
content,
|
|
426
426
|
ast: result.ast,
|
|
427
427
|
isASTDirty: result.ast === this.ast ? this.isASTDirty : true,
|
|
428
|
-
mapBuffer:
|
|
428
|
+
mapBuffer: SourceMap.safeToBuffer(result.map),
|
|
429
429
|
code: this.code,
|
|
430
430
|
invalidations: this.invalidations,
|
|
431
431
|
});
|
package/src/assetUtils.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {PluginTracer} from '@atlaspack/profiler';
|
|
|
39
39
|
import {identifierRegistry} from './IdentifierRegistry';
|
|
40
40
|
import type {EnvironmentRef} from './EnvironmentManager';
|
|
41
41
|
import {toEnvironmentId} from './EnvironmentManager';
|
|
42
|
+
import SourceMap from '@atlaspack/source-map';
|
|
42
43
|
|
|
43
44
|
export type AssetOptions = {
|
|
44
45
|
id?: string;
|
|
@@ -180,7 +181,7 @@ async function _generateFromAST(asset: CommittedAsset | UncommittedAsset) {
|
|
|
180
181
|
tracer: new PluginTracer({origin: pluginName, category: 'asset-generate'}),
|
|
181
182
|
});
|
|
182
183
|
|
|
183
|
-
let mapBuffer = map
|
|
184
|
+
let mapBuffer = SourceMap.safeToBuffer(map);
|
|
184
185
|
// Store the results in the cache so we can avoid generating again next time
|
|
185
186
|
await Promise.all([
|
|
186
187
|
asset.options.cache.setStream(
|
|
@@ -171,7 +171,7 @@ export class AtlaspackWorker {
|
|
|
171
171
|
type: 'resolved',
|
|
172
172
|
filePath: result.filePath || '',
|
|
173
173
|
canDefer: result.canDefer || false,
|
|
174
|
-
sideEffects: result.sideEffects
|
|
174
|
+
sideEffects: result.sideEffects ?? true,
|
|
175
175
|
code: result.code || undefined,
|
|
176
176
|
meta: result.meta || undefined,
|
|
177
177
|
pipeline: result.pipeline || undefined,
|
package/src/public/Asset.ts
CHANGED
|
@@ -198,6 +198,27 @@ export default class BundleGraph<TBundle extends IBundle>
|
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
isAssetReferencedFastCheck(bundle: IBundle, asset: IAsset): boolean | null {
|
|
202
|
+
return this.#graph.isAssetReferencedFastCheck(
|
|
203
|
+
bundleToInternalBundle(bundle),
|
|
204
|
+
assetToAssetValue(asset),
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
getReferencedAssets(bundle: IBundle): Set<IAsset> {
|
|
209
|
+
let internalReferencedAssets = this.#graph.getReferencedAssets(
|
|
210
|
+
bundleToInternalBundle(bundle),
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
// Convert internal assets to public assets
|
|
214
|
+
let publicReferencedAssets = new Set<IAsset>();
|
|
215
|
+
for (let internalAsset of internalReferencedAssets) {
|
|
216
|
+
publicReferencedAssets.add(assetFromValue(internalAsset, this.#options));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return publicReferencedAssets;
|
|
220
|
+
}
|
|
221
|
+
|
|
201
222
|
hasParentBundleOfType(bundle: IBundle, type: string): boolean {
|
|
202
223
|
return this.#graph.hasParentBundleOfType(
|
|
203
224
|
bundleToInternalBundle(bundle),
|
|
@@ -17,7 +17,7 @@ import fs from 'fs';
|
|
|
17
17
|
import invariant from 'assert';
|
|
18
18
|
import assert from 'assert';
|
|
19
19
|
import nullthrows from 'nullthrows';
|
|
20
|
-
import {PluginLogger} from '@atlaspack/logger';
|
|
20
|
+
import {instrumentAsync, PluginLogger} from '@atlaspack/logger';
|
|
21
21
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
22
22
|
import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
|
|
23
23
|
import AssetGraph from '../AssetGraph';
|
|
@@ -155,12 +155,14 @@ export default function createBundleGraphRequest(
|
|
|
155
155
|
requestedAssetIds,
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
let {assetGraph, changedAssets, assetRequests} = await
|
|
159
|
-
request,
|
|
160
|
-
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
let {assetGraph, changedAssets, assetRequests} = await instrumentAsync(
|
|
159
|
+
'asset-graph-request',
|
|
160
|
+
() => {
|
|
161
|
+
return api.runRequest(request, {
|
|
162
|
+
force:
|
|
163
|
+
Boolean(input.rustAtlaspack) ||
|
|
164
|
+
(options.shouldBuildLazily && requestedAssetIds.size > 0),
|
|
165
|
+
});
|
|
164
166
|
},
|
|
165
167
|
);
|
|
166
168
|
|
package/src/resolveOptions.ts
CHANGED
|
@@ -269,6 +269,7 @@ export default async function resolveOptions(
|
|
|
269
269
|
: false,
|
|
270
270
|
shouldDisableCache: initialOptions.shouldDisableCache ?? false,
|
|
271
271
|
shouldProfile: initialOptions.shouldProfile ?? false,
|
|
272
|
+
nativeProfiler: initialOptions.nativeProfiler,
|
|
272
273
|
shouldTrace: initialOptions.shouldTrace ?? false,
|
|
273
274
|
cacheDir,
|
|
274
275
|
watchDir,
|
package/src/types.ts
CHANGED
|
@@ -335,6 +335,7 @@ export type AtlaspackOptions = {
|
|
|
335
335
|
logLevel: LogLevel;
|
|
336
336
|
projectRoot: FilePath;
|
|
337
337
|
shouldProfile: boolean;
|
|
338
|
+
nativeProfiler: 'instruments' | 'samply' | undefined;
|
|
338
339
|
shouldTrace: boolean;
|
|
339
340
|
shouldPatchConsole: boolean;
|
|
340
341
|
detailedReport?: DetailedReportOptions | null | undefined;
|
package/src/worker.ts
CHANGED
|
@@ -21,7 +21,7 @@ import Validation, {ValidationOpts} from './Validation';
|
|
|
21
21
|
import {AtlaspackConfig} from './AtlaspackConfig';
|
|
22
22
|
import {registerCoreWithSerializer} from './registerCoreWithSerializer';
|
|
23
23
|
import {clearBuildCaches} from '@atlaspack/build-cache';
|
|
24
|
-
import {init as initSourcemaps} from '@
|
|
24
|
+
import {init as initSourcemaps} from '@atlaspack/source-map';
|
|
25
25
|
// @ts-expect-error TS2305
|
|
26
26
|
import {init as initRust} from '@atlaspack/rust';
|
|
27
27
|
import WorkerFarm from '@atlaspack/workers';
|