@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.
- package/CHANGELOG.md +46 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +3 -0
- package/dist/atlaspack-v3/worker/worker.js +1 -0
- package/dist/requests/AtlaspackBuildRequest.js +12 -5
- package/dist/requests/BundleGraphRequest.js +15 -78
- package/dist/requests/BundleGraphRequestRust.js +320 -0
- package/dist/requests/BundleGraphRequestUtils.js +131 -0
- package/lib/atlaspack-v3/AtlaspackV3.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +2 -1
- package/lib/requests/AtlaspackBuildRequest.js +6 -1
- package/lib/requests/BundleGraphRequest.js +15 -87
- package/lib/requests/BundleGraphRequestRust.js +378 -0
- package/lib/requests/BundleGraphRequestUtils.js +151 -0
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +1 -0
- package/lib/types/atlaspack-v3/worker/worker.d.ts +1 -0
- package/lib/types/requests/BundleGraphRequestRust.d.ts +34 -0
- package/lib/types/requests/BundleGraphRequestUtils.d.ts +31 -0
- package/package.json +15 -15
- package/src/atlaspack-v3/AtlaspackV3.ts +5 -0
- package/src/atlaspack-v3/worker/worker.ts +1 -0
- package/src/requests/AtlaspackBuildRequest.ts +13 -5
- package/src/requests/BundleGraphRequest.ts +25 -100
- package/src/requests/BundleGraphRequestRust.ts +464 -0
- package/src/requests/BundleGraphRequestUtils.ts +167 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,131 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.validateBundles = validateBundles;
|
|
40
|
+
exports.nameBundle = nameBundle;
|
|
41
|
+
exports.loadPluginConfigWithDevDeps = loadPluginConfigWithDevDeps;
|
|
42
|
+
exports.runDevDepRequest = runDevDepRequest;
|
|
43
|
+
const assert_1 = __importDefault(require("assert"));
|
|
44
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
45
|
+
const logger_1 = require("@atlaspack/logger");
|
|
46
|
+
const diagnostic_1 = __importStar(require("@atlaspack/diagnostic"));
|
|
47
|
+
const utils_1 = require("@atlaspack/utils");
|
|
48
|
+
const BundleGraph_1 = __importDefault(require("../public/BundleGraph"));
|
|
49
|
+
const Bundle_1 = require("../public/Bundle");
|
|
50
|
+
const InternalConfig_1 = require("../InternalConfig");
|
|
51
|
+
const DevDepRequest_1 = require("./DevDepRequest");
|
|
52
|
+
const ConfigRequest_1 = require("./ConfigRequest");
|
|
53
|
+
const projectPath_1 = require("../projectPath");
|
|
54
|
+
const profiler_1 = require("@atlaspack/profiler");
|
|
55
|
+
/**
|
|
56
|
+
* Validates that all bundles have unique names.
|
|
57
|
+
* Throws an assertion error if duplicate bundle names are found.
|
|
58
|
+
*/
|
|
59
|
+
function validateBundles(bundleGraph) {
|
|
60
|
+
const bundles = bundleGraph.getBundles();
|
|
61
|
+
const bundleNames = bundles.map((b) => (0, projectPath_1.joinProjectPath)(b.target.distDir, (0, nullthrows_1.default)(b.name)));
|
|
62
|
+
assert_1.default.deepEqual(bundleNames, (0, utils_1.unique)(bundleNames), 'Bundles must have unique name. Conflicting names: ' +
|
|
63
|
+
[
|
|
64
|
+
...(0, utils_1.setSymmetricDifference)(new Set(bundleNames), new Set((0, utils_1.unique)(bundleNames))),
|
|
65
|
+
].join());
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Names a bundle by running through the configured namers until one returns a name.
|
|
69
|
+
*/
|
|
70
|
+
async function nameBundle(namers, internalBundle, internalBundleGraph, options, pluginOptions, configs) {
|
|
71
|
+
const bundle = Bundle_1.Bundle.get(internalBundle, internalBundleGraph, options);
|
|
72
|
+
const bundleGraph = new BundleGraph_1.default(internalBundleGraph, Bundle_1.NamedBundle.get.bind(Bundle_1.NamedBundle), options);
|
|
73
|
+
for (const namer of namers) {
|
|
74
|
+
let measurement;
|
|
75
|
+
try {
|
|
76
|
+
measurement = profiler_1.tracer.createMeasurement(namer.name, 'namer', bundle.id);
|
|
77
|
+
const name = await namer.plugin.name({
|
|
78
|
+
bundle,
|
|
79
|
+
bundleGraph,
|
|
80
|
+
config: configs.get(namer.name)?.result,
|
|
81
|
+
options: pluginOptions,
|
|
82
|
+
logger: new logger_1.PluginLogger({ origin: namer.name }),
|
|
83
|
+
tracer: new profiler_1.PluginTracer({ origin: namer.name, category: 'namer' }),
|
|
84
|
+
});
|
|
85
|
+
if (name != null) {
|
|
86
|
+
internalBundle.name = name;
|
|
87
|
+
const { hashReference } = internalBundle;
|
|
88
|
+
internalBundle.displayName = name.includes(hashReference)
|
|
89
|
+
? name.replace(hashReference, '[hash]')
|
|
90
|
+
: name;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
throw new diagnostic_1.default({
|
|
96
|
+
diagnostic: (0, diagnostic_1.errorToDiagnostic)(e, {
|
|
97
|
+
origin: namer.name,
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
measurement && measurement.end();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throw new Error('Unable to name bundle');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Loads configuration for a plugin and tracks its dev dependencies.
|
|
109
|
+
*/
|
|
110
|
+
async function loadPluginConfigWithDevDeps(plugin, options, api, previousDevDeps, devDepRequests, configs) {
|
|
111
|
+
const config = (0, InternalConfig_1.createConfig)({
|
|
112
|
+
plugin: plugin.name,
|
|
113
|
+
searchPath: (0, projectPath_1.toProjectPathUnsafe)('index'),
|
|
114
|
+
});
|
|
115
|
+
await (0, ConfigRequest_1.loadPluginConfig)(plugin, config, options);
|
|
116
|
+
await (0, ConfigRequest_1.runConfigRequest)(api, config);
|
|
117
|
+
for (const devDep of config.devDeps) {
|
|
118
|
+
const devDepRequest = await (0, DevDepRequest_1.createDevDependency)(devDep, previousDevDeps, options);
|
|
119
|
+
await runDevDepRequest(api, devDepRequest, devDepRequests);
|
|
120
|
+
}
|
|
121
|
+
configs.set(plugin.name, config);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Runs a dev dependency request and tracks it in the devDepRequests map.
|
|
125
|
+
*/
|
|
126
|
+
async function runDevDepRequest(api, devDepRequest, devDepRequests) {
|
|
127
|
+
const { specifier, resolveFrom } = devDepRequest;
|
|
128
|
+
const key = `${specifier}:${(0, projectPath_1.fromProjectPathRelative)(resolveFrom)}`;
|
|
129
|
+
devDepRequests.set(key, devDepRequest);
|
|
130
|
+
await (0, DevDepRequest_1.runDevDepRequest)(api, devDepRequest);
|
|
131
|
+
}
|
|
@@ -72,6 +72,9 @@ class AtlaspackV3 {
|
|
|
72
72
|
buildAssetGraph() {
|
|
73
73
|
return (0, _rust().atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
|
|
74
74
|
}
|
|
75
|
+
buildBundleGraph() {
|
|
76
|
+
return (0, _rust().atlaspackNapiBuildBundleGraph)(this._atlaspack_napi);
|
|
77
|
+
}
|
|
75
78
|
loadBundleGraph(bundleGraph) {
|
|
76
79
|
const {
|
|
77
80
|
nodesJson,
|
|
@@ -381,7 +381,8 @@ class AtlaspackWorker {
|
|
|
381
381
|
setup = {
|
|
382
382
|
conditions: setupResult === null || setupResult === void 0 ? void 0 : setupResult.conditions,
|
|
383
383
|
config,
|
|
384
|
-
env: allowedEnv
|
|
384
|
+
env: allowedEnv,
|
|
385
|
+
disableCache: setupResult === null || setupResult === void 0 ? void 0 : setupResult.disableCache
|
|
385
386
|
};
|
|
386
387
|
}
|
|
387
388
|
this.#transformers.set(specifier, {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = createAtlaspackBuildRequest;
|
|
7
7
|
var _BundleGraphRequest = _interopRequireDefault(require("./BundleGraphRequest"));
|
|
8
|
+
var _BundleGraphRequestRust = _interopRequireDefault(require("./BundleGraphRequestRust"));
|
|
8
9
|
var _WriteBundlesRequest = _interopRequireDefault(require("./WriteBundlesRequest"));
|
|
9
10
|
var _utils = require("../utils");
|
|
10
11
|
var _dumpGraphToGraphViz = _interopRequireDefault(require("../dumpGraphToGraphViz"));
|
|
@@ -49,7 +50,11 @@ async function run({
|
|
|
49
50
|
requestedAssetIds,
|
|
50
51
|
signal
|
|
51
52
|
} = input;
|
|
52
|
-
let bundleGraphRequest = (0,
|
|
53
|
+
let bundleGraphRequest = (0, _featureFlags().getFeatureFlag)('nativeBundling') && rustAtlaspack ? (0, _BundleGraphRequestRust.default)({
|
|
54
|
+
optionsRef,
|
|
55
|
+
requestedAssetIds,
|
|
56
|
+
signal
|
|
57
|
+
}) : (0, _BundleGraphRequest.default)({
|
|
53
58
|
optionsRef,
|
|
54
59
|
requestedAssetIds,
|
|
55
60
|
signal
|
|
@@ -46,19 +46,10 @@ function _diagnostic() {
|
|
|
46
46
|
};
|
|
47
47
|
return data;
|
|
48
48
|
}
|
|
49
|
-
var _BundleGraph =
|
|
50
|
-
var _BundleGraph2 = _interopRequireWildcard(require("../BundleGraph"));
|
|
49
|
+
var _BundleGraph = _interopRequireWildcard(require("../BundleGraph"));
|
|
51
50
|
var _MutableBundleGraph = _interopRequireDefault(require("../public/MutableBundleGraph"));
|
|
52
|
-
var _Bundle = require("../public/Bundle");
|
|
53
51
|
var _ReporterRunner = require("../ReporterRunner");
|
|
54
52
|
var _dumpGraphToGraphViz = _interopRequireDefault(require("../dumpGraphToGraphViz"));
|
|
55
|
-
function _utils() {
|
|
56
|
-
const data = require("@atlaspack/utils");
|
|
57
|
-
_utils = function () {
|
|
58
|
-
return data;
|
|
59
|
-
};
|
|
60
|
-
return data;
|
|
61
|
-
}
|
|
62
53
|
function _rust() {
|
|
63
54
|
const data = require("@atlaspack/rust");
|
|
64
55
|
_rust = function () {
|
|
@@ -69,12 +60,11 @@ function _rust() {
|
|
|
69
60
|
var _PluginOptions = _interopRequireDefault(require("../public/PluginOptions"));
|
|
70
61
|
var _applyRuntimes = _interopRequireDefault(require("../applyRuntimes"));
|
|
71
62
|
var _constants = require("../constants");
|
|
72
|
-
var
|
|
63
|
+
var _utils = require("../utils");
|
|
73
64
|
var _AtlaspackConfigRequest = _interopRequireWildcard(require("./AtlaspackConfigRequest"));
|
|
74
65
|
var _DevDepRequest = require("./DevDepRequest");
|
|
75
|
-
var _InternalConfig = require("../InternalConfig");
|
|
76
|
-
var _ConfigRequest = require("./ConfigRequest");
|
|
77
66
|
var _projectPath = require("../projectPath");
|
|
67
|
+
var _BundleGraphRequestUtils = require("./BundleGraphRequestUtils");
|
|
78
68
|
var _AssetGraphRequest = _interopRequireDefault(require("./AssetGraphRequest"));
|
|
79
69
|
var _AssetGraphRequestRust = require("./AssetGraphRequestRust");
|
|
80
70
|
function _profiler() {
|
|
@@ -188,7 +178,7 @@ function createBundleGraphRequest(input) {
|
|
|
188
178
|
// }
|
|
189
179
|
|
|
190
180
|
measurement && measurement.end();
|
|
191
|
-
(0,
|
|
181
|
+
(0, _utils.assertSignalNotAborted)(signal);
|
|
192
182
|
|
|
193
183
|
// If any subrequests are invalid (e.g. dev dep requests or config requests),
|
|
194
184
|
// bail on incremental bundling. We also need to invalidate for option changes,
|
|
@@ -199,7 +189,7 @@ function createBundleGraphRequest(input) {
|
|
|
199
189
|
assetGraph.setNeedsBundling();
|
|
200
190
|
}
|
|
201
191
|
let configResult = (0, _nullthrows().default)(await input.api.runRequest((0, _AtlaspackConfigRequest.default)()));
|
|
202
|
-
(0,
|
|
192
|
+
(0, _utils.assertSignalNotAborted)(signal);
|
|
203
193
|
let atlaspackConfig = (0, _AtlaspackConfigRequest.getCachedAtlaspackConfig)(configResult, input.options);
|
|
204
194
|
let {
|
|
205
195
|
devDeps,
|
|
@@ -219,7 +209,7 @@ function createBundleGraphRequest(input) {
|
|
|
219
209
|
}
|
|
220
210
|
await (0, _dumpGraphToGraphViz.default)(
|
|
221
211
|
// @ts-expect-error TS2345
|
|
222
|
-
res.bundleGraph._graph, 'BundleGraph',
|
|
212
|
+
res.bundleGraph._graph, 'BundleGraph', _BundleGraph.bundleGraphEdgeTypes);
|
|
223
213
|
return res;
|
|
224
214
|
},
|
|
225
215
|
input
|
|
@@ -238,7 +228,7 @@ class BundlerRunner {
|
|
|
238
228
|
this.previousDevDeps = previousDevDeps;
|
|
239
229
|
this.devDepRequests = new Map();
|
|
240
230
|
this.configs = new Map();
|
|
241
|
-
this.pluginOptions = new _PluginOptions.default((0,
|
|
231
|
+
this.pluginOptions = new _PluginOptions.default((0, _utils.optionsProxy)(this.options, api.invalidateOnOptionChange));
|
|
242
232
|
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
243
233
|
const key = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
|
|
244
234
|
this.cacheKey = `BundleGraph/${_constants.ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
@@ -260,26 +250,10 @@ class BundlerRunner {
|
|
|
260
250
|
}
|
|
261
251
|
}
|
|
262
252
|
async loadConfig(plugin) {
|
|
263
|
-
|
|
264
|
-
plugin: plugin.name,
|
|
265
|
-
searchPath: (0, _projectPath.toProjectPathUnsafe)('index')
|
|
266
|
-
});
|
|
267
|
-
await (0, _ConfigRequest.loadPluginConfig)(plugin, config, this.options);
|
|
268
|
-
await (0, _ConfigRequest.runConfigRequest)(this.api, config);
|
|
269
|
-
for (let devDep of config.devDeps) {
|
|
270
|
-
let devDepRequest = await (0, _DevDepRequest.createDevDependency)(devDep, this.previousDevDeps, this.options);
|
|
271
|
-
await this.runDevDepRequest(devDepRequest);
|
|
272
|
-
}
|
|
273
|
-
this.configs.set(plugin.name, config);
|
|
253
|
+
await (0, _BundleGraphRequestUtils.loadPluginConfigWithDevDeps)(plugin, this.options, this.api, this.previousDevDeps, this.devDepRequests, this.configs);
|
|
274
254
|
}
|
|
275
255
|
async runDevDepRequest(devDepRequest) {
|
|
276
|
-
|
|
277
|
-
specifier,
|
|
278
|
-
resolveFrom
|
|
279
|
-
} = devDepRequest;
|
|
280
|
-
let key = `${specifier}:${(0, _projectPath.fromProjectPathRelative)(resolveFrom)}`;
|
|
281
|
-
this.devDepRequests.set(key, devDepRequest);
|
|
282
|
-
await (0, _DevDepRequest.runDevDepRequest)(this.api, devDepRequest);
|
|
256
|
+
await (0, _BundleGraphRequestUtils.runDevDepRequest)(this.api, devDepRequest, this.devDepRequests);
|
|
283
257
|
}
|
|
284
258
|
async bundle({
|
|
285
259
|
graph,
|
|
@@ -324,12 +298,12 @@ class BundlerRunner {
|
|
|
324
298
|
}
|
|
325
299
|
} else {
|
|
326
300
|
var _this$configs$get;
|
|
327
|
-
internalBundleGraph =
|
|
301
|
+
internalBundleGraph = _BundleGraph.default.fromAssetGraph(graph, this.options.mode === 'production');
|
|
328
302
|
(0, _assert().default)(internalBundleGraph != null); // ensures the graph was created
|
|
329
303
|
|
|
330
304
|
await (0, _dumpGraphToGraphViz.default)(
|
|
331
305
|
// @ts-expect-error TS2345
|
|
332
|
-
internalBundleGraph._graph, 'before_bundle',
|
|
306
|
+
internalBundleGraph._graph, 'before_bundle', _BundleGraph.bundleGraphEdgeTypes);
|
|
333
307
|
let mutableBundleGraph = new _MutableBundleGraph.default(internalBundleGraph, this.options);
|
|
334
308
|
let measurement;
|
|
335
309
|
let measurementFilename;
|
|
@@ -400,7 +374,7 @@ class BundlerRunner {
|
|
|
400
374
|
if (internalBundleGraph != null) {
|
|
401
375
|
await (0, _dumpGraphToGraphViz.default)(
|
|
402
376
|
// @ts-expect-error TS2345
|
|
403
|
-
internalBundleGraph._graph, 'after_bundle',
|
|
377
|
+
internalBundleGraph._graph, 'after_bundle', _BundleGraph.bundleGraphEdgeTypes);
|
|
404
378
|
}
|
|
405
379
|
}
|
|
406
380
|
let changedRuntimes = new Map();
|
|
@@ -411,7 +385,7 @@ class BundlerRunner {
|
|
|
411
385
|
let bundles = internalBundleGraph.getBundles({
|
|
412
386
|
includeInline: true
|
|
413
387
|
});
|
|
414
|
-
await Promise.all(bundles.map(bundle =>
|
|
388
|
+
await Promise.all(bundles.map(bundle => (0, _BundleGraphRequestUtils.nameBundle)(namers, bundle, internalBundleGraph, this.options, this.pluginOptions, this.configs)));
|
|
415
389
|
changedRuntimes = await (0, _logger().instrumentAsync)('applyRuntimes', () => (0, _applyRuntimes.default)({
|
|
416
390
|
bundleGraph: internalBundleGraph,
|
|
417
391
|
api: this.api,
|
|
@@ -432,14 +406,14 @@ class BundlerRunner {
|
|
|
432
406
|
}, this.previousDevDeps, this.options);
|
|
433
407
|
await this.runDevDepRequest(devDepRequest);
|
|
434
408
|
}
|
|
435
|
-
|
|
409
|
+
(0, _BundleGraphRequestUtils.validateBundles)(internalBundleGraph);
|
|
436
410
|
|
|
437
411
|
// Pre-compute the hashes for each bundle so they are only computed once and shared between workers.
|
|
438
412
|
internalBundleGraph.getBundleGraphHash();
|
|
439
413
|
}
|
|
440
414
|
await (0, _dumpGraphToGraphViz.default)(
|
|
441
415
|
// @ts-expect-error TS2345
|
|
442
|
-
internalBundleGraph._graph, 'after_runtimes',
|
|
416
|
+
internalBundleGraph._graph, 'after_runtimes', _BundleGraph.bundleGraphEdgeTypes);
|
|
443
417
|
this.api.storeResult({
|
|
444
418
|
bundleGraph: internalBundleGraph,
|
|
445
419
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
@@ -453,50 +427,4 @@ class BundlerRunner {
|
|
|
453
427
|
assetRequests
|
|
454
428
|
};
|
|
455
429
|
}
|
|
456
|
-
validateBundles(bundleGraph) {
|
|
457
|
-
let bundles = bundleGraph.getBundles();
|
|
458
|
-
let bundleNames = bundles.map(b => (0, _projectPath.joinProjectPath)(b.target.distDir, (0, _nullthrows().default)(b.name)));
|
|
459
|
-
_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());
|
|
460
|
-
}
|
|
461
|
-
async nameBundle(namers, internalBundle, internalBundleGraph) {
|
|
462
|
-
let bundle = _Bundle.Bundle.get(internalBundle, internalBundleGraph, this.options);
|
|
463
|
-
let bundleGraph = new _BundleGraph.default(internalBundleGraph, _Bundle.NamedBundle.get.bind(_Bundle.NamedBundle), this.options);
|
|
464
|
-
for (let namer of namers) {
|
|
465
|
-
let measurement;
|
|
466
|
-
try {
|
|
467
|
-
var _this$configs$get3;
|
|
468
|
-
measurement = _profiler().tracer.createMeasurement(namer.name, 'namer', bundle.id);
|
|
469
|
-
let name = await namer.plugin.name({
|
|
470
|
-
bundle,
|
|
471
|
-
bundleGraph,
|
|
472
|
-
config: (_this$configs$get3 = this.configs.get(namer.name)) === null || _this$configs$get3 === void 0 ? void 0 : _this$configs$get3.result,
|
|
473
|
-
options: this.pluginOptions,
|
|
474
|
-
logger: new (_logger().PluginLogger)({
|
|
475
|
-
origin: namer.name
|
|
476
|
-
}),
|
|
477
|
-
tracer: new (_profiler().PluginTracer)({
|
|
478
|
-
origin: namer.name,
|
|
479
|
-
category: 'namer'
|
|
480
|
-
})
|
|
481
|
-
});
|
|
482
|
-
if (name != null) {
|
|
483
|
-
internalBundle.name = name;
|
|
484
|
-
let {
|
|
485
|
-
hashReference
|
|
486
|
-
} = internalBundle;
|
|
487
|
-
internalBundle.displayName = name.includes(hashReference) ? name.replace(hashReference, '[hash]') : name;
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
} catch (e) {
|
|
491
|
-
throw new (_diagnostic().default)({
|
|
492
|
-
diagnostic: (0, _diagnostic().errorToDiagnostic)(e, {
|
|
493
|
-
origin: namer.name
|
|
494
|
-
})
|
|
495
|
-
});
|
|
496
|
-
} finally {
|
|
497
|
-
measurement && measurement.end();
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
throw new Error('Unable to name bundle');
|
|
501
|
-
}
|
|
502
430
|
}
|