rollup 2.79.0 → 2.79.2
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.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +283 -258
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- 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 +283 -258
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -3
- package/CHANGELOG.md +0 -6748
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.79.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.79.2
|
|
4
|
+
Thu, 26 Sep 2024 18:44:14 GMT - commit 48aef33cf2f2a6dfb175afb3bcd6a977c81f1d5c
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
return n;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version$1 = "2.79.
|
|
30
|
+
var version$1 = "2.79.2";
|
|
31
31
|
|
|
32
32
|
function ensureArray$1(items) {
|
|
33
33
|
if (Array.isArray(items)) {
|
|
@@ -10837,7 +10837,7 @@ const accessedFileUrlGlobals = {
|
|
|
10837
10837
|
umd: ['document', 'require', 'URL']
|
|
10838
10838
|
};
|
|
10839
10839
|
const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
|
|
10840
|
-
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${relativePath}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
|
|
10840
|
+
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${relativePath}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI`);
|
|
10841
10841
|
const getGenericImportMetaMechanism = (getUrl) => (prop, { chunkId }) => {
|
|
10842
10842
|
const urlMechanism = getUrl(chunkId);
|
|
10843
10843
|
return prop === null
|
|
@@ -10846,7 +10846,7 @@ const getGenericImportMetaMechanism = (getUrl) => (prop, { chunkId }) => {
|
|
|
10846
10846
|
? urlMechanism
|
|
10847
10847
|
: 'undefined';
|
|
10848
10848
|
};
|
|
10849
|
-
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(document.currentScript && document.currentScript.src || new URL('${chunkId}', document.baseURI).href)`;
|
|
10849
|
+
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('${chunkId}', document.baseURI).href)`;
|
|
10850
10850
|
const relativeUrlMechanisms = {
|
|
10851
10851
|
amd: relativePath => {
|
|
10852
10852
|
if (relativePath[0] !== '.')
|
|
@@ -14475,6 +14475,34 @@ function renderChunk({ code, options, outputPluginDriver, renderChunk, sourcemap
|
|
|
14475
14475
|
return outputPluginDriver.hookReduceArg0('renderChunk', [code, renderChunk, options], renderChunkReducer);
|
|
14476
14476
|
}
|
|
14477
14477
|
|
|
14478
|
+
const lowercaseBundleKeys = Symbol('bundleKeys');
|
|
14479
|
+
const FILE_PLACEHOLDER = {
|
|
14480
|
+
type: 'placeholder'
|
|
14481
|
+
};
|
|
14482
|
+
const getOutputBundle = (outputBundleBase) => {
|
|
14483
|
+
const reservedLowercaseBundleKeys = new Set();
|
|
14484
|
+
return new Proxy(outputBundleBase, {
|
|
14485
|
+
deleteProperty(target, key) {
|
|
14486
|
+
if (typeof key === 'string') {
|
|
14487
|
+
reservedLowercaseBundleKeys.delete(key.toLowerCase());
|
|
14488
|
+
}
|
|
14489
|
+
return Reflect.deleteProperty(target, key);
|
|
14490
|
+
},
|
|
14491
|
+
get(target, key) {
|
|
14492
|
+
if (key === lowercaseBundleKeys) {
|
|
14493
|
+
return reservedLowercaseBundleKeys;
|
|
14494
|
+
}
|
|
14495
|
+
return Reflect.get(target, key);
|
|
14496
|
+
},
|
|
14497
|
+
set(target, key, value) {
|
|
14498
|
+
if (typeof key === 'string') {
|
|
14499
|
+
reservedLowercaseBundleKeys.add(key.toLowerCase());
|
|
14500
|
+
}
|
|
14501
|
+
return Reflect.set(target, key, value);
|
|
14502
|
+
}
|
|
14503
|
+
});
|
|
14504
|
+
};
|
|
14505
|
+
|
|
14478
14506
|
function renderNamePattern(pattern, patternName, replacements) {
|
|
14479
14507
|
if (isPathFragment(pattern))
|
|
14480
14508
|
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.`));
|
|
@@ -14488,14 +14516,13 @@ function renderNamePattern(pattern, patternName, replacements) {
|
|
|
14488
14516
|
return replacement;
|
|
14489
14517
|
});
|
|
14490
14518
|
}
|
|
14491
|
-
function makeUnique(name,
|
|
14492
|
-
|
|
14493
|
-
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
14519
|
+
function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }) {
|
|
14520
|
+
if (!reservedLowercaseBundleKeys.has(name.toLowerCase()))
|
|
14494
14521
|
return name;
|
|
14495
14522
|
const ext = require$$0.extname(name);
|
|
14496
14523
|
name = name.substring(0, name.length - ext.length);
|
|
14497
14524
|
let uniqueName, uniqueIndex = 1;
|
|
14498
|
-
while (
|
|
14525
|
+
while (reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
14499
14526
|
;
|
|
14500
14527
|
return uniqueName;
|
|
14501
14528
|
}
|
|
@@ -14724,7 +14751,7 @@ class Chunk {
|
|
|
14724
14751
|
}
|
|
14725
14752
|
return facades;
|
|
14726
14753
|
}
|
|
14727
|
-
generateId(addons, options,
|
|
14754
|
+
generateId(addons, options, bundle, includeHash) {
|
|
14728
14755
|
if (this.fileName !== null) {
|
|
14729
14756
|
return this.fileName;
|
|
14730
14757
|
}
|
|
@@ -14734,12 +14761,12 @@ class Chunk {
|
|
|
14734
14761
|
return makeUnique(renderNamePattern(typeof pattern === 'function' ? pattern(this.getChunkInfo()) : pattern, patternName, {
|
|
14735
14762
|
format: () => options.format,
|
|
14736
14763
|
hash: () => includeHash
|
|
14737
|
-
? this.computeContentHashWithDependencies(addons, options,
|
|
14764
|
+
? this.computeContentHashWithDependencies(addons, options, bundle)
|
|
14738
14765
|
: '[hash]',
|
|
14739
14766
|
name: () => this.getChunkName()
|
|
14740
|
-
}),
|
|
14767
|
+
}), bundle);
|
|
14741
14768
|
}
|
|
14742
|
-
generateIdPreserveModules(preserveModulesRelativeDir, options,
|
|
14769
|
+
generateIdPreserveModules(preserveModulesRelativeDir, options, bundle, unsetOptions) {
|
|
14743
14770
|
const [{ id }] = this.orderedModules;
|
|
14744
14771
|
const sanitizedId = this.outputOptions.sanitizeFileName(id.split(QUERY_HASH_REGEX, 1)[0]);
|
|
14745
14772
|
let path;
|
|
@@ -14777,7 +14804,7 @@ class Chunk {
|
|
|
14777
14804
|
});
|
|
14778
14805
|
path = `_virtual/${fileName}`;
|
|
14779
14806
|
}
|
|
14780
|
-
return makeUnique(normalize(path),
|
|
14807
|
+
return makeUnique(normalize(path), bundle);
|
|
14781
14808
|
}
|
|
14782
14809
|
getChunkInfo() {
|
|
14783
14810
|
const facadeModule = this.facadeModule;
|
|
@@ -15098,7 +15125,7 @@ class Chunk {
|
|
|
15098
15125
|
} while (alternativeReexportModule);
|
|
15099
15126
|
}
|
|
15100
15127
|
}
|
|
15101
|
-
computeContentHashWithDependencies(addons, options,
|
|
15128
|
+
computeContentHashWithDependencies(addons, options, bundle) {
|
|
15102
15129
|
const hash = createHash();
|
|
15103
15130
|
hash.update([addons.intro, addons.outro, addons.banner, addons.footer].join(':'));
|
|
15104
15131
|
hash.update(options.format);
|
|
@@ -15109,7 +15136,7 @@ class Chunk {
|
|
|
15109
15136
|
}
|
|
15110
15137
|
else {
|
|
15111
15138
|
hash.update(current.getRenderedHash());
|
|
15112
|
-
hash.update(current.generateId(addons, options,
|
|
15139
|
+
hash.update(current.generateId(addons, options, bundle, false));
|
|
15113
15140
|
}
|
|
15114
15141
|
if (current instanceof ExternalModule)
|
|
15115
15142
|
continue;
|
|
@@ -15550,235 +15577,6 @@ function getChunkNameFromModule(module) {
|
|
|
15550
15577
|
}
|
|
15551
15578
|
const QUERY_HASH_REGEX = /[?#]/;
|
|
15552
15579
|
|
|
15553
|
-
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
15554
|
-
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
15555
|
-
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
15556
|
-
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
15557
|
-
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
15558
|
-
ext: () => require$$0.extname(emittedName).substring(1),
|
|
15559
|
-
extname: () => require$$0.extname(emittedName),
|
|
15560
|
-
hash() {
|
|
15561
|
-
return createHash()
|
|
15562
|
-
.update(emittedName)
|
|
15563
|
-
.update(':')
|
|
15564
|
-
.update(source)
|
|
15565
|
-
.digest('hex')
|
|
15566
|
-
.substring(0, 8);
|
|
15567
|
-
},
|
|
15568
|
-
name: () => emittedName.substring(0, emittedName.length - require$$0.extname(emittedName).length)
|
|
15569
|
-
}), bundle);
|
|
15570
|
-
}
|
|
15571
|
-
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
15572
|
-
if (fileName in bundle) {
|
|
15573
|
-
warn(errFileNameConflict(fileName));
|
|
15574
|
-
}
|
|
15575
|
-
bundle[fileName] = FILE_PLACEHOLDER;
|
|
15576
|
-
}
|
|
15577
|
-
const FILE_PLACEHOLDER = {
|
|
15578
|
-
type: 'placeholder'
|
|
15579
|
-
};
|
|
15580
|
-
function hasValidType(emittedFile) {
|
|
15581
|
-
return Boolean(emittedFile &&
|
|
15582
|
-
(emittedFile.type === 'asset' ||
|
|
15583
|
-
emittedFile.type === 'chunk'));
|
|
15584
|
-
}
|
|
15585
|
-
function hasValidName(emittedFile) {
|
|
15586
|
-
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
15587
|
-
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
15588
|
-
}
|
|
15589
|
-
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
15590
|
-
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
15591
|
-
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
15592
|
-
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.`));
|
|
15593
|
-
}
|
|
15594
|
-
return source;
|
|
15595
|
-
}
|
|
15596
|
-
function getAssetFileName(file, referenceId) {
|
|
15597
|
-
if (typeof file.fileName !== 'string') {
|
|
15598
|
-
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
15599
|
-
}
|
|
15600
|
-
return file.fileName;
|
|
15601
|
-
}
|
|
15602
|
-
function getChunkFileName(file, facadeChunkByModule) {
|
|
15603
|
-
var _a;
|
|
15604
|
-
const fileName = file.fileName || (file.module && ((_a = facadeChunkByModule === null || facadeChunkByModule === void 0 ? void 0 : facadeChunkByModule.get(file.module)) === null || _a === void 0 ? void 0 : _a.id));
|
|
15605
|
-
if (!fileName)
|
|
15606
|
-
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
15607
|
-
return fileName;
|
|
15608
|
-
}
|
|
15609
|
-
class FileEmitter {
|
|
15610
|
-
constructor(graph, options, baseFileEmitter) {
|
|
15611
|
-
this.graph = graph;
|
|
15612
|
-
this.options = options;
|
|
15613
|
-
this.bundle = null;
|
|
15614
|
-
this.facadeChunkByModule = null;
|
|
15615
|
-
this.outputOptions = null;
|
|
15616
|
-
this.assertAssetsFinalized = () => {
|
|
15617
|
-
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
15618
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
15619
|
-
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
15620
|
-
}
|
|
15621
|
-
};
|
|
15622
|
-
this.emitFile = (emittedFile) => {
|
|
15623
|
-
if (!hasValidType(emittedFile)) {
|
|
15624
|
-
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
15625
|
-
}
|
|
15626
|
-
if (!hasValidName(emittedFile)) {
|
|
15627
|
-
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}".`));
|
|
15628
|
-
}
|
|
15629
|
-
if (emittedFile.type === 'chunk') {
|
|
15630
|
-
return this.emitChunk(emittedFile);
|
|
15631
|
-
}
|
|
15632
|
-
return this.emitAsset(emittedFile);
|
|
15633
|
-
};
|
|
15634
|
-
this.getFileName = (fileReferenceId) => {
|
|
15635
|
-
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
15636
|
-
if (!emittedFile)
|
|
15637
|
-
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
15638
|
-
if (emittedFile.type === 'chunk') {
|
|
15639
|
-
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
15640
|
-
}
|
|
15641
|
-
return getAssetFileName(emittedFile, fileReferenceId);
|
|
15642
|
-
};
|
|
15643
|
-
this.setAssetSource = (referenceId, requestedSource) => {
|
|
15644
|
-
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
15645
|
-
if (!consumedFile)
|
|
15646
|
-
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
15647
|
-
if (consumedFile.type !== 'asset') {
|
|
15648
|
-
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
15649
|
-
}
|
|
15650
|
-
if (consumedFile.source !== undefined) {
|
|
15651
|
-
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
15652
|
-
}
|
|
15653
|
-
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
15654
|
-
if (this.bundle) {
|
|
15655
|
-
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
15656
|
-
}
|
|
15657
|
-
else {
|
|
15658
|
-
consumedFile.source = source;
|
|
15659
|
-
}
|
|
15660
|
-
};
|
|
15661
|
-
this.setOutputBundle = (outputBundle, outputOptions, facadeChunkByModule) => {
|
|
15662
|
-
this.outputOptions = outputOptions;
|
|
15663
|
-
this.bundle = outputBundle;
|
|
15664
|
-
this.facadeChunkByModule = facadeChunkByModule;
|
|
15665
|
-
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
15666
|
-
if (emittedFile.fileName) {
|
|
15667
|
-
reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
|
|
15668
|
-
}
|
|
15669
|
-
}
|
|
15670
|
-
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
15671
|
-
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
15672
|
-
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
|
|
15673
|
-
}
|
|
15674
|
-
}
|
|
15675
|
-
};
|
|
15676
|
-
this.filesByReferenceId = baseFileEmitter
|
|
15677
|
-
? new Map(baseFileEmitter.filesByReferenceId)
|
|
15678
|
-
: new Map();
|
|
15679
|
-
}
|
|
15680
|
-
assignReferenceId(file, idBase) {
|
|
15681
|
-
let referenceId;
|
|
15682
|
-
do {
|
|
15683
|
-
referenceId = createHash()
|
|
15684
|
-
.update(referenceId || idBase)
|
|
15685
|
-
.digest('hex')
|
|
15686
|
-
.substring(0, 8);
|
|
15687
|
-
} while (this.filesByReferenceId.has(referenceId));
|
|
15688
|
-
this.filesByReferenceId.set(referenceId, file);
|
|
15689
|
-
return referenceId;
|
|
15690
|
-
}
|
|
15691
|
-
emitAsset(emittedAsset) {
|
|
15692
|
-
const source = typeof emittedAsset.source !== 'undefined'
|
|
15693
|
-
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
15694
|
-
: undefined;
|
|
15695
|
-
const consumedAsset = {
|
|
15696
|
-
fileName: emittedAsset.fileName,
|
|
15697
|
-
name: emittedAsset.name,
|
|
15698
|
-
source,
|
|
15699
|
-
type: 'asset'
|
|
15700
|
-
};
|
|
15701
|
-
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
15702
|
-
if (this.bundle) {
|
|
15703
|
-
if (emittedAsset.fileName) {
|
|
15704
|
-
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
15705
|
-
}
|
|
15706
|
-
if (source !== undefined) {
|
|
15707
|
-
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
15708
|
-
}
|
|
15709
|
-
}
|
|
15710
|
-
return referenceId;
|
|
15711
|
-
}
|
|
15712
|
-
emitChunk(emittedChunk) {
|
|
15713
|
-
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
15714
|
-
return error(errInvalidRollupPhaseForChunkEmission());
|
|
15715
|
-
}
|
|
15716
|
-
if (typeof emittedChunk.id !== 'string') {
|
|
15717
|
-
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
15718
|
-
}
|
|
15719
|
-
const consumedChunk = {
|
|
15720
|
-
fileName: emittedChunk.fileName,
|
|
15721
|
-
module: null,
|
|
15722
|
-
name: emittedChunk.name || emittedChunk.id,
|
|
15723
|
-
type: 'chunk'
|
|
15724
|
-
};
|
|
15725
|
-
this.graph.moduleLoader
|
|
15726
|
-
.emitChunk(emittedChunk)
|
|
15727
|
-
.then(module => (consumedChunk.module = module))
|
|
15728
|
-
.catch(() => {
|
|
15729
|
-
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
15730
|
-
// once module loading has finished
|
|
15731
|
-
});
|
|
15732
|
-
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
15733
|
-
}
|
|
15734
|
-
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
15735
|
-
const fileName = consumedFile.fileName ||
|
|
15736
|
-
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
15737
|
-
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
15738
|
-
// We must not modify the original assets to avoid interaction between outputs
|
|
15739
|
-
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
15740
|
-
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
15741
|
-
const { options } = this;
|
|
15742
|
-
bundle[fileName] = {
|
|
15743
|
-
fileName,
|
|
15744
|
-
get isAsset() {
|
|
15745
|
-
warnDeprecation('Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead', true, options);
|
|
15746
|
-
return true;
|
|
15747
|
-
},
|
|
15748
|
-
name: consumedFile.name,
|
|
15749
|
-
source,
|
|
15750
|
-
type: 'asset'
|
|
15751
|
-
};
|
|
15752
|
-
}
|
|
15753
|
-
}
|
|
15754
|
-
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
15755
|
-
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
15756
|
-
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
15757
|
-
return fileName;
|
|
15758
|
-
}
|
|
15759
|
-
return null;
|
|
15760
|
-
}
|
|
15761
|
-
function areSourcesEqual(sourceA, sourceB) {
|
|
15762
|
-
if (typeof sourceA === 'string') {
|
|
15763
|
-
return sourceA === sourceB;
|
|
15764
|
-
}
|
|
15765
|
-
if (typeof sourceB === 'string') {
|
|
15766
|
-
return false;
|
|
15767
|
-
}
|
|
15768
|
-
if ('equals' in sourceA) {
|
|
15769
|
-
return sourceA.equals(sourceB);
|
|
15770
|
-
}
|
|
15771
|
-
if (sourceA.length !== sourceB.length) {
|
|
15772
|
-
return false;
|
|
15773
|
-
}
|
|
15774
|
-
for (let index = 0; index < sourceA.length; index++) {
|
|
15775
|
-
if (sourceA[index] !== sourceB[index]) {
|
|
15776
|
-
return false;
|
|
15777
|
-
}
|
|
15778
|
-
}
|
|
15779
|
-
return true;
|
|
15780
|
-
}
|
|
15781
|
-
|
|
15782
15580
|
const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
|
|
15783
15581
|
const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
|
|
15784
15582
|
async function createAddons(options, outputPluginDriver) {
|
|
@@ -16101,7 +15899,8 @@ class Bundle {
|
|
|
16101
15899
|
}
|
|
16102
15900
|
async generate(isWrite) {
|
|
16103
15901
|
timeStart('GENERATE', 1);
|
|
16104
|
-
const
|
|
15902
|
+
const outputBundleBase = Object.create(null);
|
|
15903
|
+
const outputBundle = getOutputBundle(outputBundleBase);
|
|
16105
15904
|
this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions, this.facadeChunkByModule);
|
|
16106
15905
|
try {
|
|
16107
15906
|
await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]);
|
|
@@ -16132,15 +15931,15 @@ class Bundle {
|
|
|
16132
15931
|
]);
|
|
16133
15932
|
this.finaliseAssets(outputBundle);
|
|
16134
15933
|
timeEnd('GENERATE', 1);
|
|
16135
|
-
return
|
|
15934
|
+
return outputBundleBase;
|
|
16136
15935
|
}
|
|
16137
|
-
async addFinalizedChunksToBundle(chunks, inputBase, addons,
|
|
16138
|
-
this.assignChunkIds(chunks, inputBase, addons,
|
|
15936
|
+
async addFinalizedChunksToBundle(chunks, inputBase, addons, bundle, snippets) {
|
|
15937
|
+
this.assignChunkIds(chunks, inputBase, addons, bundle);
|
|
16139
15938
|
for (const chunk of chunks) {
|
|
16140
|
-
|
|
15939
|
+
bundle[chunk.id] = chunk.getChunkInfoWithFileNames();
|
|
16141
15940
|
}
|
|
16142
15941
|
await Promise.all(chunks.map(async (chunk) => {
|
|
16143
|
-
const outputChunk =
|
|
15942
|
+
const outputChunk = bundle[chunk.id];
|
|
16144
15943
|
Object.assign(outputChunk, await chunk.render(this.outputOptions, addons, outputChunk, snippets));
|
|
16145
15944
|
}));
|
|
16146
15945
|
}
|
|
@@ -22590,6 +22389,238 @@ class GlobalScope extends Scope$1 {
|
|
|
22590
22389
|
}
|
|
22591
22390
|
}
|
|
22592
22391
|
|
|
22392
|
+
function generateAssetFileName(name, source, outputOptions, bundle) {
|
|
22393
|
+
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
22394
|
+
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
22395
|
+
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
22396
|
+
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
22397
|
+
ext: () => require$$0.extname(emittedName).substring(1),
|
|
22398
|
+
extname: () => require$$0.extname(emittedName),
|
|
22399
|
+
hash() {
|
|
22400
|
+
return createHash()
|
|
22401
|
+
.update(emittedName)
|
|
22402
|
+
.update(':')
|
|
22403
|
+
.update(source)
|
|
22404
|
+
.digest('hex')
|
|
22405
|
+
.substring(0, 8);
|
|
22406
|
+
},
|
|
22407
|
+
name: () => emittedName.substring(0, emittedName.length - require$$0.extname(emittedName).length)
|
|
22408
|
+
}), bundle);
|
|
22409
|
+
}
|
|
22410
|
+
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
22411
|
+
const lowercaseFileName = fileName.toLowerCase();
|
|
22412
|
+
if (bundle[lowercaseBundleKeys].has(lowercaseFileName)) {
|
|
22413
|
+
warn(errFileNameConflict(fileName));
|
|
22414
|
+
}
|
|
22415
|
+
else {
|
|
22416
|
+
bundle[fileName] = FILE_PLACEHOLDER;
|
|
22417
|
+
}
|
|
22418
|
+
}
|
|
22419
|
+
function hasValidType(emittedFile) {
|
|
22420
|
+
return Boolean(emittedFile &&
|
|
22421
|
+
(emittedFile.type === 'asset' ||
|
|
22422
|
+
emittedFile.type === 'chunk'));
|
|
22423
|
+
}
|
|
22424
|
+
function hasValidName(emittedFile) {
|
|
22425
|
+
const validatedName = emittedFile.fileName || emittedFile.name;
|
|
22426
|
+
return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
|
|
22427
|
+
}
|
|
22428
|
+
function getValidSource(source, emittedFile, fileReferenceId) {
|
|
22429
|
+
if (!(typeof source === 'string' || source instanceof Uint8Array)) {
|
|
22430
|
+
const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
|
|
22431
|
+
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.`));
|
|
22432
|
+
}
|
|
22433
|
+
return source;
|
|
22434
|
+
}
|
|
22435
|
+
function getAssetFileName(file, referenceId) {
|
|
22436
|
+
if (typeof file.fileName !== 'string') {
|
|
22437
|
+
return error(errAssetNotFinalisedForFileName(file.name || referenceId));
|
|
22438
|
+
}
|
|
22439
|
+
return file.fileName;
|
|
22440
|
+
}
|
|
22441
|
+
function getChunkFileName(file, facadeChunkByModule) {
|
|
22442
|
+
var _a;
|
|
22443
|
+
const fileName = file.fileName || (file.module && ((_a = facadeChunkByModule === null || facadeChunkByModule === void 0 ? void 0 : facadeChunkByModule.get(file.module)) === null || _a === void 0 ? void 0 : _a.id));
|
|
22444
|
+
if (!fileName)
|
|
22445
|
+
return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
22446
|
+
return fileName;
|
|
22447
|
+
}
|
|
22448
|
+
class FileEmitter {
|
|
22449
|
+
constructor(graph, options, baseFileEmitter) {
|
|
22450
|
+
this.graph = graph;
|
|
22451
|
+
this.options = options;
|
|
22452
|
+
this.bundle = null;
|
|
22453
|
+
this.facadeChunkByModule = null;
|
|
22454
|
+
this.outputOptions = null;
|
|
22455
|
+
this.assertAssetsFinalized = () => {
|
|
22456
|
+
for (const [referenceId, emittedFile] of this.filesByReferenceId) {
|
|
22457
|
+
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
22458
|
+
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
22459
|
+
}
|
|
22460
|
+
};
|
|
22461
|
+
this.emitFile = (emittedFile) => {
|
|
22462
|
+
if (!hasValidType(emittedFile)) {
|
|
22463
|
+
return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
|
|
22464
|
+
}
|
|
22465
|
+
if (!hasValidName(emittedFile)) {
|
|
22466
|
+
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}".`));
|
|
22467
|
+
}
|
|
22468
|
+
if (emittedFile.type === 'chunk') {
|
|
22469
|
+
return this.emitChunk(emittedFile);
|
|
22470
|
+
}
|
|
22471
|
+
return this.emitAsset(emittedFile);
|
|
22472
|
+
};
|
|
22473
|
+
this.getFileName = (fileReferenceId) => {
|
|
22474
|
+
const emittedFile = this.filesByReferenceId.get(fileReferenceId);
|
|
22475
|
+
if (!emittedFile)
|
|
22476
|
+
return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
|
|
22477
|
+
if (emittedFile.type === 'chunk') {
|
|
22478
|
+
return getChunkFileName(emittedFile, this.facadeChunkByModule);
|
|
22479
|
+
}
|
|
22480
|
+
return getAssetFileName(emittedFile, fileReferenceId);
|
|
22481
|
+
};
|
|
22482
|
+
this.setAssetSource = (referenceId, requestedSource) => {
|
|
22483
|
+
const consumedFile = this.filesByReferenceId.get(referenceId);
|
|
22484
|
+
if (!consumedFile)
|
|
22485
|
+
return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
|
|
22486
|
+
if (consumedFile.type !== 'asset') {
|
|
22487
|
+
return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
|
|
22488
|
+
}
|
|
22489
|
+
if (consumedFile.source !== undefined) {
|
|
22490
|
+
return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
|
|
22491
|
+
}
|
|
22492
|
+
const source = getValidSource(requestedSource, consumedFile, referenceId);
|
|
22493
|
+
if (this.bundle) {
|
|
22494
|
+
this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
|
|
22495
|
+
}
|
|
22496
|
+
else {
|
|
22497
|
+
consumedFile.source = source;
|
|
22498
|
+
}
|
|
22499
|
+
};
|
|
22500
|
+
this.setOutputBundle = (bundle, outputOptions, facadeChunkByModule) => {
|
|
22501
|
+
this.outputOptions = outputOptions;
|
|
22502
|
+
this.bundle = bundle;
|
|
22503
|
+
this.facadeChunkByModule = facadeChunkByModule;
|
|
22504
|
+
for (const { fileName } of this.filesByReferenceId.values()) {
|
|
22505
|
+
if (fileName) {
|
|
22506
|
+
reserveFileNameInBundle(fileName, bundle, this.options.onwarn);
|
|
22507
|
+
}
|
|
22508
|
+
}
|
|
22509
|
+
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
22510
|
+
if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
|
|
22511
|
+
this.finalizeAsset(consumedFile, consumedFile.source, referenceId, bundle);
|
|
22512
|
+
}
|
|
22513
|
+
}
|
|
22514
|
+
};
|
|
22515
|
+
this.filesByReferenceId = baseFileEmitter
|
|
22516
|
+
? new Map(baseFileEmitter.filesByReferenceId)
|
|
22517
|
+
: new Map();
|
|
22518
|
+
}
|
|
22519
|
+
assignReferenceId(file, idBase) {
|
|
22520
|
+
let referenceId;
|
|
22521
|
+
do {
|
|
22522
|
+
referenceId = createHash()
|
|
22523
|
+
.update(referenceId || idBase)
|
|
22524
|
+
.digest('hex')
|
|
22525
|
+
.substring(0, 8);
|
|
22526
|
+
} while (this.filesByReferenceId.has(referenceId));
|
|
22527
|
+
this.filesByReferenceId.set(referenceId, file);
|
|
22528
|
+
return referenceId;
|
|
22529
|
+
}
|
|
22530
|
+
emitAsset(emittedAsset) {
|
|
22531
|
+
const source = typeof emittedAsset.source !== 'undefined'
|
|
22532
|
+
? getValidSource(emittedAsset.source, emittedAsset, null)
|
|
22533
|
+
: undefined;
|
|
22534
|
+
const consumedAsset = {
|
|
22535
|
+
fileName: emittedAsset.fileName,
|
|
22536
|
+
name: emittedAsset.name,
|
|
22537
|
+
source,
|
|
22538
|
+
type: 'asset'
|
|
22539
|
+
};
|
|
22540
|
+
const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
|
|
22541
|
+
if (this.bundle) {
|
|
22542
|
+
if (emittedAsset.fileName) {
|
|
22543
|
+
reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
|
|
22544
|
+
}
|
|
22545
|
+
if (source !== undefined) {
|
|
22546
|
+
this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
|
|
22547
|
+
}
|
|
22548
|
+
}
|
|
22549
|
+
return referenceId;
|
|
22550
|
+
}
|
|
22551
|
+
emitChunk(emittedChunk) {
|
|
22552
|
+
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
22553
|
+
return error(errInvalidRollupPhaseForChunkEmission());
|
|
22554
|
+
}
|
|
22555
|
+
if (typeof emittedChunk.id !== 'string') {
|
|
22556
|
+
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
22557
|
+
}
|
|
22558
|
+
const consumedChunk = {
|
|
22559
|
+
fileName: emittedChunk.fileName,
|
|
22560
|
+
module: null,
|
|
22561
|
+
name: emittedChunk.name || emittedChunk.id,
|
|
22562
|
+
type: 'chunk'
|
|
22563
|
+
};
|
|
22564
|
+
this.graph.moduleLoader
|
|
22565
|
+
.emitChunk(emittedChunk)
|
|
22566
|
+
.then(module => (consumedChunk.module = module))
|
|
22567
|
+
.catch(() => {
|
|
22568
|
+
// Avoid unhandled Promise rejection as the error will be thrown later
|
|
22569
|
+
// once module loading has finished
|
|
22570
|
+
});
|
|
22571
|
+
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
22572
|
+
}
|
|
22573
|
+
finalizeAsset(consumedFile, source, referenceId, bundle) {
|
|
22574
|
+
const fileName = consumedFile.fileName ||
|
|
22575
|
+
findExistingAssetFileNameWithSource(bundle, source) ||
|
|
22576
|
+
generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
|
|
22577
|
+
// We must not modify the original assets to avoid interaction between outputs
|
|
22578
|
+
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
22579
|
+
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
22580
|
+
const { options } = this;
|
|
22581
|
+
bundle[fileName] = {
|
|
22582
|
+
fileName,
|
|
22583
|
+
get isAsset() {
|
|
22584
|
+
warnDeprecation('Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead', true, options);
|
|
22585
|
+
return true;
|
|
22586
|
+
},
|
|
22587
|
+
name: consumedFile.name,
|
|
22588
|
+
source,
|
|
22589
|
+
type: 'asset'
|
|
22590
|
+
};
|
|
22591
|
+
}
|
|
22592
|
+
}
|
|
22593
|
+
// TODO This can lead to a performance problem when many assets are emitted.
|
|
22594
|
+
// Instead, we should only deduplicate string assets and use their sources as
|
|
22595
|
+
// object keys for better performance.
|
|
22596
|
+
function findExistingAssetFileNameWithSource(bundle, source) {
|
|
22597
|
+
for (const [fileName, outputFile] of Object.entries(bundle)) {
|
|
22598
|
+
if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
|
|
22599
|
+
return fileName;
|
|
22600
|
+
}
|
|
22601
|
+
return null;
|
|
22602
|
+
}
|
|
22603
|
+
function areSourcesEqual(sourceA, sourceB) {
|
|
22604
|
+
if (typeof sourceA === 'string') {
|
|
22605
|
+
return sourceA === sourceB;
|
|
22606
|
+
}
|
|
22607
|
+
if (typeof sourceB === 'string') {
|
|
22608
|
+
return false;
|
|
22609
|
+
}
|
|
22610
|
+
if ('equals' in sourceA) {
|
|
22611
|
+
return sourceA.equals(sourceB);
|
|
22612
|
+
}
|
|
22613
|
+
if (sourceA.length !== sourceB.length) {
|
|
22614
|
+
return false;
|
|
22615
|
+
}
|
|
22616
|
+
for (let index = 0; index < sourceA.length; index++) {
|
|
22617
|
+
if (sourceA[index] !== sourceB[index]) {
|
|
22618
|
+
return false;
|
|
22619
|
+
}
|
|
22620
|
+
}
|
|
22621
|
+
return true;
|
|
22622
|
+
}
|
|
22623
|
+
|
|
22593
22624
|
function getDeprecatedContextHandler(handler, handlerName, newHandlerName, pluginName, activeDeprecation, options) {
|
|
22594
22625
|
let deprecationWarningShown = false;
|
|
22595
22626
|
return ((...args) => {
|
|
@@ -23837,13 +23868,7 @@ function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, out
|
|
|
23837
23868
|
}
|
|
23838
23869
|
function createOutput(outputBundle) {
|
|
23839
23870
|
return {
|
|
23840
|
-
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) =>
|
|
23841
|
-
const fileTypeA = getSortingFileType(outputFileA);
|
|
23842
|
-
const fileTypeB = getSortingFileType(outputFileB);
|
|
23843
|
-
if (fileTypeA === fileTypeB)
|
|
23844
|
-
return 0;
|
|
23845
|
-
return fileTypeA < fileTypeB ? -1 : 1;
|
|
23846
|
-
})
|
|
23871
|
+
output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) => getSortingFileType(outputFileA) - getSortingFileType(outputFileB))
|
|
23847
23872
|
};
|
|
23848
23873
|
}
|
|
23849
23874
|
var SortingFileType;
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED