rollup 3.3.0-0 → 3.4.0-0
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 +62 -20
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +1 -0
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +66 -24
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/bin/rollup
CHANGED
package/dist/es/rollup.js
CHANGED
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.4.0-0
|
|
4
|
+
Fri, 18 Nov 2022 07:39:24 GMT - commit 6c70b960636630638055594175dbfed0d4b7cd15
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { promises } from 'node:fs';
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.
|
|
19
|
+
var version$1 = "3.4.0-0";
|
|
20
20
|
|
|
21
21
|
var charToInteger = {};
|
|
22
22
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -6840,6 +6840,19 @@ function is_reference (node, parent) {
|
|
|
6840
6840
|
return false;
|
|
6841
6841
|
}
|
|
6842
6842
|
|
|
6843
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
6844
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
6845
|
+
const pureFunctions = Object.create(null);
|
|
6846
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
6847
|
+
let currentFunctions = pureFunctions;
|
|
6848
|
+
for (const pathSegment of functionName.split('.')) {
|
|
6849
|
+
currentFunctions = currentFunctions[pathSegment] || (currentFunctions[pathSegment] = Object.create(null));
|
|
6850
|
+
}
|
|
6851
|
+
currentFunctions[PureFunctionKey] = true;
|
|
6852
|
+
}
|
|
6853
|
+
return pureFunctions;
|
|
6854
|
+
};
|
|
6855
|
+
|
|
6843
6856
|
/* eslint sort-keys: "off" */
|
|
6844
6857
|
const ValueProperties = Symbol('Value Properties');
|
|
6845
6858
|
const getTruthyLiteralValue = () => UnknownTruthyValue;
|
|
@@ -7833,13 +7846,15 @@ class Identifier extends NodeBase {
|
|
|
7833
7846
|
switch (interaction.type) {
|
|
7834
7847
|
case INTERACTION_ACCESSED: {
|
|
7835
7848
|
return (this.variable !== null &&
|
|
7849
|
+
!this.isPureFunction(path) &&
|
|
7836
7850
|
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
7837
7851
|
}
|
|
7838
7852
|
case INTERACTION_ASSIGNED: {
|
|
7839
7853
|
return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7840
7854
|
}
|
|
7841
7855
|
case INTERACTION_CALLED: {
|
|
7842
|
-
return this.
|
|
7856
|
+
return (!this.isPureFunction(path) &&
|
|
7857
|
+
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
7843
7858
|
}
|
|
7844
7859
|
}
|
|
7845
7860
|
}
|
|
@@ -7921,6 +7936,18 @@ class Identifier extends NodeBase {
|
|
|
7921
7936
|
}
|
|
7922
7937
|
return this.variable;
|
|
7923
7938
|
}
|
|
7939
|
+
isPureFunction(path) {
|
|
7940
|
+
let currentPureFunction = this.context.manualPureFunctions[this.name];
|
|
7941
|
+
for (const segment of path) {
|
|
7942
|
+
if (currentPureFunction) {
|
|
7943
|
+
currentPureFunction = currentPureFunction[segment];
|
|
7944
|
+
}
|
|
7945
|
+
else {
|
|
7946
|
+
return false;
|
|
7947
|
+
}
|
|
7948
|
+
}
|
|
7949
|
+
return currentPureFunction?.[PureFunctionKey];
|
|
7950
|
+
}
|
|
7924
7951
|
}
|
|
7925
7952
|
function closestParentFunctionOrProgram(node) {
|
|
7926
7953
|
while (node && !/^Program|Function/.test(node.type)) {
|
|
@@ -12618,13 +12645,21 @@ function getPluginWithTimers(plugin, index) {
|
|
|
12618
12645
|
timerLabel += ` (${plugin.name})`;
|
|
12619
12646
|
}
|
|
12620
12647
|
timerLabel += ` - ${hook}`;
|
|
12621
|
-
const
|
|
12622
|
-
plugin[hook] = function (...parameters) {
|
|
12648
|
+
const handler = function (...parameters) {
|
|
12623
12649
|
timeStart(timerLabel, 4);
|
|
12624
12650
|
const result = hookFunction.apply(this, parameters);
|
|
12625
12651
|
timeEnd(timerLabel, 4);
|
|
12626
12652
|
return result;
|
|
12627
12653
|
};
|
|
12654
|
+
let hookFunction;
|
|
12655
|
+
if (typeof plugin[hook].handler === 'function') {
|
|
12656
|
+
hookFunction = plugin[hook].handler;
|
|
12657
|
+
plugin[hook].handler = handler;
|
|
12658
|
+
}
|
|
12659
|
+
else {
|
|
12660
|
+
hookFunction = plugin[hook];
|
|
12661
|
+
plugin[hook] = handler;
|
|
12662
|
+
}
|
|
12628
12663
|
}
|
|
12629
12664
|
}
|
|
12630
12665
|
return plugin;
|
|
@@ -13147,6 +13182,7 @@ class Module {
|
|
|
13147
13182
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
13148
13183
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
13149
13184
|
magicString: this.magicString,
|
|
13185
|
+
manualPureFunctions: this.graph.pureFunctions,
|
|
13150
13186
|
module: this,
|
|
13151
13187
|
moduleContext: this.context,
|
|
13152
13188
|
options: this.options,
|
|
@@ -22846,17 +22882,17 @@ class GlobalScope extends Scope$1 {
|
|
|
22846
22882
|
}
|
|
22847
22883
|
}
|
|
22848
22884
|
|
|
22849
|
-
function
|
|
22885
|
+
function getSourceHash(source) {
|
|
22886
|
+
return createHash().update(source).digest('hex');
|
|
22887
|
+
}
|
|
22888
|
+
function generateAssetFileName(name, source, sourceHash, outputOptions, bundle) {
|
|
22850
22889
|
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
22851
22890
|
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
22852
22891
|
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
22853
22892
|
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
22854
22893
|
ext: () => extname(emittedName).slice(1),
|
|
22855
22894
|
extname: () => extname(emittedName),
|
|
22856
|
-
hash: size =>
|
|
22857
|
-
.update(source)
|
|
22858
|
-
.digest('hex')
|
|
22859
|
-
.slice(0, Math.max(0, size || defaultHashSize)),
|
|
22895
|
+
hash: size => sourceHash.slice(0, Math.max(0, size || defaultHashSize)),
|
|
22860
22896
|
name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
|
|
22861
22897
|
}), bundle);
|
|
22862
22898
|
}
|
|
@@ -22961,9 +22997,6 @@ class FileEmitter {
|
|
|
22961
22997
|
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
22962
22998
|
if (emittedFile.fileName) {
|
|
22963
22999
|
reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
|
|
22964
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.source === 'string') {
|
|
22965
|
-
fileNamesBySource.set(emittedFile.source, emittedFile.fileName);
|
|
22966
|
-
}
|
|
22967
23000
|
}
|
|
22968
23001
|
}
|
|
22969
23002
|
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
@@ -23031,15 +23064,19 @@ class FileEmitter {
|
|
|
23031
23064
|
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
23032
23065
|
}
|
|
23033
23066
|
finalizeAsset(consumedFile, source, referenceId, { bundle, fileNamesBySource, outputOptions }) {
|
|
23034
|
-
|
|
23035
|
-
|
|
23036
|
-
|
|
23067
|
+
let fileName = consumedFile.fileName;
|
|
23068
|
+
// Deduplicate assets if an explicit fileName is not provided
|
|
23069
|
+
if (!fileName) {
|
|
23070
|
+
const sourceHash = getSourceHash(source);
|
|
23071
|
+
fileName = fileNamesBySource.get(sourceHash);
|
|
23072
|
+
if (!fileName) {
|
|
23073
|
+
fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
|
|
23074
|
+
fileNamesBySource.set(sourceHash, fileName);
|
|
23075
|
+
}
|
|
23076
|
+
}
|
|
23037
23077
|
// We must not modify the original assets to avoid interaction between outputs
|
|
23038
23078
|
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
23039
23079
|
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
23040
|
-
if (typeof source === 'string') {
|
|
23041
|
-
fileNamesBySource.set(source, fileName);
|
|
23042
|
-
}
|
|
23043
23080
|
bundle[fileName] = {
|
|
23044
23081
|
fileName,
|
|
23045
23082
|
name: consumedFile.name,
|
|
@@ -23467,6 +23504,7 @@ class Graph {
|
|
|
23467
23504
|
this.acornParser = Parser.extend(...options.acornInjectPlugins);
|
|
23468
23505
|
this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver);
|
|
23469
23506
|
this.fileOperationQueue = new Queue(options.maxParallelFileOps);
|
|
23507
|
+
this.pureFunctions = getPureFunctions(options);
|
|
23470
23508
|
}
|
|
23471
23509
|
async build() {
|
|
23472
23510
|
timeStart('generate module graph', 2);
|
|
@@ -23966,6 +24004,7 @@ const treeshakePresets = {
|
|
|
23966
24004
|
recommended: {
|
|
23967
24005
|
annotations: true,
|
|
23968
24006
|
correctVarValueBeforeDeclaration: false,
|
|
24007
|
+
manualPureFunctions: EMPTY_ARRAY,
|
|
23969
24008
|
moduleSideEffects: () => true,
|
|
23970
24009
|
propertyReadSideEffects: true,
|
|
23971
24010
|
tryCatchDeoptimization: true,
|
|
@@ -23974,6 +24013,7 @@ const treeshakePresets = {
|
|
|
23974
24013
|
safest: {
|
|
23975
24014
|
annotations: true,
|
|
23976
24015
|
correctVarValueBeforeDeclaration: true,
|
|
24016
|
+
manualPureFunctions: EMPTY_ARRAY,
|
|
23977
24017
|
moduleSideEffects: () => true,
|
|
23978
24018
|
propertyReadSideEffects: true,
|
|
23979
24019
|
tryCatchDeoptimization: true,
|
|
@@ -23982,6 +24022,7 @@ const treeshakePresets = {
|
|
|
23982
24022
|
smallest: {
|
|
23983
24023
|
annotations: true,
|
|
23984
24024
|
correctVarValueBeforeDeclaration: false,
|
|
24025
|
+
manualPureFunctions: EMPTY_ARRAY,
|
|
23985
24026
|
moduleSideEffects: () => false,
|
|
23986
24027
|
propertyReadSideEffects: false,
|
|
23987
24028
|
tryCatchDeoptimization: false,
|
|
@@ -24178,6 +24219,7 @@ const getTreeshake = (config) => {
|
|
|
24178
24219
|
return {
|
|
24179
24220
|
annotations: configWithPreset.annotations !== false,
|
|
24180
24221
|
correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true,
|
|
24222
|
+
manualPureFunctions: configWithPreset.manualPureFunctions ?? EMPTY_ARRAY,
|
|
24181
24223
|
moduleSideEffects: getHasModuleSideEffects(configWithPreset.moduleSideEffects),
|
|
24182
24224
|
propertyReadSideEffects: configWithPreset.propertyReadSideEffects === 'always'
|
|
24183
24225
|
? 'always'
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.d.ts
CHANGED
|
@@ -466,6 +466,7 @@ type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
|
|
|
466
466
|
export interface NormalizedTreeshakingOptions {
|
|
467
467
|
annotations: boolean;
|
|
468
468
|
correctVarValueBeforeDeclaration: boolean;
|
|
469
|
+
manualPureFunctions: readonly string[];
|
|
469
470
|
moduleSideEffects: HasModuleSideEffects;
|
|
470
471
|
propertyReadSideEffects: boolean | 'always';
|
|
471
472
|
tryCatchDeoptimization: boolean;
|
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.4.0-0
|
|
4
|
+
Fri, 18 Nov 2022 07:39:24 GMT - commit 6c70b960636630638055594175dbfed0d4b7cd15
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version$1 = "3.
|
|
34
|
+
var version$1 = "3.4.0-0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -50,6 +50,10 @@ async function asyncFlatten(array) {
|
|
|
50
50
|
return array;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
const BLANK = Object.freeze(Object.create(null));
|
|
54
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
55
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
56
|
+
|
|
53
57
|
function getLocator$1(source, options) {
|
|
54
58
|
if (options === void 0) { options = {}; }
|
|
55
59
|
var offsetLine = options.offsetLine || 0;
|
|
@@ -814,6 +818,7 @@ const treeshakePresets = {
|
|
|
814
818
|
recommended: {
|
|
815
819
|
annotations: true,
|
|
816
820
|
correctVarValueBeforeDeclaration: false,
|
|
821
|
+
manualPureFunctions: EMPTY_ARRAY,
|
|
817
822
|
moduleSideEffects: () => true,
|
|
818
823
|
propertyReadSideEffects: true,
|
|
819
824
|
tryCatchDeoptimization: true,
|
|
@@ -822,6 +827,7 @@ const treeshakePresets = {
|
|
|
822
827
|
safest: {
|
|
823
828
|
annotations: true,
|
|
824
829
|
correctVarValueBeforeDeclaration: true,
|
|
830
|
+
manualPureFunctions: EMPTY_ARRAY,
|
|
825
831
|
moduleSideEffects: () => true,
|
|
826
832
|
propertyReadSideEffects: true,
|
|
827
833
|
tryCatchDeoptimization: true,
|
|
@@ -830,6 +836,7 @@ const treeshakePresets = {
|
|
|
830
836
|
smallest: {
|
|
831
837
|
annotations: true,
|
|
832
838
|
correctVarValueBeforeDeclaration: false,
|
|
839
|
+
manualPureFunctions: EMPTY_ARRAY,
|
|
833
840
|
moduleSideEffects: () => false,
|
|
834
841
|
propertyReadSideEffects: false,
|
|
835
842
|
tryCatchDeoptimization: false,
|
|
@@ -3035,10 +3042,6 @@ class ExternalVariable extends Variable {
|
|
|
3035
3042
|
}
|
|
3036
3043
|
}
|
|
3037
3044
|
|
|
3038
|
-
const BLANK = Object.freeze(Object.create(null));
|
|
3039
|
-
const EMPTY_OBJECT = Object.freeze({});
|
|
3040
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
3041
|
-
|
|
3042
3045
|
const RESERVED_NAMES = new Set([
|
|
3043
3046
|
'await',
|
|
3044
3047
|
'break',
|
|
@@ -7352,6 +7355,19 @@ function is_reference (node, parent) {
|
|
|
7352
7355
|
return false;
|
|
7353
7356
|
}
|
|
7354
7357
|
|
|
7358
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
7359
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
7360
|
+
const pureFunctions = Object.create(null);
|
|
7361
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
7362
|
+
let currentFunctions = pureFunctions;
|
|
7363
|
+
for (const pathSegment of functionName.split('.')) {
|
|
7364
|
+
currentFunctions = currentFunctions[pathSegment] || (currentFunctions[pathSegment] = Object.create(null));
|
|
7365
|
+
}
|
|
7366
|
+
currentFunctions[PureFunctionKey] = true;
|
|
7367
|
+
}
|
|
7368
|
+
return pureFunctions;
|
|
7369
|
+
};
|
|
7370
|
+
|
|
7355
7371
|
/* eslint sort-keys: "off" */
|
|
7356
7372
|
const ValueProperties = Symbol('Value Properties');
|
|
7357
7373
|
const getTruthyLiteralValue = () => UnknownTruthyValue;
|
|
@@ -8345,13 +8361,15 @@ class Identifier extends NodeBase {
|
|
|
8345
8361
|
switch (interaction.type) {
|
|
8346
8362
|
case INTERACTION_ACCESSED: {
|
|
8347
8363
|
return (this.variable !== null &&
|
|
8364
|
+
!this.isPureFunction(path) &&
|
|
8348
8365
|
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
8349
8366
|
}
|
|
8350
8367
|
case INTERACTION_ASSIGNED: {
|
|
8351
8368
|
return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8352
8369
|
}
|
|
8353
8370
|
case INTERACTION_CALLED: {
|
|
8354
|
-
return this.
|
|
8371
|
+
return (!this.isPureFunction(path) &&
|
|
8372
|
+
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
8355
8373
|
}
|
|
8356
8374
|
}
|
|
8357
8375
|
}
|
|
@@ -8433,6 +8451,18 @@ class Identifier extends NodeBase {
|
|
|
8433
8451
|
}
|
|
8434
8452
|
return this.variable;
|
|
8435
8453
|
}
|
|
8454
|
+
isPureFunction(path) {
|
|
8455
|
+
let currentPureFunction = this.context.manualPureFunctions[this.name];
|
|
8456
|
+
for (const segment of path) {
|
|
8457
|
+
if (currentPureFunction) {
|
|
8458
|
+
currentPureFunction = currentPureFunction[segment];
|
|
8459
|
+
}
|
|
8460
|
+
else {
|
|
8461
|
+
return false;
|
|
8462
|
+
}
|
|
8463
|
+
}
|
|
8464
|
+
return currentPureFunction?.[PureFunctionKey];
|
|
8465
|
+
}
|
|
8436
8466
|
}
|
|
8437
8467
|
function closestParentFunctionOrProgram(node) {
|
|
8438
8468
|
while (node && !/^Program|Function/.test(node.type)) {
|
|
@@ -13130,13 +13160,21 @@ function getPluginWithTimers(plugin, index) {
|
|
|
13130
13160
|
timerLabel += ` (${plugin.name})`;
|
|
13131
13161
|
}
|
|
13132
13162
|
timerLabel += ` - ${hook}`;
|
|
13133
|
-
const
|
|
13134
|
-
plugin[hook] = function (...parameters) {
|
|
13163
|
+
const handler = function (...parameters) {
|
|
13135
13164
|
timeStart(timerLabel, 4);
|
|
13136
13165
|
const result = hookFunction.apply(this, parameters);
|
|
13137
13166
|
timeEnd(timerLabel, 4);
|
|
13138
13167
|
return result;
|
|
13139
13168
|
};
|
|
13169
|
+
let hookFunction;
|
|
13170
|
+
if (typeof plugin[hook].handler === 'function') {
|
|
13171
|
+
hookFunction = plugin[hook].handler;
|
|
13172
|
+
plugin[hook].handler = handler;
|
|
13173
|
+
}
|
|
13174
|
+
else {
|
|
13175
|
+
hookFunction = plugin[hook];
|
|
13176
|
+
plugin[hook] = handler;
|
|
13177
|
+
}
|
|
13140
13178
|
}
|
|
13141
13179
|
}
|
|
13142
13180
|
return plugin;
|
|
@@ -13659,6 +13697,7 @@ class Module {
|
|
|
13659
13697
|
includeDynamicImport: this.includeDynamicImport.bind(this),
|
|
13660
13698
|
includeVariableInModule: this.includeVariableInModule.bind(this),
|
|
13661
13699
|
magicString: this.magicString,
|
|
13700
|
+
manualPureFunctions: this.graph.pureFunctions,
|
|
13662
13701
|
module: this,
|
|
13663
13702
|
moduleContext: this.context,
|
|
13664
13703
|
options: this.options,
|
|
@@ -23358,17 +23397,17 @@ class GlobalScope extends Scope$1 {
|
|
|
23358
23397
|
}
|
|
23359
23398
|
}
|
|
23360
23399
|
|
|
23361
|
-
function
|
|
23400
|
+
function getSourceHash(source) {
|
|
23401
|
+
return createHash().update(source).digest('hex');
|
|
23402
|
+
}
|
|
23403
|
+
function generateAssetFileName(name, source, sourceHash, outputOptions, bundle) {
|
|
23362
23404
|
const emittedName = outputOptions.sanitizeFileName(name || 'asset');
|
|
23363
23405
|
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
23364
23406
|
? outputOptions.assetFileNames({ name, source, type: 'asset' })
|
|
23365
23407
|
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
23366
23408
|
ext: () => node_path.extname(emittedName).slice(1),
|
|
23367
23409
|
extname: () => node_path.extname(emittedName),
|
|
23368
|
-
hash: size =>
|
|
23369
|
-
.update(source)
|
|
23370
|
-
.digest('hex')
|
|
23371
|
-
.slice(0, Math.max(0, size || defaultHashSize)),
|
|
23410
|
+
hash: size => sourceHash.slice(0, Math.max(0, size || defaultHashSize)),
|
|
23372
23411
|
name: () => emittedName.slice(0, Math.max(0, emittedName.length - node_path.extname(emittedName).length))
|
|
23373
23412
|
}), bundle);
|
|
23374
23413
|
}
|
|
@@ -23473,9 +23512,6 @@ class FileEmitter {
|
|
|
23473
23512
|
for (const emittedFile of this.filesByReferenceId.values()) {
|
|
23474
23513
|
if (emittedFile.fileName) {
|
|
23475
23514
|
reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
|
|
23476
|
-
if (emittedFile.type === 'asset' && typeof emittedFile.source === 'string') {
|
|
23477
|
-
fileNamesBySource.set(emittedFile.source, emittedFile.fileName);
|
|
23478
|
-
}
|
|
23479
23515
|
}
|
|
23480
23516
|
}
|
|
23481
23517
|
for (const [referenceId, consumedFile] of this.filesByReferenceId) {
|
|
@@ -23543,15 +23579,19 @@ class FileEmitter {
|
|
|
23543
23579
|
return this.assignReferenceId(consumedChunk, emittedChunk.id);
|
|
23544
23580
|
}
|
|
23545
23581
|
finalizeAsset(consumedFile, source, referenceId, { bundle, fileNamesBySource, outputOptions }) {
|
|
23546
|
-
|
|
23547
|
-
|
|
23548
|
-
|
|
23582
|
+
let fileName = consumedFile.fileName;
|
|
23583
|
+
// Deduplicate assets if an explicit fileName is not provided
|
|
23584
|
+
if (!fileName) {
|
|
23585
|
+
const sourceHash = getSourceHash(source);
|
|
23586
|
+
fileName = fileNamesBySource.get(sourceHash);
|
|
23587
|
+
if (!fileName) {
|
|
23588
|
+
fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
|
|
23589
|
+
fileNamesBySource.set(sourceHash, fileName);
|
|
23590
|
+
}
|
|
23591
|
+
}
|
|
23549
23592
|
// We must not modify the original assets to avoid interaction between outputs
|
|
23550
23593
|
const assetWithFileName = { ...consumedFile, fileName, source };
|
|
23551
23594
|
this.filesByReferenceId.set(referenceId, assetWithFileName);
|
|
23552
|
-
if (typeof source === 'string') {
|
|
23553
|
-
fileNamesBySource.set(source, fileName);
|
|
23554
|
-
}
|
|
23555
23595
|
bundle[fileName] = {
|
|
23556
23596
|
fileName,
|
|
23557
23597
|
name: consumedFile.name,
|
|
@@ -23979,6 +24019,7 @@ class Graph {
|
|
|
23979
24019
|
this.acornParser = Parser.extend(...options.acornInjectPlugins);
|
|
23980
24020
|
this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver);
|
|
23981
24021
|
this.fileOperationQueue = new Queue(options.maxParallelFileOps);
|
|
24022
|
+
this.pureFunctions = getPureFunctions(options);
|
|
23982
24023
|
}
|
|
23983
24024
|
async build() {
|
|
23984
24025
|
timeStart('generate module graph', 2);
|
|
@@ -24596,6 +24637,7 @@ const getTreeshake = (config) => {
|
|
|
24596
24637
|
return {
|
|
24597
24638
|
annotations: configWithPreset.annotations !== false,
|
|
24598
24639
|
correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true,
|
|
24640
|
+
manualPureFunctions: configWithPreset.manualPureFunctions ?? EMPTY_ARRAY,
|
|
24599
24641
|
moduleSideEffects: getHasModuleSideEffects(configWithPreset.moduleSideEffects),
|
|
24600
24642
|
propertyReadSideEffects: configWithPreset.propertyReadSideEffects === 'always'
|
|
24601
24643
|
? 'always'
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED