rollup 3.0.0-6 → 3.0.0-7
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/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +322 -320
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +0 -8
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +322 -320
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
- package/CHANGELOG.md +0 -6748
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.0.0-
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.0.0-6
|
|
4
|
+
Fri, 23 Sep 2022 04:45:13 GMT - commit 8015be75da6c0861998eb093fb040d0b17679b20
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -28,7 +28,7 @@ function _interopNamespaceDefault(e) {
|
|
|
28
28
|
return n;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
var version$1 = "3.0.0-
|
|
31
|
+
var version$1 = "3.0.0-6";
|
|
32
32
|
|
|
33
33
|
function ensureArray$1(items) {
|
|
34
34
|
if (Array.isArray(items)) {
|
|
@@ -14247,293 +14247,6 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
14247
14247
|
|
|
14248
14248
|
const finalisers = { amd, cjs, es, iife, system, umd };
|
|
14249
14249
|
|
|
14250
|
-
const createHash = () => node_crypto.createHash('sha256');
|
|
14251
|
-
|
|
14252
|
-
// Four random characters from the private use area to minimize risk of conflicts
|
|
14253
|
-
const hashPlaceholderLeft = '!~{';
|
|
14254
|
-
const hashPlaceholderRight = '}~';
|
|
14255
|
-
const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
|
|
14256
|
-
// This is the size of a sha256
|
|
14257
|
-
const maxHashSize = 64;
|
|
14258
|
-
const defaultHashSize = 8;
|
|
14259
|
-
const getHashPlaceholderGenerator = () => {
|
|
14260
|
-
let nextIndex = 0;
|
|
14261
|
-
return (optionName, hashSize = defaultHashSize) => {
|
|
14262
|
-
if (hashSize > maxHashSize) {
|
|
14263
|
-
return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14264
|
-
}
|
|
14265
|
-
const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
|
|
14266
|
-
if (placeholder.length > hashSize) {
|
|
14267
|
-
return error(errFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14268
|
-
}
|
|
14269
|
-
return placeholder;
|
|
14270
|
-
};
|
|
14271
|
-
};
|
|
14272
|
-
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
|
|
14273
|
-
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
14274
|
-
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
14275
|
-
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
14276
|
-
const containedPlaceholders = new Set();
|
|
14277
|
-
const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
|
|
14278
|
-
if (placeholders.has(placeholder)) {
|
|
14279
|
-
containedPlaceholders.add(placeholder);
|
|
14280
|
-
return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
|
|
14281
|
-
}
|
|
14282
|
-
return placeholder;
|
|
14283
|
-
});
|
|
14284
|
-
return { containedPlaceholders, transformedCode };
|
|
14285
|
-
};
|
|
14286
|
-
|
|
14287
|
-
function renderNamePattern(pattern, patternName, replacements) {
|
|
14288
|
-
if (isPathFragment(pattern))
|
|
14289
|
-
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
|
|
14290
|
-
return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
|
|
14291
|
-
if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
|
|
14292
|
-
return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
|
|
14293
|
-
}
|
|
14294
|
-
const replacement = replacements[type](size && parseInt(size.slice(1)));
|
|
14295
|
-
if (isPathFragment(replacement))
|
|
14296
|
-
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14297
|
-
return replacement;
|
|
14298
|
-
});
|
|
14299
|
-
}
|
|
14300
|
-
function makeUnique(name, existingNames) {
|
|
14301
|
-
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
14302
|
-
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14303
|
-
return name;
|
|
14304
|
-
const ext = node_path.extname(name);
|
|
14305
|
-
name = name.substring(0, name.length - ext.length);
|
|
14306
|
-
let uniqueName, uniqueIndex = 1;
|
|
14307
|
-
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14308
|
-
;
|
|
14309
|
-
return uniqueName;
|
|
14310
|
-
}
|
|
14311
|
-
|
|
14312
|
-
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
14313
|
-
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
14314
|
-
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
14315
|
-
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
14316
|
-
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
14317
|
-
ext: () => node_path.extname(emittedName).substring(1),
|
|
14318
|
-
extname: () => node_path.extname(emittedName),
|
|
14319
|
-
hash: size => createHash()
|
|
14320
|
-
.update(source)
|
|
14321
|
-
.digest('hex')
|
|
14322
|
-
.substring(0, size || defaultHashSize),
|
|
14323
|
-
name: () => emittedName.substring(0, emittedName.length - node_path.extname(emittedName).length)
|
|
14324
|
-
}), bundle);
|
|
14325
|
-
}
|
|
14326
|
-
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
14327
|
-
if (fileName in bundle) {
|
|
14328
|
-
warn(errFileNameConflict(fileName));
|
|
14329
|
-
}
|
|
14330
|
-
bundle[fileName] = FILE_PLACEHOLDER;
|
|
14331
|
-
}
|
|
14332
|
-
const FILE_PLACEHOLDER = {
|
|
14333
|
-
type: 'placeholder'
|
|
14334
|
-
};
|
|
14335
|
-
function hasValidType(emittedFile) {
|
|
14336
|
-
return Boolean(emittedFile &&
|
|
14337
|
-
(emittedFile.type === 'asset' ||
|
|
14338
|
-
emittedFile.type === 'chunk'));
|
|
14339
|
-
}
|
|
14340
|
-
function hasValidName(emittedFile) {
|
|
14341
|
-
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
14342
|
-
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
14343
|
-
}
|
|
14344
|
-
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
14345
|
-
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
14346
|
-
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
14347
|
-
return error(errFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
|
|
14348
|
-
}
|
|
14349
|
-
return source;
|
|
14350
|
-
}
|
|
14351
|
-
function getAssetFileName(file, referenceId) {
|
|
14352
|
-
if (typeof file.fileName !== 'string') {
|
|
14353
|
-
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
14354
|
-
}
|
|
14355
|
-
return file.fileName;
|
|
14356
|
-
}
|
|
14357
|
-
function getChunkFileName(file, facadeChunkByModule) {
|
|
14358
|
-
if (file.fileName) {
|
|
14359
|
-
return file.fileName;
|
|
14360
|
-
}
|
|
14361
|
-
if (facadeChunkByModule) {
|
|
14362
|
-
const chunk = facadeChunkByModule.get(file.module);
|
|
14363
|
-
return chunk.id || chunk.getFileName();
|
|
14364
|
-
}
|
|
14365
|
-
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
14366
|
-
}
|
|
14367
|
-
class FileEmitter {
|
|
14368
|
-
constructor(graph, options, baseFileEmitter) {
|
|
14369
|
-
this.graph = graph;
|
|
14370
|
-
this.options = options;
|
|
14371
|
-
this.bundle = null;
|
|
14372
|
-
this.facadeChunkByModule = null;
|
|
14373
|
-
this.outputOptions = null;
|
|
14374
|
-
this.emitFile = (emittedFile) => {
|
|
14375
|
-
if (!hasValidType(emittedFile)) {
|
|
14376
|
-
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
14377
|
-
}
|
|
14378
|
-
if (!hasValidName(emittedFile)) {
|
|
14379
|
-
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
|
|
14380
|
-
}
|
|
14381
|
-
if (emittedFile.type === 'chunk') {
|
|
14382
|
-
return this.emitChunk(emittedFile);
|
|
14383
|
-
}
|
|
14384
|
-
return this.emitAsset(emittedFile);
|
|
14385
|
-
};
|
|
14386
|
-
this.finaliseAssets = () => {
|
|
14387
|
-
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
14388
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
14389
|
-
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
14390
|
-
}
|
|
14391
|
-
};
|
|
14392
|
-
this.getFileName = (fileReferenceId) => {
|
|
14393
|
-
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
14394
|
-
if (!emittedFile)
|
|
14395
|
-
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
14396
|
-
if (emittedFile.type === 'chunk') {
|
|
14397
|
-
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
14398
|
-
}
|
|
14399
|
-
return getAssetFileName(emittedFile, fileReferenceId);
|
|
14400
|
-
};
|
|
14401
|
-
this.setAssetSource = (referenceId, requestedSource) => {
|
|
14402
|
-
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
14403
|
-
if (!consumedFile)
|
|
14404
|
-
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
14405
|
-
if (consumedFile.type !== 'asset') {
|
|
14406
|
-
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
14407
|
-
}
|
|
14408
|
-
if (consumedFile.source !== undefined) {
|
|
14409
|
-
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
14410
|
-
}
|
|
14411
|
-
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
14412
|
-
if (this.bundle) {
|
|
14413
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
14414
|
-
}
|
|
14415
|
-
else {
|
|
14416
|
-
consumedFile.source = source;
|
|
14417
|
-
}
|
|
14418
|
-
};
|
|
14419
|
-
this.setChunkInformation = (facadeChunkByModule) => {
|
|
14420
|
-
this.facadeChunkByModule = facadeChunkByModule;
|
|
14421
|
-
};
|
|
14422
|
-
this.setOutputBundle = (outputBundle, outputOptions) => {
|
|
14423
|
-
this.outputOptions = outputOptions;
|
|
14424
|
-
this.bundle = outputBundle;
|
|
14425
|
-
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
14426
|
-
if (emittedFile.fileName) {
|
|
14427
|
-
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
14428
|
-
}
|
|
14429
|
-
}
|
|
14430
|
-
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
14431
|
-
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
14432
|
-
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
14433
|
-
}
|
|
14434
|
-
}
|
|
14435
|
-
};
|
|
14436
|
-
this.filesByReferenceId = baseFileEmitter
|
|
14437
|
-
? new Map(baseFileEmitter.filesByReferenceId)
|
|
14438
|
-
: new Map();
|
|
14439
|
-
}
|
|
14440
|
-
assignReferenceId(file, idBase) {
|
|
14441
|
-
let referenceId;
|
|
14442
|
-
do {
|
|
14443
|
-
referenceId = createHash()
|
|
14444
|
-
.update(referenceId || idBase)
|
|
14445
|
-
.digest('hex')
|
|
14446
|
-
.substring(0, 8);
|
|
14447
|
-
} while (this.filesByReferenceId.has(referenceId));
|
|
14448
|
-
this.filesByReferenceId.set(referenceId, file);
|
|
14449
|
-
return referenceId;
|
|
14450
|
-
}
|
|
14451
|
-
emitAsset(emittedAsset) {
|
|
14452
|
-
const source = typeof emittedAsset.source !== 'undefined'
|
|
14453
|
-
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
14454
|
-
: undefined;
|
|
14455
|
-
const consumedAsset = {
|
|
14456
|
-
fileName: emittedAsset.fileName,
|
|
14457
|
-
name: emittedAsset.name,
|
|
14458
|
-
source,
|
|
14459
|
-
type: 'asset'
|
|
14460
|
-
};
|
|
14461
|
-
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
14462
|
-
if (this.bundle) {
|
|
14463
|
-
if (emittedAsset.fileName) {
|
|
14464
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
14465
|
-
}
|
|
14466
|
-
if (source !== undefined) {
|
|
14467
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
14468
|
-
}
|
|
14469
|
-
}
|
|
14470
|
-
return referenceId;
|
|
14471
|
-
}
|
|
14472
|
-
emitChunk(emittedChunk) {
|
|
14473
|
-
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
14474
|
-
return error(errInvalidRollupPhaseForChunkEmission());
|
|
14475
|
-
}
|
|
14476
|
-
if (typeof emittedChunk.id !== 'string') {
|
|
14477
|
-
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
14478
|
-
}
|
|
14479
|
-
const consumedChunk = {
|
|
14480
|
-
fileName: emittedChunk.fileName,
|
|
14481
|
-
module: null,
|
|
14482
|
-
name: emittedChunk.name || emittedChunk.id,
|
|
14483
|
-
type: 'chunk'
|
|
14484
|
-
};
|
|
14485
|
-
this.graph.moduleLoader
|
|
14486
|
-
.emitChunk(emittedChunk)
|
|
14487
|
-
.then(module => (consumedChunk.module = module))
|
|
14488
|
-
.catch(() => {
|
|
14489
|
-
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
14490
|
-
// once module loading has finished
|
|
14491
|
-
});
|
|
14492
|
-
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
14493
|
-
}
|
|
14494
|
-
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
14495
|
-
const fileName = consumedFile.fileName ||
|
|
14496
|
-
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
14497
|
-
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
14498
|
-
// We must not modify the original assets to avoid interaction between outputs
|
|
14499
|
-
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
14500
|
-
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
14501
|
-
bundle[fileName] = {
|
|
14502
|
-
fileName,
|
|
14503
|
-
name: consumedFile.name,
|
|
14504
|
-
source,
|
|
14505
|
-
type: 'asset'
|
|
14506
|
-
};
|
|
14507
|
-
}
|
|
14508
|
-
}
|
|
14509
|
-
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
14510
|
-
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
14511
|
-
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
14512
|
-
return fileName;
|
|
14513
|
-
}
|
|
14514
|
-
return null;
|
|
14515
|
-
}
|
|
14516
|
-
function areSourcesEqual(sourceA, sourceB) {
|
|
14517
|
-
if (typeof sourceA === 'string') {
|
|
14518
|
-
return sourceA === sourceB;
|
|
14519
|
-
}
|
|
14520
|
-
if (typeof sourceB === 'string') {
|
|
14521
|
-
return false;
|
|
14522
|
-
}
|
|
14523
|
-
if ('equals' in sourceA) {
|
|
14524
|
-
return sourceA.equals(sourceB);
|
|
14525
|
-
}
|
|
14526
|
-
if (sourceA.length !== sourceB.length) {
|
|
14527
|
-
return false;
|
|
14528
|
-
}
|
|
14529
|
-
for (let index = 0; index < sourceA.length; index++) {
|
|
14530
|
-
if (sourceA[index] !== sourceB[index]) {
|
|
14531
|
-
return false;
|
|
14532
|
-
}
|
|
14533
|
-
}
|
|
14534
|
-
return true;
|
|
14535
|
-
}
|
|
14536
|
-
|
|
14537
14250
|
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
14538
14251
|
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
14539
14252
|
async function createAddons(options, outputPluginDriver, chunk) {
|
|
@@ -14806,6 +14519,93 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
|
|
|
14806
14519
|
}
|
|
14807
14520
|
}
|
|
14808
14521
|
|
|
14522
|
+
// Four random characters from the private use area to minimize risk of conflicts
|
|
14523
|
+
const hashPlaceholderLeft = '!~{';
|
|
14524
|
+
const hashPlaceholderRight = '}~';
|
|
14525
|
+
const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
|
|
14526
|
+
// This is the size of a sha256
|
|
14527
|
+
const maxHashSize = 64;
|
|
14528
|
+
const defaultHashSize = 8;
|
|
14529
|
+
const getHashPlaceholderGenerator = () => {
|
|
14530
|
+
let nextIndex = 0;
|
|
14531
|
+
return (optionName, hashSize = defaultHashSize) => {
|
|
14532
|
+
if (hashSize > maxHashSize) {
|
|
14533
|
+
return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14534
|
+
}
|
|
14535
|
+
const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
|
|
14536
|
+
if (placeholder.length > hashSize) {
|
|
14537
|
+
return error(errFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
|
|
14538
|
+
}
|
|
14539
|
+
return placeholder;
|
|
14540
|
+
};
|
|
14541
|
+
};
|
|
14542
|
+
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
|
|
14543
|
+
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
14544
|
+
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
14545
|
+
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
14546
|
+
const containedPlaceholders = new Set();
|
|
14547
|
+
const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
|
|
14548
|
+
if (placeholders.has(placeholder)) {
|
|
14549
|
+
containedPlaceholders.add(placeholder);
|
|
14550
|
+
return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
|
|
14551
|
+
}
|
|
14552
|
+
return placeholder;
|
|
14553
|
+
});
|
|
14554
|
+
return { containedPlaceholders, transformedCode };
|
|
14555
|
+
};
|
|
14556
|
+
|
|
14557
|
+
const lowercaseBundleKeys = Symbol('bundleKeys');
|
|
14558
|
+
const FILE_PLACEHOLDER = {
|
|
14559
|
+
type: 'placeholder'
|
|
14560
|
+
};
|
|
14561
|
+
const getOutputBundle = (outputBundleBase) => {
|
|
14562
|
+
const reservedLowercaseBundleKeys = new Set();
|
|
14563
|
+
return new Proxy(outputBundleBase, {
|
|
14564
|
+
deleteProperty(target, key) {
|
|
14565
|
+
if (typeof key === 'string') {
|
|
14566
|
+
reservedLowercaseBundleKeys.delete(key.toLowerCase());
|
|
14567
|
+
}
|
|
14568
|
+
return Reflect.deleteProperty(target, key);
|
|
14569
|
+
},
|
|
14570
|
+
get(target, key) {
|
|
14571
|
+
if (key === lowercaseBundleKeys) {
|
|
14572
|
+
return reservedLowercaseBundleKeys;
|
|
14573
|
+
}
|
|
14574
|
+
return Reflect.get(target, key);
|
|
14575
|
+
},
|
|
14576
|
+
set(target, key, value) {
|
|
14577
|
+
if (typeof key === 'string') {
|
|
14578
|
+
reservedLowercaseBundleKeys.add(key.toLowerCase());
|
|
14579
|
+
}
|
|
14580
|
+
return Reflect.set(target, key, value);
|
|
14581
|
+
}
|
|
14582
|
+
});
|
|
14583
|
+
};
|
|
14584
|
+
|
|
14585
|
+
function renderNamePattern(pattern, patternName, replacements) {
|
|
14586
|
+
if (isPathFragment(pattern))
|
|
14587
|
+
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
|
|
14588
|
+
return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
|
|
14589
|
+
if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
|
|
14590
|
+
return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
|
|
14591
|
+
}
|
|
14592
|
+
const replacement = replacements[type](size && parseInt(size.slice(1)));
|
|
14593
|
+
if (isPathFragment(replacement))
|
|
14594
|
+
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14595
|
+
return replacement;
|
|
14596
|
+
});
|
|
14597
|
+
}
|
|
14598
|
+
function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }) {
|
|
14599
|
+
if (!reservedLowercaseBundleKeys.has(name.toLowerCase()))
|
|
14600
|
+
return name;
|
|
14601
|
+
const ext = node_path.extname(name);
|
|
14602
|
+
name = name.substring(0, name.length - ext.length);
|
|
14603
|
+
let uniqueName, uniqueIndex = 1;
|
|
14604
|
+
while (reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14605
|
+
;
|
|
14606
|
+
return uniqueName;
|
|
14607
|
+
}
|
|
14608
|
+
|
|
14809
14609
|
const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.cjs', '.cts'];
|
|
14810
14610
|
function getGlobalName(chunk, globals, hasExports, warn) {
|
|
14811
14611
|
const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
|
|
@@ -16215,6 +16015,8 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
|
|
|
16215
16015
|
return { version: 3, ...map };
|
|
16216
16016
|
}
|
|
16217
16017
|
|
|
16018
|
+
const createHash = () => node_crypto.createHash('sha256');
|
|
16019
|
+
|
|
16218
16020
|
function decodedSourcemap(map) {
|
|
16219
16021
|
if (!map)
|
|
16220
16022
|
return null;
|
|
@@ -16233,7 +16035,7 @@ function decodedSourcemap(map) {
|
|
|
16233
16035
|
return { ...map, mappings };
|
|
16234
16036
|
}
|
|
16235
16037
|
|
|
16236
|
-
async function renderChunks(chunks,
|
|
16038
|
+
async function renderChunks(chunks, bundle, pluginDriver, outputOptions, onwarn) {
|
|
16237
16039
|
timeStart('render chunks', 2);
|
|
16238
16040
|
reserveEntryChunksInBundle(chunks);
|
|
16239
16041
|
const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
|
|
@@ -16241,8 +16043,8 @@ async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, o
|
|
|
16241
16043
|
timeStart('transform chunks', 2);
|
|
16242
16044
|
const chunkGraph = getChunkGraph(chunks);
|
|
16243
16045
|
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
|
|
16244
|
-
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder,
|
|
16245
|
-
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder,
|
|
16046
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
|
|
16047
|
+
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
|
|
16246
16048
|
timeEnd('transform chunks', 2);
|
|
16247
16049
|
}
|
|
16248
16050
|
function reserveEntryChunksInBundle(chunks) {
|
|
@@ -16357,7 +16159,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
16357
16159
|
renderedChunksByPlaceholder
|
|
16358
16160
|
};
|
|
16359
16161
|
}
|
|
16360
|
-
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder,
|
|
16162
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle) {
|
|
16361
16163
|
const hashesByPlaceholder = new Map();
|
|
16362
16164
|
for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
|
|
16363
16165
|
let hash = createHash();
|
|
@@ -16380,13 +16182,13 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
|
|
|
16380
16182
|
}
|
|
16381
16183
|
finalHash = hash.digest('hex').slice(0, placeholder.length);
|
|
16382
16184
|
finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
|
|
16383
|
-
} while (
|
|
16384
|
-
|
|
16385
|
-
hashesByPlaceholder.set(placeholder, finalHash
|
|
16185
|
+
} while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
|
|
16186
|
+
bundle[finalFileName] = FILE_PLACEHOLDER;
|
|
16187
|
+
hashesByPlaceholder.set(placeholder, finalHash);
|
|
16386
16188
|
}
|
|
16387
16189
|
return hashesByPlaceholder;
|
|
16388
16190
|
}
|
|
16389
|
-
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder,
|
|
16191
|
+
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
|
|
16390
16192
|
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
16391
16193
|
let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
16392
16194
|
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
@@ -16394,7 +16196,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
|
|
|
16394
16196
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
16395
16197
|
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
16396
16198
|
}
|
|
16397
|
-
|
|
16199
|
+
bundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16398
16200
|
}
|
|
16399
16201
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16400
16202
|
let updatedCode = hashesByPlaceholder.size
|
|
@@ -16403,7 +16205,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
|
|
|
16403
16205
|
if (map) {
|
|
16404
16206
|
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
16405
16207
|
}
|
|
16406
|
-
|
|
16208
|
+
bundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16407
16209
|
}
|
|
16408
16210
|
}
|
|
16409
16211
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -16433,7 +16235,8 @@ class Bundle {
|
|
|
16433
16235
|
}
|
|
16434
16236
|
async generate(isWrite) {
|
|
16435
16237
|
timeStart('GENERATE', 1);
|
|
16436
|
-
const
|
|
16238
|
+
const outputBundleBase = Object.create(null);
|
|
16239
|
+
const outputBundle = getOutputBundle(outputBundleBase);
|
|
16437
16240
|
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions);
|
|
16438
16241
|
try {
|
|
16439
16242
|
timeStart('initialize render', 2);
|
|
@@ -16465,7 +16268,7 @@ class Bundle {
|
|
|
16465
16268
|
this.finaliseAssets(outputBundle);
|
|
16466
16269
|
timeEnd('generate bundle', 2);
|
|
16467
16270
|
timeEnd('GENERATE', 1);
|
|
16468
|
-
return
|
|
16271
|
+
return outputBundleBase;
|
|
16469
16272
|
}
|
|
16470
16273
|
async addManualChunks(manualChunks) {
|
|
16471
16274
|
const manualChunkAliasByEntry = new Map();
|
|
@@ -16501,17 +16304,19 @@ class Bundle {
|
|
|
16501
16304
|
}
|
|
16502
16305
|
return manualChunkAliasByEntry;
|
|
16503
16306
|
}
|
|
16504
|
-
finaliseAssets(
|
|
16505
|
-
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
|
|
16509
|
-
|
|
16510
|
-
|
|
16511
|
-
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
|
|
16307
|
+
finaliseAssets(bundle) {
|
|
16308
|
+
if (this.outputOptions.validate) {
|
|
16309
|
+
for (const file of Object.values(bundle)) {
|
|
16310
|
+
if ('code' in file) {
|
|
16311
|
+
try {
|
|
16312
|
+
this.graph.contextParse(file.code, {
|
|
16313
|
+
allowHashBang: true,
|
|
16314
|
+
ecmaVersion: 'latest'
|
|
16315
|
+
});
|
|
16316
|
+
}
|
|
16317
|
+
catch (err) {
|
|
16318
|
+
this.inputOptions.onwarn(errChunkInvalid(file, err));
|
|
16319
|
+
}
|
|
16515
16320
|
}
|
|
16516
16321
|
}
|
|
16517
16322
|
}
|
|
@@ -22835,6 +22640,209 @@ class GlobalScope extends Scope$1 {
|
|
|
22835
22640
|
}
|
|
22836
22641
|
}
|
|
22837
22642
|
|
|
22643
|
+
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
22644
|
+
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
22645
|
+
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
22646
|
+
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
22647
|
+
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
22648
|
+
ext: () => node_path.extname(emittedName).substring(1),
|
|
22649
|
+
extname: () => node_path.extname(emittedName),
|
|
22650
|
+
hash: size => createHash()
|
|
22651
|
+
.update(source)
|
|
22652
|
+
.digest('hex')
|
|
22653
|
+
.substring(0, size || defaultHashSize),
|
|
22654
|
+
name: () => emittedName.substring(0, emittedName.length - node_path.extname(emittedName).length)
|
|
22655
|
+
}), bundle);
|
|
22656
|
+
}
|
|
22657
|
+
function reserveFileNameInBundle(fileName, { bundle }, warn) {
|
|
22658
|
+
if (bundle[lowercaseBundleKeys].has(fileName.toLowerCase())) {
|
|
22659
|
+
warn(errFileNameConflict(fileName));
|
|
22660
|
+
}
|
|
22661
|
+
else {
|
|
22662
|
+
bundle[fileName] = FILE_PLACEHOLDER;
|
|
22663
|
+
}
|
|
22664
|
+
}
|
|
22665
|
+
function hasValidType(emittedFile) {
|
|
22666
|
+
return Boolean(emittedFile &&
|
|
22667
|
+
(emittedFile.type === 'asset' ||
|
|
22668
|
+
emittedFile.type === 'chunk'));
|
|
22669
|
+
}
|
|
22670
|
+
function hasValidName(emittedFile) {
|
|
22671
|
+
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
22672
|
+
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
22673
|
+
}
|
|
22674
|
+
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
22675
|
+
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
22676
|
+
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
22677
|
+
return error(errFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
|
|
22678
|
+
}
|
|
22679
|
+
return source;
|
|
22680
|
+
}
|
|
22681
|
+
function getAssetFileName(file, referenceId) {
|
|
22682
|
+
if (typeof file.fileName !== 'string') {
|
|
22683
|
+
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
22684
|
+
}
|
|
22685
|
+
return file.fileName;
|
|
22686
|
+
}
|
|
22687
|
+
function getChunkFileName(file, facadeChunkByModule) {
|
|
22688
|
+
if (file.fileName) {
|
|
22689
|
+
return file.fileName;
|
|
22690
|
+
}
|
|
22691
|
+
if (facadeChunkByModule) {
|
|
22692
|
+
const chunk = facadeChunkByModule.get(file.module);
|
|
22693
|
+
return chunk.id || chunk.getFileName();
|
|
22694
|
+
}
|
|
22695
|
+
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
22696
|
+
}
|
|
22697
|
+
class FileEmitter {
|
|
22698
|
+
constructor(graph, options, baseFileEmitter) {
|
|
22699
|
+
this.graph = graph;
|
|
22700
|
+
this.options = options;
|
|
22701
|
+
this.facadeChunkByModule = null;
|
|
22702
|
+
this.nextIdBase = 1;
|
|
22703
|
+
this.output = null;
|
|
22704
|
+
this.emitFile = (emittedFile) => {
|
|
22705
|
+
if (!hasValidType(emittedFile)) {
|
|
22706
|
+
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
22707
|
+
}
|
|
22708
|
+
if (!hasValidName(emittedFile)) {
|
|
22709
|
+
return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
|
|
22710
|
+
}
|
|
22711
|
+
if (emittedFile.type === 'chunk') {
|
|
22712
|
+
return this.emitChunk(emittedFile);
|
|
22713
|
+
}
|
|
22714
|
+
return this.emitAsset(emittedFile);
|
|
22715
|
+
};
|
|
22716
|
+
this.finaliseAssets = () => {
|
|
22717
|
+
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
22718
|
+
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
22719
|
+
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
22720
|
+
}
|
|
22721
|
+
};
|
|
22722
|
+
this.getFileName = (fileReferenceId) => {
|
|
22723
|
+
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
22724
|
+
if (!emittedFile)
|
|
22725
|
+
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
22726
|
+
if (emittedFile.type === 'chunk') {
|
|
22727
|
+
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
22728
|
+
}
|
|
22729
|
+
return getAssetFileName(emittedFile, fileReferenceId);
|
|
22730
|
+
};
|
|
22731
|
+
this.setAssetSource = (referenceId, requestedSource) => {
|
|
22732
|
+
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
22733
|
+
if (!consumedFile)
|
|
22734
|
+
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
22735
|
+
if (consumedFile.type !== 'asset') {
|
|
22736
|
+
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
22737
|
+
}
|
|
22738
|
+
if (consumedFile.source !== undefined) {
|
|
22739
|
+
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
22740
|
+
}
|
|
22741
|
+
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
22742
|
+
if (this.output) {
|
|
22743
|
+
this.finalizeAsset(consumedFile, source, referenceId, this.output);
|
|
22744
|
+
}
|
|
22745
|
+
else {
|
|
22746
|
+
consumedFile.source = source;
|
|
22747
|
+
}
|
|
22748
|
+
};
|
|
22749
|
+
this.setChunkInformation = (facadeChunkByModule) => {
|
|
22750
|
+
this.facadeChunkByModule = facadeChunkByModule;
|
|
22751
|
+
};
|
|
22752
|
+
this.setOutputBundle = (bundle, outputOptions) => {
|
|
22753
|
+
const fileNamesBySource = new Map();
|
|
22754
|
+
const output = (this.output = { bundle, fileNamesBySource, outputOptions });
|
|
22755
|
+
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
22756
|
+
if (emittedFile.fileName) {
|
|
22757
|
+
reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
|
|
22758
|
+
if (emittedFile.type === 'asset' && typeof emittedFile.source === 'string') {
|
|
22759
|
+
fileNamesBySource.set(emittedFile.source, emittedFile.fileName);
|
|
22760
|
+
}
|
|
22761
|
+
}
|
|
22762
|
+
}
|
|
22763
|
+
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
22764
|
+
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
22765
|
+
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, output);
|
|
22766
|
+
}
|
|
22767
|
+
}
|
|
22768
|
+
};
|
|
22769
|
+
this.filesByReferenceId = baseFileEmitter
|
|
22770
|
+
? new Map(baseFileEmitter.filesByReferenceId)
|
|
22771
|
+
: new Map();
|
|
22772
|
+
}
|
|
22773
|
+
assignReferenceId(file, idBase) {
|
|
22774
|
+
let referenceId;
|
|
22775
|
+
do {
|
|
22776
|
+
referenceId = createHash()
|
|
22777
|
+
.update(referenceId || idBase)
|
|
22778
|
+
.digest('hex')
|
|
22779
|
+
.substring(0, 8);
|
|
22780
|
+
} while (this.filesByReferenceId.has(referenceId));
|
|
22781
|
+
this.filesByReferenceId.set(referenceId, file);
|
|
22782
|
+
return referenceId;
|
|
22783
|
+
}
|
|
22784
|
+
emitAsset(emittedAsset) {
|
|
22785
|
+
const source = typeof emittedAsset.source !== 'undefined'
|
|
22786
|
+
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
22787
|
+
: undefined;
|
|
22788
|
+
const consumedAsset = {
|
|
22789
|
+
fileName: emittedAsset.fileName,
|
|
22790
|
+
name: emittedAsset.name,
|
|
22791
|
+
source,
|
|
22792
|
+
type: 'asset'
|
|
22793
|
+
};
|
|
22794
|
+
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || String(this.nextIdBase++));
|
|
22795
|
+
if (this.output) {
|
|
22796
|
+
if (emittedAsset.fileName) {
|
|
22797
|
+
reserveFileNameInBundle(emittedAsset.fileName, this.output, this.options.onwarn);
|
|
22798
|
+
}
|
|
22799
|
+
if (source !== undefined) {
|
|
22800
|
+
this.finalizeAsset(consumedAsset, source, referenceId, this.output);
|
|
22801
|
+
}
|
|
22802
|
+
}
|
|
22803
|
+
return referenceId;
|
|
22804
|
+
}
|
|
22805
|
+
emitChunk(emittedChunk) {
|
|
22806
|
+
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
22807
|
+
return error(errInvalidRollupPhaseForChunkEmission());
|
|
22808
|
+
}
|
|
22809
|
+
if (typeof emittedChunk.id !== 'string') {
|
|
22810
|
+
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
22811
|
+
}
|
|
22812
|
+
const consumedChunk = {
|
|
22813
|
+
fileName: emittedChunk.fileName,
|
|
22814
|
+
module: null,
|
|
22815
|
+
name: emittedChunk.name || emittedChunk.id,
|
|
22816
|
+
type: 'chunk'
|
|
22817
|
+
};
|
|
22818
|
+
this.graph.moduleLoader
|
|
22819
|
+
.emitChunk(emittedChunk)
|
|
22820
|
+
.then(module => (consumedChunk.module = module))
|
|
22821
|
+
.catch(() => {
|
|
22822
|
+
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
22823
|
+
// once module loading has finished
|
|
22824
|
+
});
|
|
22825
|
+
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
22826
|
+
}
|
|
22827
|
+
finalizeAsset(consumedFile, source, referenceId, { bundle, fileNamesBySource, outputOptions }) {
|
|
22828
|
+
const fileName = consumedFile.fileName ||
|
|
22829
|
+
(typeof source === 'string' && fileNamesBySource.get(source)) ||
|
|
22830
|
+
generateAssetFileName(consumedFile.name, source, outputOptions, bundle);
|
|
22831
|
+
// We must not modify the original assets to avoid interaction between outputs
|
|
22832
|
+
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
22833
|
+
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
22834
|
+
if (typeof source === 'string') {
|
|
22835
|
+
fileNamesBySource.set(source, fileName);
|
|
22836
|
+
}
|
|
22837
|
+
bundle[fileName] = {
|
|
22838
|
+
fileName,
|
|
22839
|
+
name: consumedFile.name,
|
|
22840
|
+
source,
|
|
22841
|
+
type: 'asset'
|
|
22842
|
+
};
|
|
22843
|
+
}
|
|
22844
|
+
}
|
|
22845
|
+
|
|
22838
22846
|
function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
|
|
22839
22847
|
let cacheable = true;
|
|
22840
22848
|
if (typeof plugin.cacheKey !== 'string') {
|
|
@@ -24031,13 +24039,7 @@ function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, out
|
|
|
24031
24039
|
}
|
|
24032
24040
|
function createOutput(outputBundle) {
|
|
24033
24041
|
return {
|
|
24034
|
-
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) =>
|
|
24035
|
-
const fileTypeA = getSortingFileType(outputFileA);
|
|
24036
|
-
const fileTypeB = getSortingFileType(outputFileB);
|
|
24037
|
-
if (fileTypeA === fileTypeB)
|
|
24038
|
-
return 0;
|
|
24039
|
-
return fileTypeA < fileTypeB ? -1 : 1;
|
|
24040
|
-
})
|
|
24042
|
+
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) => getSortingFileType(outputFileA) - getSortingFileType(outputFileB))
|
|
24041
24043
|
};
|
|
24042
24044
|
}
|
|
24043
24045
|
var SortingFileType;
|