rollup 3.0.0-5 → 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 +323 -322
- 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 +323 -322
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
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)) {
|
|
@@ -6640,7 +6640,7 @@ function toBase64(num) {
|
|
|
6640
6640
|
let outStr = '';
|
|
6641
6641
|
do {
|
|
6642
6642
|
const curDigit = num % base;
|
|
6643
|
-
num =
|
|
6643
|
+
num = (num / base) | 0;
|
|
6644
6644
|
outStr = chars[curDigit] + outStr;
|
|
6645
6645
|
} while (num !== 0);
|
|
6646
6646
|
return outStr;
|
|
@@ -14247,294 +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 = '\uf7f9\ue4d3';
|
|
14254
|
-
const hashPlaceholderRight = '\ue3cc\uf1fe';
|
|
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}${String(++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
|
-
nextIndex++;
|
|
14270
|
-
return placeholder;
|
|
14271
|
-
};
|
|
14272
|
-
};
|
|
14273
|
-
const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}\\d{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
|
|
14274
|
-
const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
|
|
14275
|
-
const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
|
|
14276
|
-
const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
|
|
14277
|
-
const containedPlaceholders = new Set();
|
|
14278
|
-
const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
|
|
14279
|
-
if (placeholders.has(placeholder)) {
|
|
14280
|
-
containedPlaceholders.add(placeholder);
|
|
14281
|
-
return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
|
|
14282
|
-
}
|
|
14283
|
-
return placeholder;
|
|
14284
|
-
});
|
|
14285
|
-
return { containedPlaceholders, transformedCode };
|
|
14286
|
-
};
|
|
14287
|
-
|
|
14288
|
-
function renderNamePattern(pattern, patternName, replacements) {
|
|
14289
|
-
if (isPathFragment(pattern))
|
|
14290
|
-
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.`));
|
|
14291
|
-
return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
|
|
14292
|
-
if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
|
|
14293
|
-
return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
|
|
14294
|
-
}
|
|
14295
|
-
const replacement = replacements[type](size && parseInt(size.slice(1)));
|
|
14296
|
-
if (isPathFragment(replacement))
|
|
14297
|
-
return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
|
|
14298
|
-
return replacement;
|
|
14299
|
-
});
|
|
14300
|
-
}
|
|
14301
|
-
function makeUnique(name, existingNames) {
|
|
14302
|
-
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
14303
|
-
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14304
|
-
return name;
|
|
14305
|
-
const ext = node_path.extname(name);
|
|
14306
|
-
name = name.substring(0, name.length - ext.length);
|
|
14307
|
-
let uniqueName, uniqueIndex = 1;
|
|
14308
|
-
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14309
|
-
;
|
|
14310
|
-
return uniqueName;
|
|
14311
|
-
}
|
|
14312
|
-
|
|
14313
|
-
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
14314
|
-
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
14315
|
-
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
14316
|
-
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
14317
|
-
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
14318
|
-
ext: () => node_path.extname(emittedName).substring(1),
|
|
14319
|
-
extname: () => node_path.extname(emittedName),
|
|
14320
|
-
hash: size => createHash()
|
|
14321
|
-
.update(source)
|
|
14322
|
-
.digest('hex')
|
|
14323
|
-
.substring(0, size || defaultHashSize),
|
|
14324
|
-
name: () => emittedName.substring(0, emittedName.length - node_path.extname(emittedName).length)
|
|
14325
|
-
}), bundle);
|
|
14326
|
-
}
|
|
14327
|
-
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
14328
|
-
if (fileName in bundle) {
|
|
14329
|
-
warn(errFileNameConflict(fileName));
|
|
14330
|
-
}
|
|
14331
|
-
bundle[fileName] = FILE_PLACEHOLDER;
|
|
14332
|
-
}
|
|
14333
|
-
const FILE_PLACEHOLDER = {
|
|
14334
|
-
type: 'placeholder'
|
|
14335
|
-
};
|
|
14336
|
-
function hasValidType(emittedFile) {
|
|
14337
|
-
return Boolean(emittedFile &&
|
|
14338
|
-
(emittedFile.type === 'asset' ||
|
|
14339
|
-
emittedFile.type === 'chunk'));
|
|
14340
|
-
}
|
|
14341
|
-
function hasValidName(emittedFile) {
|
|
14342
|
-
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
14343
|
-
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
14344
|
-
}
|
|
14345
|
-
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
14346
|
-
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
14347
|
-
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
14348
|
-
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.`));
|
|
14349
|
-
}
|
|
14350
|
-
return source;
|
|
14351
|
-
}
|
|
14352
|
-
function getAssetFileName(file, referenceId) {
|
|
14353
|
-
if (typeof file.fileName !== 'string') {
|
|
14354
|
-
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
14355
|
-
}
|
|
14356
|
-
return file.fileName;
|
|
14357
|
-
}
|
|
14358
|
-
function getChunkFileName(file, facadeChunkByModule) {
|
|
14359
|
-
if (file.fileName) {
|
|
14360
|
-
return file.fileName;
|
|
14361
|
-
}
|
|
14362
|
-
if (facadeChunkByModule) {
|
|
14363
|
-
const chunk = facadeChunkByModule.get(file.module);
|
|
14364
|
-
return chunk.id || chunk.getFileName();
|
|
14365
|
-
}
|
|
14366
|
-
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
14367
|
-
}
|
|
14368
|
-
class FileEmitter {
|
|
14369
|
-
constructor(graph, options, baseFileEmitter) {
|
|
14370
|
-
this.graph = graph;
|
|
14371
|
-
this.options = options;
|
|
14372
|
-
this.bundle = null;
|
|
14373
|
-
this.facadeChunkByModule = null;
|
|
14374
|
-
this.outputOptions = null;
|
|
14375
|
-
this.emitFile = (emittedFile) => {
|
|
14376
|
-
if (!hasValidType(emittedFile)) {
|
|
14377
|
-
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
14378
|
-
}
|
|
14379
|
-
if (!hasValidName(emittedFile)) {
|
|
14380
|
-
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}".`));
|
|
14381
|
-
}
|
|
14382
|
-
if (emittedFile.type === 'chunk') {
|
|
14383
|
-
return this.emitChunk(emittedFile);
|
|
14384
|
-
}
|
|
14385
|
-
return this.emitAsset(emittedFile);
|
|
14386
|
-
};
|
|
14387
|
-
this.finaliseAssets = () => {
|
|
14388
|
-
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
14389
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
14390
|
-
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
14391
|
-
}
|
|
14392
|
-
};
|
|
14393
|
-
this.getFileName = (fileReferenceId) => {
|
|
14394
|
-
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
14395
|
-
if (!emittedFile)
|
|
14396
|
-
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
14397
|
-
if (emittedFile.type === 'chunk') {
|
|
14398
|
-
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
14399
|
-
}
|
|
14400
|
-
return getAssetFileName(emittedFile, fileReferenceId);
|
|
14401
|
-
};
|
|
14402
|
-
this.setAssetSource = (referenceId, requestedSource) => {
|
|
14403
|
-
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
14404
|
-
if (!consumedFile)
|
|
14405
|
-
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
14406
|
-
if (consumedFile.type !== 'asset') {
|
|
14407
|
-
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
14408
|
-
}
|
|
14409
|
-
if (consumedFile.source !== undefined) {
|
|
14410
|
-
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
14411
|
-
}
|
|
14412
|
-
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
14413
|
-
if (this.bundle) {
|
|
14414
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
14415
|
-
}
|
|
14416
|
-
else {
|
|
14417
|
-
consumedFile.source = source;
|
|
14418
|
-
}
|
|
14419
|
-
};
|
|
14420
|
-
this.setChunkInformation = (facadeChunkByModule) => {
|
|
14421
|
-
this.facadeChunkByModule = facadeChunkByModule;
|
|
14422
|
-
};
|
|
14423
|
-
this.setOutputBundle = (outputBundle, outputOptions) => {
|
|
14424
|
-
this.outputOptions = outputOptions;
|
|
14425
|
-
this.bundle = outputBundle;
|
|
14426
|
-
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
14427
|
-
if (emittedFile.fileName) {
|
|
14428
|
-
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
14429
|
-
}
|
|
14430
|
-
}
|
|
14431
|
-
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
14432
|
-
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
14433
|
-
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
14434
|
-
}
|
|
14435
|
-
}
|
|
14436
|
-
};
|
|
14437
|
-
this.filesByReferenceId = baseFileEmitter
|
|
14438
|
-
? new Map(baseFileEmitter.filesByReferenceId)
|
|
14439
|
-
: new Map();
|
|
14440
|
-
}
|
|
14441
|
-
assignReferenceId(file, idBase) {
|
|
14442
|
-
let referenceId;
|
|
14443
|
-
do {
|
|
14444
|
-
referenceId = createHash()
|
|
14445
|
-
.update(referenceId || idBase)
|
|
14446
|
-
.digest('hex')
|
|
14447
|
-
.substring(0, 8);
|
|
14448
|
-
} while (this.filesByReferenceId.has(referenceId));
|
|
14449
|
-
this.filesByReferenceId.set(referenceId, file);
|
|
14450
|
-
return referenceId;
|
|
14451
|
-
}
|
|
14452
|
-
emitAsset(emittedAsset) {
|
|
14453
|
-
const source = typeof emittedAsset.source !== 'undefined'
|
|
14454
|
-
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
14455
|
-
: undefined;
|
|
14456
|
-
const consumedAsset = {
|
|
14457
|
-
fileName: emittedAsset.fileName,
|
|
14458
|
-
name: emittedAsset.name,
|
|
14459
|
-
source,
|
|
14460
|
-
type: 'asset'
|
|
14461
|
-
};
|
|
14462
|
-
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
14463
|
-
if (this.bundle) {
|
|
14464
|
-
if (emittedAsset.fileName) {
|
|
14465
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
14466
|
-
}
|
|
14467
|
-
if (source !== undefined) {
|
|
14468
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
14469
|
-
}
|
|
14470
|
-
}
|
|
14471
|
-
return referenceId;
|
|
14472
|
-
}
|
|
14473
|
-
emitChunk(emittedChunk) {
|
|
14474
|
-
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
14475
|
-
return error(errInvalidRollupPhaseForChunkEmission());
|
|
14476
|
-
}
|
|
14477
|
-
if (typeof emittedChunk.id !== 'string') {
|
|
14478
|
-
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
14479
|
-
}
|
|
14480
|
-
const consumedChunk = {
|
|
14481
|
-
fileName: emittedChunk.fileName,
|
|
14482
|
-
module: null,
|
|
14483
|
-
name: emittedChunk.name || emittedChunk.id,
|
|
14484
|
-
type: 'chunk'
|
|
14485
|
-
};
|
|
14486
|
-
this.graph.moduleLoader
|
|
14487
|
-
.emitChunk(emittedChunk)
|
|
14488
|
-
.then(module => (consumedChunk.module = module))
|
|
14489
|
-
.catch(() => {
|
|
14490
|
-
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
14491
|
-
// once module loading has finished
|
|
14492
|
-
});
|
|
14493
|
-
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
14494
|
-
}
|
|
14495
|
-
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
14496
|
-
const fileName = consumedFile.fileName ||
|
|
14497
|
-
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
14498
|
-
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
14499
|
-
// We must not modify the original assets to avoid interaction between outputs
|
|
14500
|
-
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
14501
|
-
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
14502
|
-
bundle[fileName] = {
|
|
14503
|
-
fileName,
|
|
14504
|
-
name: consumedFile.name,
|
|
14505
|
-
source,
|
|
14506
|
-
type: 'asset'
|
|
14507
|
-
};
|
|
14508
|
-
}
|
|
14509
|
-
}
|
|
14510
|
-
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
14511
|
-
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
14512
|
-
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
14513
|
-
return fileName;
|
|
14514
|
-
}
|
|
14515
|
-
return null;
|
|
14516
|
-
}
|
|
14517
|
-
function areSourcesEqual(sourceA, sourceB) {
|
|
14518
|
-
if (typeof sourceA === 'string') {
|
|
14519
|
-
return sourceA === sourceB;
|
|
14520
|
-
}
|
|
14521
|
-
if (typeof sourceB === 'string') {
|
|
14522
|
-
return false;
|
|
14523
|
-
}
|
|
14524
|
-
if ('equals' in sourceA) {
|
|
14525
|
-
return sourceA.equals(sourceB);
|
|
14526
|
-
}
|
|
14527
|
-
if (sourceA.length !== sourceB.length) {
|
|
14528
|
-
return false;
|
|
14529
|
-
}
|
|
14530
|
-
for (let index = 0; index < sourceA.length; index++) {
|
|
14531
|
-
if (sourceA[index] !== sourceB[index]) {
|
|
14532
|
-
return false;
|
|
14533
|
-
}
|
|
14534
|
-
}
|
|
14535
|
-
return true;
|
|
14536
|
-
}
|
|
14537
|
-
|
|
14538
14250
|
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
14539
14251
|
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
14540
14252
|
async function createAddons(options, outputPluginDriver, chunk) {
|
|
@@ -14807,6 +14519,93 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
|
|
|
14807
14519
|
}
|
|
14808
14520
|
}
|
|
14809
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
|
+
|
|
14810
14609
|
const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.cjs', '.cts'];
|
|
14811
14610
|
function getGlobalName(chunk, globals, hasExports, warn) {
|
|
14812
14611
|
const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
|
|
@@ -16216,6 +16015,8 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
|
|
|
16216
16015
|
return { version: 3, ...map };
|
|
16217
16016
|
}
|
|
16218
16017
|
|
|
16018
|
+
const createHash = () => node_crypto.createHash('sha256');
|
|
16019
|
+
|
|
16219
16020
|
function decodedSourcemap(map) {
|
|
16220
16021
|
if (!map)
|
|
16221
16022
|
return null;
|
|
@@ -16234,7 +16035,7 @@ function decodedSourcemap(map) {
|
|
|
16234
16035
|
return { ...map, mappings };
|
|
16235
16036
|
}
|
|
16236
16037
|
|
|
16237
|
-
async function renderChunks(chunks,
|
|
16038
|
+
async function renderChunks(chunks, bundle, pluginDriver, outputOptions, onwarn) {
|
|
16238
16039
|
timeStart('render chunks', 2);
|
|
16239
16040
|
reserveEntryChunksInBundle(chunks);
|
|
16240
16041
|
const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
|
|
@@ -16242,8 +16043,8 @@ async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, o
|
|
|
16242
16043
|
timeStart('transform chunks', 2);
|
|
16243
16044
|
const chunkGraph = getChunkGraph(chunks);
|
|
16244
16045
|
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
|
|
16245
|
-
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder,
|
|
16246
|
-
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder,
|
|
16046
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
|
|
16047
|
+
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
|
|
16247
16048
|
timeEnd('transform chunks', 2);
|
|
16248
16049
|
}
|
|
16249
16050
|
function reserveEntryChunksInBundle(chunks) {
|
|
@@ -16358,7 +16159,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
16358
16159
|
renderedChunksByPlaceholder
|
|
16359
16160
|
};
|
|
16360
16161
|
}
|
|
16361
|
-
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder,
|
|
16162
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle) {
|
|
16362
16163
|
const hashesByPlaceholder = new Map();
|
|
16363
16164
|
for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
|
|
16364
16165
|
let hash = createHash();
|
|
@@ -16381,13 +16182,13 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
|
|
|
16381
16182
|
}
|
|
16382
16183
|
finalHash = hash.digest('hex').slice(0, placeholder.length);
|
|
16383
16184
|
finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
|
|
16384
|
-
} while (
|
|
16385
|
-
|
|
16386
|
-
hashesByPlaceholder.set(placeholder, finalHash
|
|
16185
|
+
} while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
|
|
16186
|
+
bundle[finalFileName] = FILE_PLACEHOLDER;
|
|
16187
|
+
hashesByPlaceholder.set(placeholder, finalHash);
|
|
16387
16188
|
}
|
|
16388
16189
|
return hashesByPlaceholder;
|
|
16389
16190
|
}
|
|
16390
|
-
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder,
|
|
16191
|
+
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
|
|
16391
16192
|
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
16392
16193
|
let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
16393
16194
|
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
@@ -16395,7 +16196,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
|
|
|
16395
16196
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
16396
16197
|
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
16397
16198
|
}
|
|
16398
|
-
|
|
16199
|
+
bundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16399
16200
|
}
|
|
16400
16201
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16401
16202
|
let updatedCode = hashesByPlaceholder.size
|
|
@@ -16404,7 +16205,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
|
|
|
16404
16205
|
if (map) {
|
|
16405
16206
|
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
16406
16207
|
}
|
|
16407
|
-
|
|
16208
|
+
bundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
|
|
16408
16209
|
}
|
|
16409
16210
|
}
|
|
16410
16211
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -16434,7 +16235,8 @@ class Bundle {
|
|
|
16434
16235
|
}
|
|
16435
16236
|
async generate(isWrite) {
|
|
16436
16237
|
timeStart('GENERATE', 1);
|
|
16437
|
-
const
|
|
16238
|
+
const outputBundleBase = Object.create(null);
|
|
16239
|
+
const outputBundle = getOutputBundle(outputBundleBase);
|
|
16438
16240
|
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions);
|
|
16439
16241
|
try {
|
|
16440
16242
|
timeStart('initialize render', 2);
|
|
@@ -16466,7 +16268,7 @@ class Bundle {
|
|
|
16466
16268
|
this.finaliseAssets(outputBundle);
|
|
16467
16269
|
timeEnd('generate bundle', 2);
|
|
16468
16270
|
timeEnd('GENERATE', 1);
|
|
16469
|
-
return
|
|
16271
|
+
return outputBundleBase;
|
|
16470
16272
|
}
|
|
16471
16273
|
async addManualChunks(manualChunks) {
|
|
16472
16274
|
const manualChunkAliasByEntry = new Map();
|
|
@@ -16502,17 +16304,19 @@ class Bundle {
|
|
|
16502
16304
|
}
|
|
16503
16305
|
return manualChunkAliasByEntry;
|
|
16504
16306
|
}
|
|
16505
|
-
finaliseAssets(
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
|
|
16509
|
-
|
|
16510
|
-
|
|
16511
|
-
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
|
|
16515
|
-
|
|
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
|
+
}
|
|
16516
16320
|
}
|
|
16517
16321
|
}
|
|
16518
16322
|
}
|
|
@@ -22836,6 +22640,209 @@ class GlobalScope extends Scope$1 {
|
|
|
22836
22640
|
}
|
|
22837
22641
|
}
|
|
22838
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
|
+
|
|
22839
22846
|
function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
|
|
22840
22847
|
let cacheable = true;
|
|
22841
22848
|
if (typeof plugin.cacheKey !== 'string') {
|
|
@@ -24032,13 +24039,7 @@ function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, out
|
|
|
24032
24039
|
}
|
|
24033
24040
|
function createOutput(outputBundle) {
|
|
24034
24041
|
return {
|
|
24035
|
-
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) =>
|
|
24036
|
-
const fileTypeA = getSortingFileType(outputFileA);
|
|
24037
|
-
const fileTypeB = getSortingFileType(outputFileB);
|
|
24038
|
-
if (fileTypeA === fileTypeB)
|
|
24039
|
-
return 0;
|
|
24040
|
-
return fileTypeA < fileTypeB ? -1 : 1;
|
|
24041
|
-
})
|
|
24042
|
+
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) => getSortingFileType(outputFileA) - getSortingFileType(outputFileB))
|
|
24042
24043
|
};
|
|
24043
24044
|
}
|
|
24044
24045
|
var SortingFileType;
|