@atlaspack/core 2.24.0 → 2.24.2-dev-ts-project-refs-d30e9754f.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 +26 -0
- package/LICENSE +201 -0
- package/dist/AssetGraph.js +591 -0
- package/dist/Atlaspack.js +656 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +108 -0
- package/dist/BundleGraph.js +1628 -0
- package/dist/CommittedAsset.js +142 -0
- package/dist/Dependency.js +125 -0
- package/dist/Environment.js +132 -0
- package/dist/EnvironmentManager.js +108 -0
- package/dist/IdentifierRegistry.js +38 -0
- package/dist/InternalConfig.js +37 -0
- package/dist/PackagerRunner.js +531 -0
- package/dist/ReporterRunner.js +151 -0
- package/dist/RequestTracker.js +1368 -0
- package/dist/SymbolPropagation.js +620 -0
- package/dist/TargetDescriptor.schema.js +143 -0
- package/dist/Transformation.js +487 -0
- package/dist/UncommittedAsset.js +315 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +305 -0
- package/dist/assetUtils.js +168 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
- package/dist/atlaspack-v3/fs.js +52 -0
- package/dist/atlaspack-v3/index.js +25 -0
- package/dist/atlaspack-v3/jsCallable.js +16 -0
- package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
- package/dist/atlaspack-v3/worker/compat/bitflags.js +94 -0
- package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
- package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
- package/dist/atlaspack-v3/worker/compat/index.js +25 -0
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
- package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -0
- package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
- package/dist/atlaspack-v3/worker/compat/target.js +14 -0
- package/dist/atlaspack-v3/worker/worker.js +292 -0
- package/dist/constants.js +17 -0
- package/dist/dumpGraphToGraphViz.js +281 -0
- package/dist/index.js +62 -0
- package/dist/loadAtlaspackPlugin.js +128 -0
- package/dist/loadDotEnv.js +41 -0
- package/dist/projectPath.js +83 -0
- package/dist/public/Asset.js +279 -0
- package/dist/public/Bundle.js +224 -0
- package/dist/public/BundleGraph.js +359 -0
- package/dist/public/BundleGroup.js +53 -0
- package/dist/public/Config.js +286 -0
- package/dist/public/Dependency.js +138 -0
- package/dist/public/Environment.js +278 -0
- package/dist/public/MutableBundleGraph.js +277 -0
- package/dist/public/PluginOptions.js +80 -0
- package/dist/public/Symbols.js +248 -0
- package/dist/public/Target.js +69 -0
- package/dist/registerCoreWithSerializer.js +38 -0
- package/dist/requests/AssetGraphRequest.js +429 -0
- package/dist/requests/AssetGraphRequestRust.js +246 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +60 -0
- package/dist/requests/AtlaspackConfigRequest.js +490 -0
- package/dist/requests/BundleGraphRequest.js +441 -0
- package/dist/requests/ConfigRequest.js +222 -0
- package/dist/requests/DevDepRequest.js +204 -0
- package/dist/requests/EntryRequest.js +314 -0
- package/dist/requests/PackageRequest.js +65 -0
- package/dist/requests/PathRequest.js +349 -0
- package/dist/requests/TargetRequest.js +1310 -0
- package/dist/requests/ValidationRequest.js +49 -0
- package/dist/requests/WriteBundleRequest.js +254 -0
- package/dist/requests/WriteBundlesRequest.js +165 -0
- package/dist/requests/asset-graph-diff.js +126 -0
- package/dist/requests/asset-graph-dot.js +131 -0
- package/dist/resolveOptions.js +268 -0
- package/dist/rustWorkerThreadDylibHack.js +19 -0
- package/dist/serializerCore.browser.js +43 -0
- package/dist/summarizeRequest.js +39 -0
- package/dist/types.js +31 -0
- package/dist/utils.js +172 -0
- package/dist/worker.js +130 -0
- package/lib/AssetGraph.js +1 -0
- package/lib/atlaspack-v3/AtlaspackV3.js +7 -3
- package/lib/requests/AssetGraphRequestRust.js +1 -1
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +1 -1
- package/package.json +22 -22
- package/src/AssetGraph.ts +1 -0
- package/src/atlaspack-v3/AtlaspackV3.ts +12 -3
- package/src/requests/AssetGraphRequestRust.ts +1 -1
- package/tsconfig.json +55 -2
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
36
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
37
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
38
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
39
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
40
|
+
};
|
|
41
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
42
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
43
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
44
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
45
|
+
};
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
var _BundleGraph_graph, _BundleGraph_options, _BundleGraph_createBundle;
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.bundleGraphToInternalBundleGraph = bundleGraphToInternalBundleGraph;
|
|
52
|
+
const assert_1 = __importDefault(require("assert"));
|
|
53
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
54
|
+
const graph_1 = require("@atlaspack/graph");
|
|
55
|
+
const Asset_1 = require("./Asset");
|
|
56
|
+
const Bundle_1 = require("./Bundle");
|
|
57
|
+
const Dependency_1 = __importStar(require("./Dependency"));
|
|
58
|
+
const Target_1 = require("./Target");
|
|
59
|
+
const utils_1 = require("../utils");
|
|
60
|
+
const BundleGroup_1 = __importStar(require("./BundleGroup"));
|
|
61
|
+
// Friendly access for other modules within this package that need access
|
|
62
|
+
// to the internal bundle.
|
|
63
|
+
const _bundleGraphToInternalBundleGraph = new WeakMap();
|
|
64
|
+
function bundleGraphToInternalBundleGraph(bundleGraph) {
|
|
65
|
+
return (0, nullthrows_1.default)(_bundleGraphToInternalBundleGraph.get(bundleGraph));
|
|
66
|
+
}
|
|
67
|
+
class BundleGraph {
|
|
68
|
+
constructor(graph, createBundle, options) {
|
|
69
|
+
_BundleGraph_graph.set(this, void 0);
|
|
70
|
+
_BundleGraph_options.set(this, void 0);
|
|
71
|
+
_BundleGraph_createBundle.set(this, void 0);
|
|
72
|
+
__classPrivateFieldSet(this, _BundleGraph_graph, graph, "f");
|
|
73
|
+
__classPrivateFieldSet(this, _BundleGraph_options, options, "f");
|
|
74
|
+
__classPrivateFieldSet(this, _BundleGraph_createBundle, createBundle, "f");
|
|
75
|
+
_bundleGraphToInternalBundleGraph.set(this, graph);
|
|
76
|
+
}
|
|
77
|
+
getAssetById(id) {
|
|
78
|
+
return (0, Asset_1.assetFromValue)(__classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetById(id), __classPrivateFieldGet(this, _BundleGraph_options, "f"));
|
|
79
|
+
}
|
|
80
|
+
getAssetPublicId(asset) {
|
|
81
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetPublicId((0, Asset_1.assetToAssetValue)(asset));
|
|
82
|
+
}
|
|
83
|
+
isDependencySkipped(dep) {
|
|
84
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isDependencySkipped((0, Dependency_1.dependencyToInternalDependency)(dep));
|
|
85
|
+
}
|
|
86
|
+
getResolvedAsset(dep, bundle) {
|
|
87
|
+
let resolution = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getResolvedAsset((0, Dependency_1.dependencyToInternalDependency)(dep), bundle && (0, Bundle_1.bundleToInternalBundle)(bundle));
|
|
88
|
+
if (resolution) {
|
|
89
|
+
return (0, Asset_1.assetFromValue)(resolution, __classPrivateFieldGet(this, _BundleGraph_options, "f"));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
getIncomingDependencies(asset) {
|
|
93
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
94
|
+
.getIncomingDependencies((0, Asset_1.assetToAssetValue)(asset))
|
|
95
|
+
.map((dep) => (0, Dependency_1.getPublicDependency)(dep, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
96
|
+
}
|
|
97
|
+
getAssetWithDependency(dep) {
|
|
98
|
+
let asset = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetWithDependency((0, Dependency_1.dependencyToInternalDependency)(dep));
|
|
99
|
+
if (asset) {
|
|
100
|
+
return (0, Asset_1.assetFromValue)(asset, __classPrivateFieldGet(this, _BundleGraph_options, "f"));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
getBundleGroupsContainingBundle(bundle) {
|
|
104
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
105
|
+
.getBundleGroupsContainingBundle((0, Bundle_1.bundleToInternalBundle)(bundle))
|
|
106
|
+
.map((bundleGroup) => new BundleGroup_1.default(bundleGroup, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
107
|
+
}
|
|
108
|
+
getReferencedBundles(bundle, opts) {
|
|
109
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
110
|
+
.getReferencedBundles((0, Bundle_1.bundleToInternalBundle)(bundle), opts)
|
|
111
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
112
|
+
}
|
|
113
|
+
getReferencingBundles(bundle) {
|
|
114
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
115
|
+
.getReferencingBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
|
|
116
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
117
|
+
}
|
|
118
|
+
resolveAsyncDependency(dependency, bundle) {
|
|
119
|
+
let resolved = __classPrivateFieldGet(this, _BundleGraph_graph, "f").resolveAsyncDependency((0, Dependency_1.dependencyToInternalDependency)(dependency), bundle && (0, Bundle_1.bundleToInternalBundle)(bundle));
|
|
120
|
+
if (resolved == null) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
else if (resolved.type === 'bundle_group') {
|
|
124
|
+
return {
|
|
125
|
+
type: 'bundle_group',
|
|
126
|
+
value: new BundleGroup_1.default(resolved.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
type: 'asset',
|
|
131
|
+
value: (0, Asset_1.assetFromValue)(resolved.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
getReferencedBundle(dependency, bundle) {
|
|
135
|
+
let result = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getReferencedBundle((0, Dependency_1.dependencyToInternalDependency)(dependency), (0, Bundle_1.bundleToInternalBundle)(bundle));
|
|
136
|
+
if (result != null) {
|
|
137
|
+
return __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, result, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f"));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
getDependencies(asset) {
|
|
141
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
142
|
+
.getDependencies((0, Asset_1.assetToAssetValue)(asset))
|
|
143
|
+
.map((dep) => (0, Dependency_1.getPublicDependency)(dep, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
144
|
+
}
|
|
145
|
+
isAssetReachableFromBundle(asset, bundle) {
|
|
146
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isAssetReachableFromBundle((0, Asset_1.assetToAssetValue)(asset), (0, Bundle_1.bundleToInternalBundle)(bundle));
|
|
147
|
+
}
|
|
148
|
+
isAssetReferenced(bundle, asset) {
|
|
149
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isAssetReferenced((0, Bundle_1.bundleToInternalBundle)(bundle), (0, Asset_1.assetToAssetValue)(asset));
|
|
150
|
+
}
|
|
151
|
+
hasParentBundleOfType(bundle, type) {
|
|
152
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").hasParentBundleOfType((0, Bundle_1.bundleToInternalBundle)(bundle), type);
|
|
153
|
+
}
|
|
154
|
+
getBundlesInBundleGroup(bundleGroup, opts) {
|
|
155
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
156
|
+
.getBundlesInBundleGroup((0, BundleGroup_1.bundleGroupToInternalBundleGroup)(bundleGroup), opts)
|
|
157
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
158
|
+
}
|
|
159
|
+
getBundles(opts) {
|
|
160
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
161
|
+
.getBundles(opts)
|
|
162
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
163
|
+
}
|
|
164
|
+
isEntryBundleGroup(bundleGroup) {
|
|
165
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isEntryBundleGroup((0, BundleGroup_1.bundleGroupToInternalBundleGroup)(bundleGroup));
|
|
166
|
+
}
|
|
167
|
+
getChildBundles(bundle) {
|
|
168
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
169
|
+
.getChildBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
|
|
170
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
171
|
+
}
|
|
172
|
+
getParentBundles(bundle) {
|
|
173
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
174
|
+
.getParentBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
|
|
175
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
176
|
+
}
|
|
177
|
+
getSymbolResolution(asset, symbol, boundary) {
|
|
178
|
+
let res = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getSymbolResolution((0, Asset_1.assetToAssetValue)(asset), symbol, boundary ? (0, Bundle_1.bundleToInternalBundle)(boundary) : null);
|
|
179
|
+
return {
|
|
180
|
+
asset: (0, Asset_1.assetFromValue)(res.asset, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
|
|
181
|
+
exportSymbol: res.exportSymbol,
|
|
182
|
+
symbol: res.symbol,
|
|
183
|
+
loc: (0, utils_1.fromInternalSourceLocation)(__classPrivateFieldGet(this, _BundleGraph_options, "f").projectRoot, res.loc),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
getExportedSymbols(asset, boundary) {
|
|
187
|
+
let res = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getExportedSymbols((0, Asset_1.assetToAssetValue)(asset), boundary ? (0, Bundle_1.bundleToInternalBundle)(boundary) : null);
|
|
188
|
+
return res.map((e) => ({
|
|
189
|
+
asset: (0, Asset_1.assetFromValue)(e.asset, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
|
|
190
|
+
exportSymbol: e.exportSymbol,
|
|
191
|
+
symbol: e.symbol,
|
|
192
|
+
loc: (0, utils_1.fromInternalSourceLocation)(__classPrivateFieldGet(this, _BundleGraph_options, "f").projectRoot, e.loc),
|
|
193
|
+
exportAs: e.exportAs,
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
traverse(visit, start, opts) {
|
|
197
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").traverse(
|
|
198
|
+
// @ts-expect-error TS2345
|
|
199
|
+
(0, graph_1.mapVisitor)((node, actions) => {
|
|
200
|
+
// Skipping unused dependencies here is faster than doing an isDependencySkipped check inside the visitor
|
|
201
|
+
// because the node needs to be re-looked up by id from the hashmap.
|
|
202
|
+
if (opts?.skipUnusedDependencies &&
|
|
203
|
+
node.type === 'dependency' &&
|
|
204
|
+
(node.hasDeferred || node.excluded)) {
|
|
205
|
+
actions.skipChildren();
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
return node.type === 'asset'
|
|
209
|
+
? { type: 'asset', value: (0, Asset_1.assetFromValue)(node.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")) }
|
|
210
|
+
: {
|
|
211
|
+
type: 'dependency',
|
|
212
|
+
value: (0, Dependency_1.getPublicDependency)(node.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
|
|
213
|
+
};
|
|
214
|
+
}, visit), start ? (0, Asset_1.assetToAssetValue)(start) : undefined);
|
|
215
|
+
}
|
|
216
|
+
traverseBundles(visit, startBundle) {
|
|
217
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").traverseBundles((0, graph_1.mapVisitor)((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")), visit), startBundle == null ? undefined : (0, Bundle_1.bundleToInternalBundle)(startBundle));
|
|
218
|
+
}
|
|
219
|
+
getBundlesWithAsset(asset) {
|
|
220
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
221
|
+
.getBundlesWithAsset((0, Asset_1.assetToAssetValue)(asset))
|
|
222
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
223
|
+
}
|
|
224
|
+
getBundlesWithDependency(dependency) {
|
|
225
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
226
|
+
.getBundlesWithDependency((0, Dependency_1.dependencyToInternalDependency)(dependency))
|
|
227
|
+
.map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
228
|
+
}
|
|
229
|
+
getUsedSymbols(v) {
|
|
230
|
+
if (v instanceof Asset_1.Asset) {
|
|
231
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getUsedSymbolsAsset((0, Asset_1.assetToAssetValue)(v));
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
(0, assert_1.default)(v instanceof Dependency_1.default);
|
|
235
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getUsedSymbolsDependency((0, Dependency_1.dependencyToInternalDependency)(v));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
getEntryRoot(target) {
|
|
239
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getEntryRoot(__classPrivateFieldGet(this, _BundleGraph_options, "f").projectRoot, (0, Target_1.targetToInternalTarget)(target));
|
|
240
|
+
}
|
|
241
|
+
// Given a set of dependencies, return any conditions where those dependencies are either
|
|
242
|
+
// the true or false dependency for those conditions. This is currently used to work out which
|
|
243
|
+
// conditions belong to a bundle in packaging.
|
|
244
|
+
getConditionsForDependencies(deps, bundle) {
|
|
245
|
+
const conditions = new Set();
|
|
246
|
+
const depIds = deps.map((dep) => dep.id);
|
|
247
|
+
for (const condition of __classPrivateFieldGet(this, _BundleGraph_graph, "f")._conditions.values()) {
|
|
248
|
+
if (depIds.includes(condition.ifTrueDependency.id) ||
|
|
249
|
+
depIds.includes(condition.ifFalseDependency.id)) {
|
|
250
|
+
const [[trueAsset, ifTrueBundles], [falseAsset, ifFalseBundles]] = [
|
|
251
|
+
condition.ifTrueDependency,
|
|
252
|
+
condition.ifFalseDependency,
|
|
253
|
+
].map((dep) => {
|
|
254
|
+
const asset = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getResolvedAsset(dep, (0, Bundle_1.bundleToInternalBundle)(bundle));
|
|
255
|
+
if (asset &&
|
|
256
|
+
__classPrivateFieldGet(this, _BundleGraph_graph, "f").bundleHasAsset((0, Bundle_1.bundleToInternalBundle)(bundle), asset)) {
|
|
257
|
+
// Asset is in the same bundle, we know it doesn't need to be loaded externally
|
|
258
|
+
return [asset, []];
|
|
259
|
+
}
|
|
260
|
+
const resolvedAsync = __classPrivateFieldGet(this, _BundleGraph_graph, "f").resolveAsyncDependency(dep, (0, Bundle_1.bundleToInternalBundle)(bundle));
|
|
261
|
+
if (resolvedAsync?.type === 'asset') {
|
|
262
|
+
// Single bundle to load dynamically
|
|
263
|
+
return [
|
|
264
|
+
resolvedAsync.value,
|
|
265
|
+
[
|
|
266
|
+
__classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, (0, nullthrows_1.default)(__classPrivateFieldGet(this, _BundleGraph_graph, "f").getReferencedBundle(dep, (0, Bundle_1.bundleToInternalBundle)(bundle)), `Failed to load referenced bundle for '${dep.specifier}' specifier from '${String(dep.sourcePath)}'`), __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")),
|
|
267
|
+
],
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
else if (resolvedAsync) {
|
|
271
|
+
// Bundle group means we have multiple bundles to load first
|
|
272
|
+
return [
|
|
273
|
+
__classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetById(resolvedAsync.value.entryAssetId),
|
|
274
|
+
__classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
275
|
+
.getBundlesInBundleGroup(resolvedAsync.value)
|
|
276
|
+
.map((b) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, b, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f"))),
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
return [
|
|
281
|
+
(0, nullthrows_1.default)(asset, `Failed to load depenendency for '${dep.specifier}' specifier from '${String(dep.sourcePath)}'`),
|
|
282
|
+
[],
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
conditions.add({
|
|
287
|
+
publicId: condition.publicId,
|
|
288
|
+
key: condition.key,
|
|
289
|
+
ifTrueDependency: (0, nullthrows_1.default)(deps.find((dep) => dep.id === condition.ifTrueDependency.id), 'ifTrueDependency was null'),
|
|
290
|
+
ifFalseDependency: (0, nullthrows_1.default)(deps.find((dep) => dep.id === condition.ifFalseDependency.id), 'ifFalseDependency was null'),
|
|
291
|
+
ifTrueBundles,
|
|
292
|
+
ifFalseBundles,
|
|
293
|
+
ifTrueAssetId: __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetPublicId(trueAsset),
|
|
294
|
+
ifFalseAssetId: __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetPublicId(falseAsset),
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// @ts-expect-error TS2322
|
|
299
|
+
return conditions;
|
|
300
|
+
}
|
|
301
|
+
// This is used to generate information for building a manifest that can
|
|
302
|
+
// be used by a webserver to understand which conditions are used by which bundles,
|
|
303
|
+
// and which bundles those conditions require depending on what they evaluate to.
|
|
304
|
+
getConditionalBundleMapping() {
|
|
305
|
+
let bundleConditions = new Map();
|
|
306
|
+
// Convert the internal references in conditions to public API references
|
|
307
|
+
for (const cond of __classPrivateFieldGet(this, _BundleGraph_graph, "f")._conditions.values()) {
|
|
308
|
+
let assets = Array.from(cond.assets).map((asset) => (0, nullthrows_1.default)(this.getAssetById(asset.id)));
|
|
309
|
+
let bundles = new Set();
|
|
310
|
+
let ifTrueBundles = [];
|
|
311
|
+
let ifFalseBundles = [];
|
|
312
|
+
for (const asset of assets) {
|
|
313
|
+
const bundlesWithAsset = this.getBundlesWithAsset(asset);
|
|
314
|
+
for (const bundle of bundlesWithAsset) {
|
|
315
|
+
bundles.add(bundle);
|
|
316
|
+
}
|
|
317
|
+
const assetDeps = this.getDependencies(asset);
|
|
318
|
+
const depToBundles = (dep) => {
|
|
319
|
+
const publicDep = (0, nullthrows_1.default)(assetDeps.find((assetDep) => dep.id === assetDep.id));
|
|
320
|
+
const resolved = this.resolveAsyncDependency(publicDep);
|
|
321
|
+
if (!resolved) {
|
|
322
|
+
// If there's no async dependency, don't list it as required
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
(0, assert_1.default)(resolved.type === 'bundle_group');
|
|
326
|
+
return this.getBundlesInBundleGroup(resolved.value);
|
|
327
|
+
};
|
|
328
|
+
// @ts-expect-error TS2345
|
|
329
|
+
ifTrueBundles.push(...depToBundles(cond.ifTrueDependency));
|
|
330
|
+
// @ts-expect-error TS2345
|
|
331
|
+
ifFalseBundles.push(...depToBundles(cond.ifFalseDependency));
|
|
332
|
+
}
|
|
333
|
+
for (let bundle of bundles) {
|
|
334
|
+
const conditions = bundleConditions.get(bundle.id) ?? new Map();
|
|
335
|
+
const currentCondition = conditions.get(cond.key);
|
|
336
|
+
conditions.set(cond.key, {
|
|
337
|
+
bundle,
|
|
338
|
+
ifTrueBundles: [
|
|
339
|
+
...(currentCondition?.ifTrueBundles ?? []),
|
|
340
|
+
...ifTrueBundles,
|
|
341
|
+
],
|
|
342
|
+
ifFalseBundles: [
|
|
343
|
+
...(currentCondition?.ifFalseBundles ?? []),
|
|
344
|
+
...ifFalseBundles,
|
|
345
|
+
],
|
|
346
|
+
});
|
|
347
|
+
bundleConditions.set(bundle.id, conditions);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return bundleConditions;
|
|
351
|
+
}
|
|
352
|
+
getReferencedConditionalBundles(bundle) {
|
|
353
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
|
|
354
|
+
.getReferencedConditionalBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
|
|
355
|
+
.map((result) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, result, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
_BundleGraph_graph = new WeakMap(), _BundleGraph_options = new WeakMap(), _BundleGraph_createBundle = new WeakMap();
|
|
359
|
+
exports.default = BundleGraph;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _BundleGroup_bundleGroup, _BundleGroup_options;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.bundleGroupToInternalBundleGroup = bundleGroupToInternalBundleGroup;
|
|
19
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
20
|
+
const Target_1 = __importDefault(require("./Target"));
|
|
21
|
+
const internalBundleGroupToBundleGroup = new WeakMap();
|
|
22
|
+
const _bundleGroupToInternalBundleGroup = new WeakMap();
|
|
23
|
+
function bundleGroupToInternalBundleGroup(target) {
|
|
24
|
+
return (0, nullthrows_1.default)(_bundleGroupToInternalBundleGroup.get(target));
|
|
25
|
+
}
|
|
26
|
+
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
27
|
+
class BundleGroup {
|
|
28
|
+
constructor(bundleGroup, options) {
|
|
29
|
+
// @ts-expect-error TS2564
|
|
30
|
+
_BundleGroup_bundleGroup.set(this, void 0);
|
|
31
|
+
// @ts-expect-error TS2564
|
|
32
|
+
_BundleGroup_options.set(this, void 0);
|
|
33
|
+
let existing = internalBundleGroupToBundleGroup.get(bundleGroup);
|
|
34
|
+
if (existing != null) {
|
|
35
|
+
return existing;
|
|
36
|
+
}
|
|
37
|
+
__classPrivateFieldSet(this, _BundleGroup_bundleGroup, bundleGroup, "f");
|
|
38
|
+
__classPrivateFieldSet(this, _BundleGroup_options, options, "f");
|
|
39
|
+
_bundleGroupToInternalBundleGroup.set(this, bundleGroup);
|
|
40
|
+
internalBundleGroupToBundleGroup.set(bundleGroup, this);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
get target() {
|
|
44
|
+
return new Target_1.default(__classPrivateFieldGet(this, _BundleGroup_bundleGroup, "f").target, __classPrivateFieldGet(this, _BundleGroup_options, "f"));
|
|
45
|
+
}
|
|
46
|
+
get entryAssetId() {
|
|
47
|
+
return __classPrivateFieldGet(this, _BundleGroup_bundleGroup, "f").entryAssetId;
|
|
48
|
+
}
|
|
49
|
+
[(_BundleGroup_bundleGroup = new WeakMap(), _BundleGroup_options = new WeakMap(), inspect)]() {
|
|
50
|
+
return `BundleGroup(${this.entryAssetId})`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = BundleGroup;
|