@atlaspack/core 2.32.1 → 2.33.1

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.
@@ -0,0 +1,378 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = createBundleGraphRequestRust;
7
+ exports.getBundleGraph = getBundleGraph;
8
+ function _assert() {
9
+ const data = _interopRequireDefault(require("assert"));
10
+ _assert = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ function _diagnostic() {
16
+ const data = _interopRequireDefault(require("@atlaspack/diagnostic"));
17
+ _diagnostic = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _graph() {
23
+ const data = require("@atlaspack/graph");
24
+ _graph = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
29
+ function _logger() {
30
+ const data = require("@atlaspack/logger");
31
+ _logger = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
36
+ function _featureFlags() {
37
+ const data = require("@atlaspack/feature-flags");
38
+ _featureFlags = function () {
39
+ return data;
40
+ };
41
+ return data;
42
+ }
43
+ var _BundleGraph = _interopRequireWildcard(require("../BundleGraph"));
44
+ var _dumpGraphToGraphViz = _interopRequireDefault(require("../dumpGraphToGraphViz"));
45
+ function _nullthrows() {
46
+ const data = _interopRequireDefault(require("nullthrows"));
47
+ _nullthrows = function () {
48
+ return data;
49
+ };
50
+ return data;
51
+ }
52
+ function _rust() {
53
+ const data = require("@atlaspack/rust");
54
+ _rust = function () {
55
+ return data;
56
+ };
57
+ return data;
58
+ }
59
+ var _PluginOptions = _interopRequireDefault(require("../public/PluginOptions"));
60
+ var _applyRuntimes = _interopRequireDefault(require("../applyRuntimes"));
61
+ var _constants = require("../constants");
62
+ var _utils = require("../utils");
63
+ var _DevDepRequest = require("./DevDepRequest");
64
+ var _RequestTracker = require("../RequestTracker");
65
+ var _AtlaspackConfigRequest = _interopRequireWildcard(require("./AtlaspackConfigRequest"));
66
+ var _BundleGraphRequestUtils = require("./BundleGraphRequestUtils");
67
+ var _EnvironmentManager = require("../EnvironmentManager");
68
+ var _Environment = require("../Environment");
69
+ 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); }
70
+ 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; }
71
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
72
+ function createBundleGraphRequestRust(input) {
73
+ return {
74
+ type: _RequestTracker.requestTypes.bundle_graph_request,
75
+ id: 'BundleGraphRust',
76
+ run: async runInput => {
77
+ const {
78
+ api,
79
+ options,
80
+ rustAtlaspack
81
+ } = runInput;
82
+ (0, _assert().default)(rustAtlaspack, 'BundleGraphRequestRust requires rustAtlaspack');
83
+ let {
84
+ bundleGraphPromise,
85
+ commitPromise
86
+ } = await rustAtlaspack.buildBundleGraph();
87
+ let [serializedBundleGraph, bundleGraphError] = await bundleGraphPromise;
88
+ if (bundleGraphError) {
89
+ throw new (_diagnostic().default)({
90
+ diagnostic: bundleGraphError
91
+ });
92
+ }
93
+
94
+ // Don’t reuse previous JS result yet; we just rebuild from scratch.
95
+ let {
96
+ bundleGraph,
97
+ changedAssets
98
+ } = (0, _logger().instrument)('atlaspack_v3_getBundleGraph', () => getBundleGraph(serializedBundleGraph));
99
+ const runner = new NativeBundlerRunner({
100
+ api,
101
+ options
102
+ }, input.optionsRef);
103
+ await runner.loadConfigs();
104
+
105
+ // Name all bundles
106
+ const namers = await runner.config.getNamers();
107
+ const bundles = bundleGraph.getBundles({
108
+ includeInline: true
109
+ });
110
+ await Promise.all(bundles.map(b => (0, _BundleGraphRequestUtils.nameBundle)(namers, b, bundleGraph, options, runner.pluginOptions, runner.configs)));
111
+
112
+ // Apply runtimes
113
+ const changedRuntimes = await (0, _logger().instrumentAsync)('applyRuntimes', () => (0, _applyRuntimes.default)({
114
+ bundleGraph,
115
+ api,
116
+ config: runner.config,
117
+ options,
118
+ optionsRef: input.optionsRef,
119
+ pluginOptions: runner.pluginOptions,
120
+ previousDevDeps: runner.previousDevDeps,
121
+ devDepRequests: runner.devDepRequests,
122
+ configs: runner.configs
123
+ }));
124
+
125
+ // Add dev deps for namers
126
+ for (const namer of namers) {
127
+ const devDepRequest = await (0, _DevDepRequest.createDevDependency)({
128
+ specifier: namer.name,
129
+ resolveFrom: namer.resolveFrom
130
+ }, runner.previousDevDeps, options);
131
+ await (0, _BundleGraphRequestUtils.runDevDepRequest)(api, devDepRequest, runner.devDepRequests);
132
+ }
133
+ (0, _BundleGraphRequestUtils.validateBundles)(bundleGraph);
134
+ bundleGraph.getBundleGraphHash();
135
+ await (0, _dumpGraphToGraphViz.default)(
136
+ // @ts-expect-error Accessing internal graph for debug output
137
+ bundleGraph._graph, 'after_runtimes_native', _BundleGraph.bundleGraphEdgeTypes);
138
+ let [_commitResult, commitError] = await commitPromise;
139
+ if (commitError) {
140
+ throw new (_diagnostic().default)({
141
+ diagnostic: {
142
+ message: 'Error committing bundle graph in Rust: ' + commitError.message
143
+ }
144
+ });
145
+ }
146
+ return {
147
+ bundleGraph,
148
+ // Not accurate yet — ok for now.
149
+ assetGraphBundlingVersion: 0,
150
+ changedAssets: changedRuntimes,
151
+ assetRequests: []
152
+ };
153
+ },
154
+ input
155
+ };
156
+ }
157
+ function mapSymbols({
158
+ exported,
159
+ ...symbol
160
+ }) {
161
+ let jsSymbol = {
162
+ local: symbol.local ?? undefined,
163
+ loc: symbol.loc ?? undefined,
164
+ isWeak: symbol.isWeak,
165
+ meta: {
166
+ isEsm: symbol.isEsmExport,
167
+ isStaticBindingSafe: symbol.isStaticBindingSafe
168
+ }
169
+ };
170
+ if (symbol.exported) {
171
+ jsSymbol.exported = symbol.exported;
172
+ }
173
+ return [exported, jsSymbol];
174
+ }
175
+ function normalizeEnv(env) {
176
+ if (!env) return env;
177
+ env.id = env.id || (0, _Environment.getEnvironmentHash)(env);
178
+ return (0, _EnvironmentManager.toEnvironmentRef)(env);
179
+ }
180
+ function getBundleGraph(serializedGraph) {
181
+ // Build a fresh internal bundle graph.
182
+ const publicIdByAssetId = new Map(Object.entries(serializedGraph.publicIdByAssetId ?? {}));
183
+ const assetPublicIds = new Set(serializedGraph.assetPublicIds ?? []);
184
+
185
+ // BundleGraph constructor expects a ContentGraph under `_graph`.
186
+ // We reuse the internal graph class by creating an empty instance and then adding nodes.
187
+ const graph = new _BundleGraph.default({
188
+ // We intentionally start with an empty graph and add nodes/edges from the Rust payload.
189
+ // `ContentGraph` will allocate as needed.
190
+ graph: new (_graph().ContentGraph)(),
191
+ bundleContentHashes: new Map(),
192
+ publicIdByAssetId,
193
+ assetPublicIds,
194
+ conditions: new Map()
195
+ });
196
+
197
+ // Root must exist at node id 0.
198
+ const rootNodeId = graph._graph.addNodeByContentKey('@@root', {
199
+ id: '@@root',
200
+ type: 'root',
201
+ value: null
202
+ });
203
+ graph._graph.setRootNodeId(rootNodeId);
204
+ let entry = 0;
205
+ const changedAssets = new Map();
206
+ const decoder = new TextDecoder();
207
+
208
+ // Create nodes in order.
209
+ for (let i = 0; i < serializedGraph.nodes.length; i++) {
210
+ // Nodes come back as buffers (same as AssetGraphRequestRust)
211
+ let node = JSON.parse(decoder.decode(serializedGraph.nodes[i]));
212
+ if (node.type === 'root') {
213
+ continue;
214
+ }
215
+ if (node.type === 'entry') {
216
+ let id = 'entry:' + ++entry;
217
+ graph._graph.addNodeByContentKey(id, {
218
+ id,
219
+ type: 'root',
220
+ value: null
221
+ });
222
+ continue;
223
+ }
224
+ if (node.type === 'asset') {
225
+ let asset = node.value;
226
+ let id = asset.id;
227
+ asset.committed = true;
228
+ asset.contentKey = id;
229
+ asset.env = {
230
+ ...asset.env
231
+ };
232
+ asset.env.id = (0, _featureFlags().getFeatureFlag)('environmentDeduplication') ? (0, _Environment.getEnvironmentHash)(asset.env) : (0, _Environment.getEnvironmentHash)(asset.env);
233
+ asset.env = normalizeEnv(asset.env);
234
+ asset.mapKey = `map:${asset.id}`;
235
+ asset.dependencies = new Map();
236
+ asset.meta.isV3 = true;
237
+ if (asset.symbols != null) {
238
+ asset.symbols = new Map(asset.symbols.map(mapSymbols));
239
+ }
240
+ changedAssets.set(id, asset);
241
+ const assetNode = {
242
+ id,
243
+ type: 'asset',
244
+ usedSymbols: new Set(),
245
+ usedSymbolsDownDirty: true,
246
+ usedSymbolsUpDirty: true,
247
+ value: asset
248
+ };
249
+ graph._graph.addNodeByContentKey(id, assetNode);
250
+ continue;
251
+ }
252
+ if (node.type === 'dependency') {
253
+ let {
254
+ dependency,
255
+ id
256
+ } = node.value;
257
+ dependency.id = id;
258
+ dependency.env = {
259
+ ...dependency.env
260
+ };
261
+ dependency.env.id = (0, _Environment.getEnvironmentHash)(dependency.env);
262
+ dependency.env = normalizeEnv(dependency.env);
263
+ if (dependency.symbols != null) {
264
+ var _dependency$symbols;
265
+ dependency.symbols = new Map((_dependency$symbols = dependency.symbols) === null || _dependency$symbols === void 0 ? void 0 : _dependency$symbols.map(mapSymbols));
266
+ }
267
+ let usedSymbolsDown = new Set();
268
+ let usedSymbolsUp = new Map();
269
+ if (dependency.isEntry && dependency.isLibrary) {
270
+ usedSymbolsDown.add('*');
271
+ usedSymbolsUp.set('*', undefined);
272
+ }
273
+ const depNode = {
274
+ id,
275
+ type: 'dependency',
276
+ deferred: false,
277
+ excluded: false,
278
+ hasDeferred: node.has_deferred,
279
+ // @ts-expect-error Flow types expect a more specific symbol set type
280
+ usedSymbolsDown,
281
+ usedSymbolsDownDirty: true,
282
+ usedSymbolsUp,
283
+ usedSymbolsUpDirtyDown: true,
284
+ usedSymbolsUpDirtyUp: true,
285
+ value: dependency
286
+ };
287
+ graph._graph.addNodeByContentKey(id, depNode);
288
+ continue;
289
+ }
290
+ if (node.type === 'bundle') {
291
+ node.value.env = normalizeEnv(node.value.env);
292
+ node.value.target.env = normalizeEnv(node.value.target.env);
293
+ graph._graph.addNodeByContentKey(node.id, node);
294
+ continue;
295
+ }
296
+ if (node.type === 'bundle_group' || node.type === 'bundleGroup') {
297
+ // Rust serializer may emit bundleGroup nodes either as `{id,type,value:{...}}`
298
+ // or as `{type:"bundleGroup", id, target, entryAssetId}`.
299
+ if (node.value == null) {
300
+ node.value = {
301
+ target: node.target,
302
+ entryAssetId: node.entryAssetId ?? node.entry_asset_id
303
+ };
304
+ }
305
+
306
+ // Normalize entry asset id field naming
307
+ if (node.value.entryAssetId == null && node.value.entry_asset_id != null) {
308
+ node.value.entryAssetId = node.value.entry_asset_id;
309
+ }
310
+ node.value.target.env = normalizeEnv(node.value.target.env);
311
+ // Normalise to the expected snake_case type
312
+ node.type = 'bundle_group';
313
+ graph._graph.addNodeByContentKey(node.id, node);
314
+ continue;
315
+ }
316
+ }
317
+
318
+ // Apply edges
319
+ for (let i = 0; i < serializedGraph.edges.length; i += 3) {
320
+ const from = serializedGraph.edges[i];
321
+ const to = serializedGraph.edges[i + 1];
322
+ const type = serializedGraph.edges[i + 2];
323
+ const fromNode = graph._graph.getNode(from);
324
+ const toNode = graph._graph.getNode(to);
325
+ if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type) === 'asset' && (toNode === null || toNode === void 0 ? void 0 : toNode.type) === 'dependency') {
326
+ fromNode.value.dependencies.set(toNode.value.id, toNode.value);
327
+ }
328
+
329
+ // If we are adding a references edge, remove existing null edge.
330
+ if (type === _BundleGraph.bundleGraphEdgeTypes.references && graph._graph.hasEdge(from, to, _BundleGraph.bundleGraphEdgeTypes.null)) {
331
+ graph._graph.removeEdge(from, to, _BundleGraph.bundleGraphEdgeTypes.null);
332
+ }
333
+ graph._graph.addEdge(from, to, type);
334
+ }
335
+ return {
336
+ bundleGraph: graph,
337
+ changedAssets
338
+ };
339
+ }
340
+ class NativeBundlerRunner {
341
+ constructor({
342
+ api,
343
+ options
344
+ }, optionsRef) {
345
+ this.options = options;
346
+ this.api = api;
347
+ this.optionsRef = optionsRef;
348
+ this.previousDevDeps = new Map();
349
+ this.devDepRequests = new Map();
350
+ this.configs = new Map();
351
+ this.pluginOptions = new _PluginOptions.default((0, _utils.optionsProxy)(this.options, api.invalidateOnOptionChange));
352
+ const key = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
353
+ this.cacheKey = `BundleGraph/${_constants.ATLASPACK_VERSION}/${options.mode}/${key}`;
354
+ }
355
+ async loadConfigs() {
356
+ const configResult = (0, _nullthrows().default)(await this.api.runRequest((0, _AtlaspackConfigRequest.default)()));
357
+ this.config = (0, _AtlaspackConfigRequest.getCachedAtlaspackConfig)(configResult, this.options);
358
+ const {
359
+ devDeps,
360
+ invalidDevDeps
361
+ } = await (0, _DevDepRequest.getDevDepRequests)(this.api);
362
+ this.previousDevDeps = devDeps;
363
+ (0, _DevDepRequest.invalidateDevDeps)(invalidDevDeps, this.options, this.config);
364
+ const bundler = await this.config.getBundler();
365
+ await this.loadPluginConfig(bundler);
366
+ const namers = await this.config.getNamers();
367
+ for (const namer of namers) {
368
+ await this.loadPluginConfig(namer);
369
+ }
370
+ const runtimes = await this.config.getRuntimes();
371
+ for (const runtime of runtimes) {
372
+ await this.loadPluginConfig(runtime);
373
+ }
374
+ }
375
+ async loadPluginConfig(plugin) {
376
+ await (0, _BundleGraphRequestUtils.loadPluginConfigWithDevDeps)(plugin, this.options, this.api, this.previousDevDeps, this.devDepRequests, this.configs);
377
+ }
378
+ }
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.loadPluginConfigWithDevDeps = loadPluginConfigWithDevDeps;
7
+ exports.nameBundle = nameBundle;
8
+ exports.runDevDepRequest = runDevDepRequest;
9
+ exports.validateBundles = validateBundles;
10
+ function _assert() {
11
+ const data = _interopRequireDefault(require("assert"));
12
+ _assert = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _nullthrows() {
18
+ const data = _interopRequireDefault(require("nullthrows"));
19
+ _nullthrows = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _logger() {
25
+ const data = require("@atlaspack/logger");
26
+ _logger = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _diagnostic() {
32
+ const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
33
+ _diagnostic = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
38
+ function _utils() {
39
+ const data = require("@atlaspack/utils");
40
+ _utils = function () {
41
+ return data;
42
+ };
43
+ return data;
44
+ }
45
+ var _BundleGraph = _interopRequireDefault(require("../public/BundleGraph"));
46
+ var _Bundle = require("../public/Bundle");
47
+ var _InternalConfig = require("../InternalConfig");
48
+ var _DevDepRequest = require("./DevDepRequest");
49
+ var _ConfigRequest = require("./ConfigRequest");
50
+ var _projectPath = require("../projectPath");
51
+ function _profiler() {
52
+ const data = require("@atlaspack/profiler");
53
+ _profiler = function () {
54
+ return data;
55
+ };
56
+ return data;
57
+ }
58
+ 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); }
59
+ 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; }
60
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
+ /**
62
+ * Shared utilities for BundleGraphRequest and BundleGraphRequestRust.
63
+ *
64
+ * This module contains common functionality used by both the JS and native
65
+ * bundling paths, such as bundle validation, naming, and configuration loading.
66
+ */
67
+
68
+ /**
69
+ * Validates that all bundles have unique names.
70
+ * Throws an assertion error if duplicate bundle names are found.
71
+ */
72
+ function validateBundles(bundleGraph) {
73
+ const bundles = bundleGraph.getBundles();
74
+ const bundleNames = bundles.map(b => (0, _projectPath.joinProjectPath)(b.target.distDir, (0, _nullthrows().default)(b.name)));
75
+ _assert().default.deepEqual(bundleNames, (0, _utils().unique)(bundleNames), 'Bundles must have unique name. Conflicting names: ' + [...(0, _utils().setSymmetricDifference)(new Set(bundleNames), new Set((0, _utils().unique)(bundleNames)))].join());
76
+ }
77
+
78
+ /**
79
+ * Names a bundle by running through the configured namers until one returns a name.
80
+ */
81
+ async function nameBundle(namers, internalBundle, internalBundleGraph, options, pluginOptions, configs) {
82
+ const bundle = _Bundle.Bundle.get(internalBundle, internalBundleGraph, options);
83
+ const bundleGraph = new _BundleGraph.default(internalBundleGraph, _Bundle.NamedBundle.get.bind(_Bundle.NamedBundle), options);
84
+ for (const namer of namers) {
85
+ let measurement;
86
+ try {
87
+ var _configs$get;
88
+ measurement = _profiler().tracer.createMeasurement(namer.name, 'namer', bundle.id);
89
+ const name = await namer.plugin.name({
90
+ bundle,
91
+ bundleGraph,
92
+ config: (_configs$get = configs.get(namer.name)) === null || _configs$get === void 0 ? void 0 : _configs$get.result,
93
+ options: pluginOptions,
94
+ logger: new (_logger().PluginLogger)({
95
+ origin: namer.name
96
+ }),
97
+ tracer: new (_profiler().PluginTracer)({
98
+ origin: namer.name,
99
+ category: 'namer'
100
+ })
101
+ });
102
+ if (name != null) {
103
+ internalBundle.name = name;
104
+ const {
105
+ hashReference
106
+ } = internalBundle;
107
+ internalBundle.displayName = name.includes(hashReference) ? name.replace(hashReference, '[hash]') : name;
108
+ return;
109
+ }
110
+ } catch (e) {
111
+ throw new (_diagnostic().default)({
112
+ diagnostic: (0, _diagnostic().errorToDiagnostic)(e, {
113
+ origin: namer.name
114
+ })
115
+ });
116
+ } finally {
117
+ measurement && measurement.end();
118
+ }
119
+ }
120
+ throw new Error('Unable to name bundle');
121
+ }
122
+
123
+ /**
124
+ * Loads configuration for a plugin and tracks its dev dependencies.
125
+ */
126
+ async function loadPluginConfigWithDevDeps(plugin, options, api, previousDevDeps, devDepRequests, configs) {
127
+ const config = (0, _InternalConfig.createConfig)({
128
+ plugin: plugin.name,
129
+ searchPath: (0, _projectPath.toProjectPathUnsafe)('index')
130
+ });
131
+ await (0, _ConfigRequest.loadPluginConfig)(plugin, config, options);
132
+ await (0, _ConfigRequest.runConfigRequest)(api, config);
133
+ for (const devDep of config.devDeps) {
134
+ const devDepRequest = await (0, _DevDepRequest.createDevDependency)(devDep, previousDevDeps, options);
135
+ await runDevDepRequest(api, devDepRequest, devDepRequests);
136
+ }
137
+ configs.set(plugin.name, config);
138
+ }
139
+
140
+ /**
141
+ * Runs a dev dependency request and tracks it in the devDepRequests map.
142
+ */
143
+ async function runDevDepRequest(api, devDepRequest, devDepRequests) {
144
+ const {
145
+ specifier,
146
+ resolveFrom
147
+ } = devDepRequest;
148
+ const key = `${specifier}:${(0, _projectPath.fromProjectPathRelative)(resolveFrom)}`;
149
+ devDepRequests.set(key, devDepRequest);
150
+ await (0, _DevDepRequest.runDevDepRequest)(api, devDepRequest);
151
+ }
@@ -25,6 +25,7 @@ export declare class AtlaspackV3 {
25
25
  static create({ fs, packageManager, threads, lmdb, napiWorkerPool, ...options }: AtlaspackV3Options): Promise<AtlaspackV3>;
26
26
  end(): void;
27
27
  buildAssetGraph(): Promise<any>;
28
+ buildBundleGraph(): Promise<any>;
28
29
  loadBundleGraph(bundleGraph: BundleGraph): Promise<void>;
29
30
  package(bundleId: string): Promise<[RunPackagerRunnerResult, Diagnostic | null]>;
30
31
  respondToFsEvents(events: Array<Event>): Promise<boolean>;
@@ -23,6 +23,7 @@ export declare class AtlaspackWorker {
23
23
  env: {
24
24
  [k: string]: string | undefined;
25
25
  };
26
+ disableCache: boolean | undefined;
26
27
  } | undefined>;
27
28
  }
28
29
  type LoadPluginOptions = {
@@ -0,0 +1,34 @@
1
+ import type { Async } from '@atlaspack/types';
2
+ import InternalBundleGraph from '../BundleGraph';
3
+ import { requestTypes, StaticRunOpts } from '../RequestTracker';
4
+ import type { BundleGraphResult } from './BundleGraphRequest';
5
+ import type { Asset } from '../types';
6
+ type BundleGraphRequestInput = {
7
+ requestedAssetIds: Set<string>;
8
+ signal?: AbortSignal;
9
+ optionsRef: any;
10
+ };
11
+ type RunInput = {
12
+ input: BundleGraphRequestInput;
13
+ } & StaticRunOpts<BundleGraphResult>;
14
+ type BundleGraphRequestRust = {
15
+ id: string;
16
+ readonly type: typeof requestTypes.bundle_graph_request;
17
+ run: (arg1: RunInput) => Async<BundleGraphResult>;
18
+ input: BundleGraphRequestInput;
19
+ };
20
+ type SerializedBundleGraph = {
21
+ nodes: Array<any>;
22
+ edges: Array<number>;
23
+ publicIdByAssetId: {
24
+ [k: string]: string;
25
+ };
26
+ assetPublicIds: Array<string>;
27
+ hadPreviousGraph: boolean;
28
+ };
29
+ export default function createBundleGraphRequestRust(input: BundleGraphRequestInput): BundleGraphRequestRust;
30
+ export declare function getBundleGraph(serializedGraph: SerializedBundleGraph): {
31
+ bundleGraph: InternalBundleGraph;
32
+ changedAssets: Map<string, Asset>;
33
+ };
34
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared utilities for BundleGraphRequest and BundleGraphRequestRust.
3
+ *
4
+ * This module contains common functionality used by both the JS and native
5
+ * bundling paths, such as bundle validation, naming, and configuration loading.
6
+ */
7
+ import type { Namer } from '@atlaspack/types';
8
+ import type { LoadedPlugin } from '../AtlaspackConfig';
9
+ import type { RunAPI } from '../RequestTracker';
10
+ import type { Bundle as InternalBundle, Config, DevDepRequest, AtlaspackOptions, DevDepRequestRef } from '../types';
11
+ import InternalBundleGraph from '../BundleGraph';
12
+ import PluginOptions from '../public/PluginOptions';
13
+ import { PluginWithLoadConfig } from './ConfigRequest';
14
+ import type { BundleGraphResult } from './BundleGraphRequest';
15
+ /**
16
+ * Validates that all bundles have unique names.
17
+ * Throws an assertion error if duplicate bundle names are found.
18
+ */
19
+ export declare function validateBundles(bundleGraph: InternalBundleGraph): void;
20
+ /**
21
+ * Names a bundle by running through the configured namers until one returns a name.
22
+ */
23
+ export declare function nameBundle(namers: Array<LoadedPlugin<Namer<unknown>>>, internalBundle: InternalBundle, internalBundleGraph: InternalBundleGraph, options: AtlaspackOptions, pluginOptions: PluginOptions, configs: Map<string, Config>): Promise<void>;
24
+ /**
25
+ * Loads configuration for a plugin and tracks its dev dependencies.
26
+ */
27
+ export declare function loadPluginConfigWithDevDeps<T extends PluginWithLoadConfig>(plugin: LoadedPlugin<T>, options: AtlaspackOptions, api: RunAPI<BundleGraphResult>, previousDevDeps: Map<string, string>, devDepRequests: Map<string, DevDepRequest | DevDepRequestRef>, configs: Map<string, Config>): Promise<void>;
28
+ /**
29
+ * Runs a dev dependency request and tracks it in the devDepRequests map.
30
+ */
31
+ export declare function runDevDepRequest(api: RunAPI<BundleGraphResult>, devDepRequest: DevDepRequest | DevDepRequestRef, devDepRequests: Map<string, DevDepRequest | DevDepRequestRef>): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.32.1",
3
+ "version": "2.33.1",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,22 +23,22 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@mischnic/json-sourcemap": "^0.1.0",
26
- "@atlaspack/build-cache": "2.13.9",
27
- "@atlaspack/cache": "3.2.46",
26
+ "@atlaspack/build-cache": "2.13.11",
27
+ "@atlaspack/cache": "3.2.48",
28
28
  "@atlaspack/diagnostic": "2.14.4",
29
29
  "@atlaspack/events": "2.14.4",
30
- "@atlaspack/feature-flags": "2.28.0",
31
- "@atlaspack/fs": "2.15.46",
32
- "@atlaspack/graph": "3.6.13",
33
- "@atlaspack/logger": "2.14.43",
34
- "@atlaspack/package-manager": "2.14.51",
35
- "@atlaspack/plugin": "2.14.51",
36
- "@atlaspack/profiler": "2.15.12",
37
- "@atlaspack/rust": "3.21.0",
38
- "@atlaspack/types": "2.15.41",
39
- "@atlaspack/utils": "3.3.3",
40
- "@atlaspack/workers": "2.14.51",
41
- "@atlaspack/source-map": "3.2.6",
30
+ "@atlaspack/feature-flags": "2.29.1",
31
+ "@atlaspack/fs": "2.15.48",
32
+ "@atlaspack/graph": "3.6.15",
33
+ "@atlaspack/logger": "2.14.45",
34
+ "@atlaspack/package-manager": "2.14.53",
35
+ "@atlaspack/plugin": "2.14.53",
36
+ "@atlaspack/profiler": "2.15.14",
37
+ "@atlaspack/rust": "3.22.1",
38
+ "@atlaspack/types": "2.15.43",
39
+ "@atlaspack/utils": "3.3.5",
40
+ "@atlaspack/workers": "2.14.53",
41
+ "@atlaspack/source-map": "3.2.8",
42
42
  "base-x": "^3.0.8",
43
43
  "browserslist": "^4.6.6",
44
44
  "clone": "^2.1.1",
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  atlaspackNapiCreate,
3
3
  atlaspackNapiBuildAssetGraph,
4
+ atlaspackNapiBuildBundleGraph,
4
5
  atlaspackNapiRespondToFsEvents,
5
6
  atlaspackNapiCompleteSession,
6
7
  atlaspackNapiLoadBundleGraph,
@@ -101,6 +102,10 @@ export class AtlaspackV3 {
101
102
  return atlaspackNapiBuildAssetGraph(this._atlaspack_napi) as Promise<any>;
102
103
  }
103
104
 
105
+ buildBundleGraph(): Promise<any> {
106
+ return atlaspackNapiBuildBundleGraph(this._atlaspack_napi) as Promise<any>;
107
+ }
108
+
104
109
  loadBundleGraph(bundleGraph: BundleGraph): Promise<void> {
105
110
  const {nodesJson, edges, publicIdByAssetId, environmentsJson} =
106
111
  bundleGraph.serializeForNative();
@@ -424,6 +424,7 @@ export class AtlaspackWorker {
424
424
  conditions: setupResult?.conditions,
425
425
  config,
426
426
  env: allowedEnv,
427
+ disableCache: setupResult?.disableCache,
427
428
  };
428
429
  }
429
430