rollup 2.18.1 → 2.21.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/CHANGELOG.md +38 -0
- 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 +131 -99
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.d.ts +24 -22
- 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 +131 -99
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +2 -2
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.21.0
|
|
4
|
+
Tue, 07 Jul 2020 19:25:24 GMT - commit b1aaedc37f1bf83ed410f4b5c4ea950b12b14e7a
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -28,7 +28,7 @@ var crypto = require('crypto');
|
|
|
28
28
|
var fs = require('fs');
|
|
29
29
|
var events = require('events');
|
|
30
30
|
|
|
31
|
-
var version = "2.
|
|
31
|
+
var version = "2.21.0";
|
|
32
32
|
|
|
33
33
|
function createCommonjsModule(fn, basedir, module) {
|
|
34
34
|
return module = {
|
|
@@ -3094,6 +3094,15 @@ class ThisVariable extends LocalVariable {
|
|
|
3094
3094
|
}
|
|
3095
3095
|
}
|
|
3096
3096
|
|
|
3097
|
+
class SpreadElement extends NodeBase {
|
|
3098
|
+
bind() {
|
|
3099
|
+
super.bind();
|
|
3100
|
+
// Only properties of properties of the argument could become subject to reassignment
|
|
3101
|
+
// This will also reassign the return values of iterators
|
|
3102
|
+
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3097
3106
|
class ParameterScope extends ChildScope {
|
|
3098
3107
|
constructor(parent, context) {
|
|
3099
3108
|
super(parent);
|
|
@@ -3131,6 +3140,14 @@ class ParameterScope extends ChildScope {
|
|
|
3131
3140
|
let calledFromTryStatement = false;
|
|
3132
3141
|
let argIncluded = false;
|
|
3133
3142
|
const restParam = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
3143
|
+
for (const checkedArg of args) {
|
|
3144
|
+
if (checkedArg instanceof SpreadElement) {
|
|
3145
|
+
for (const arg of args) {
|
|
3146
|
+
arg.include(context, false);
|
|
3147
|
+
}
|
|
3148
|
+
break;
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3134
3151
|
for (let index = args.length - 1; index >= 0; index--) {
|
|
3135
3152
|
const paramVars = this.parameters[index] || restParam;
|
|
3136
3153
|
const arg = args[index];
|
|
@@ -7623,6 +7640,13 @@ const ASSET_PREFIX = 'ROLLUP_ASSET_URL_';
|
|
|
7623
7640
|
const CHUNK_PREFIX = 'ROLLUP_CHUNK_URL_';
|
|
7624
7641
|
const FILE_PREFIX = 'ROLLUP_FILE_URL_';
|
|
7625
7642
|
class MetaProperty extends NodeBase {
|
|
7643
|
+
getReferencedFileName(outputPluginDriver) {
|
|
7644
|
+
const metaProperty = this.metaProperty;
|
|
7645
|
+
if (metaProperty && metaProperty.startsWith(FILE_PREFIX)) {
|
|
7646
|
+
return outputPluginDriver.getFileName(metaProperty.substr(FILE_PREFIX.length));
|
|
7647
|
+
}
|
|
7648
|
+
return null;
|
|
7649
|
+
}
|
|
7626
7650
|
hasEffects() {
|
|
7627
7651
|
return false;
|
|
7628
7652
|
}
|
|
@@ -7632,30 +7656,26 @@ class MetaProperty extends NodeBase {
|
|
|
7632
7656
|
include() {
|
|
7633
7657
|
if (!this.included) {
|
|
7634
7658
|
this.included = true;
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
parent
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
metaProperty.startsWith(
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7659
|
+
if (this.meta.name === 'import') {
|
|
7660
|
+
this.context.addImportMeta(this);
|
|
7661
|
+
const parent = this.parent;
|
|
7662
|
+
const metaProperty = (this.metaProperty =
|
|
7663
|
+
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
7664
|
+
? parent.propertyKey
|
|
7665
|
+
: null);
|
|
7666
|
+
if (metaProperty &&
|
|
7667
|
+
(metaProperty.startsWith(FILE_PREFIX) ||
|
|
7668
|
+
metaProperty.startsWith(ASSET_PREFIX) ||
|
|
7669
|
+
metaProperty.startsWith(CHUNK_PREFIX))) {
|
|
7670
|
+
this.scope.addAccessedGlobalsByFormat(accessedFileUrlGlobals);
|
|
7671
|
+
}
|
|
7672
|
+
else {
|
|
7673
|
+
this.scope.addAccessedGlobalsByFormat(accessedMetaUrlGlobals);
|
|
7674
|
+
}
|
|
7648
7675
|
}
|
|
7649
7676
|
}
|
|
7650
7677
|
}
|
|
7651
|
-
initialise() {
|
|
7652
|
-
if (this.meta.name === 'import') {
|
|
7653
|
-
this.context.addImportMeta(this);
|
|
7654
|
-
}
|
|
7655
|
-
}
|
|
7656
7678
|
renderFinalMechanism(code, chunkId, format, outputPluginDriver) {
|
|
7657
|
-
if (!this.included)
|
|
7658
|
-
return;
|
|
7659
7679
|
const parent = this.parent;
|
|
7660
7680
|
const metaProperty = this.metaProperty;
|
|
7661
7681
|
if (metaProperty &&
|
|
@@ -7801,15 +7821,6 @@ class NewExpression extends NodeBase {
|
|
|
7801
7821
|
}
|
|
7802
7822
|
}
|
|
7803
7823
|
|
|
7804
|
-
class SpreadElement extends NodeBase {
|
|
7805
|
-
bind() {
|
|
7806
|
-
super.bind();
|
|
7807
|
-
// Only properties of properties of the argument could become subject to reassignment
|
|
7808
|
-
// This will also reassign the return values of iterators
|
|
7809
|
-
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
7810
|
-
}
|
|
7811
|
-
}
|
|
7812
|
-
|
|
7813
7824
|
class ObjectExpression extends NodeBase {
|
|
7814
7825
|
constructor() {
|
|
7815
7826
|
super(...arguments);
|
|
@@ -9655,7 +9666,7 @@ class Module {
|
|
|
9655
9666
|
}
|
|
9656
9667
|
relevantDependencies.add(variable.module);
|
|
9657
9668
|
}
|
|
9658
|
-
if (this.options.treeshake) {
|
|
9669
|
+
if (this.options.treeshake && this.moduleSideEffects !== 'no-treeshake') {
|
|
9659
9670
|
for (const dependency of possibleDependencies) {
|
|
9660
9671
|
if (!(dependency.moduleSideEffects || additionalSideEffectModules.has(dependency)) ||
|
|
9661
9672
|
relevantDependencies.has(dependency)) {
|
|
@@ -9794,7 +9805,8 @@ class Module {
|
|
|
9794
9805
|
return null;
|
|
9795
9806
|
}
|
|
9796
9807
|
hasEffects() {
|
|
9797
|
-
return this.
|
|
9808
|
+
return (this.moduleSideEffects === 'no-treeshake' ||
|
|
9809
|
+
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
9798
9810
|
}
|
|
9799
9811
|
include() {
|
|
9800
9812
|
const context = createInclusionContext();
|
|
@@ -9875,10 +9887,10 @@ class Module {
|
|
|
9875
9887
|
}
|
|
9876
9888
|
this.transformDependencies = transformDependencies;
|
|
9877
9889
|
this.customTransformCache = customTransformCache;
|
|
9878
|
-
if (
|
|
9890
|
+
if (moduleSideEffects != null) {
|
|
9879
9891
|
this.moduleSideEffects = moduleSideEffects;
|
|
9880
9892
|
}
|
|
9881
|
-
if (
|
|
9893
|
+
if (syntheticNamedExports != null) {
|
|
9882
9894
|
this.syntheticNamedExports = syntheticNamedExports;
|
|
9883
9895
|
}
|
|
9884
9896
|
timeStart('generate ast', 3);
|
|
@@ -10619,7 +10631,10 @@ function renderChunk({ code, options, outputPluginDriver, renderChunk, sourcemap
|
|
|
10619
10631
|
return outputPluginDriver.hookReduceArg0('renderChunk', [code, renderChunk, options], renderChunkReducer);
|
|
10620
10632
|
}
|
|
10621
10633
|
|
|
10622
|
-
function renderNamePattern(pattern, patternName, replacements) {
|
|
10634
|
+
function renderNamePattern(pattern, patternName, replacements, getFileInfo) {
|
|
10635
|
+
if (typeof pattern === 'function') {
|
|
10636
|
+
pattern = pattern(getFileInfo());
|
|
10637
|
+
}
|
|
10623
10638
|
if (!isPlainPathFragment(pattern))
|
|
10624
10639
|
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths and must not contain invalid characters.`));
|
|
10625
10640
|
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
|
|
@@ -10661,11 +10676,12 @@ function getGlobalName(module, globals, hasExports, warn) {
|
|
|
10661
10676
|
}
|
|
10662
10677
|
}
|
|
10663
10678
|
class Chunk$1 {
|
|
10664
|
-
constructor(orderedModules, inputOptions, outputOptions, unsetOptions, modulesById, chunkByModule, facadeChunkByModule, manualChunkAlias) {
|
|
10679
|
+
constructor(orderedModules, inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, manualChunkAlias) {
|
|
10665
10680
|
this.orderedModules = orderedModules;
|
|
10666
10681
|
this.inputOptions = inputOptions;
|
|
10667
10682
|
this.outputOptions = outputOptions;
|
|
10668
10683
|
this.unsetOptions = unsetOptions;
|
|
10684
|
+
this.pluginDriver = pluginDriver;
|
|
10669
10685
|
this.modulesById = modulesById;
|
|
10670
10686
|
this.chunkByModule = chunkByModule;
|
|
10671
10687
|
this.facadeChunkByModule = facadeChunkByModule;
|
|
@@ -10721,8 +10737,8 @@ class Chunk$1 {
|
|
|
10721
10737
|
}
|
|
10722
10738
|
this.variableName = makeLegal(this.generateVariableName());
|
|
10723
10739
|
}
|
|
10724
|
-
static generateFacade(inputOptions, outputOptions, unsetOptions, modulesById, chunkByModule, facadeChunkByModule, facadedModule, facadeName) {
|
|
10725
|
-
const chunk = new Chunk$1([], inputOptions, outputOptions, unsetOptions, modulesById, chunkByModule, facadeChunkByModule, null);
|
|
10740
|
+
static generateFacade(inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, facadedModule, facadeName) {
|
|
10741
|
+
const chunk = new Chunk$1([], inputOptions, outputOptions, unsetOptions, pluginDriver, modulesById, chunkByModule, facadeChunkByModule, null);
|
|
10726
10742
|
chunk.assignFacadeName(facadeName, facadedModule);
|
|
10727
10743
|
if (!facadeChunkByModule.has(facadedModule)) {
|
|
10728
10744
|
facadeChunkByModule.set(facadedModule, chunk);
|
|
@@ -10826,7 +10842,7 @@ class Chunk$1 {
|
|
|
10826
10842
|
this.assignFacadeName(requiredFacades.shift(), module);
|
|
10827
10843
|
}
|
|
10828
10844
|
for (const facadeName of requiredFacades) {
|
|
10829
|
-
facades.push(Chunk$1.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.modulesById, this.chunkByModule, this.facadeChunkByModule, module, facadeName));
|
|
10845
|
+
facades.push(Chunk$1.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.facadeChunkByModule, module, facadeName));
|
|
10830
10846
|
}
|
|
10831
10847
|
}
|
|
10832
10848
|
for (const module of this.dynamicEntryModules) {
|
|
@@ -10850,7 +10866,7 @@ class Chunk$1 {
|
|
|
10850
10866
|
}
|
|
10851
10867
|
return facades;
|
|
10852
10868
|
}
|
|
10853
|
-
generateId(addons, options, existingNames, includeHash
|
|
10869
|
+
generateId(addons, options, existingNames, includeHash) {
|
|
10854
10870
|
if (this.fileName !== null) {
|
|
10855
10871
|
return this.fileName;
|
|
10856
10872
|
}
|
|
@@ -10860,10 +10876,10 @@ class Chunk$1 {
|
|
|
10860
10876
|
return makeUnique(renderNamePattern(pattern, patternName, {
|
|
10861
10877
|
format: () => options.format,
|
|
10862
10878
|
hash: () => includeHash
|
|
10863
|
-
? this.computeContentHashWithDependencies(addons, options, existingNames
|
|
10879
|
+
? this.computeContentHashWithDependencies(addons, options, existingNames)
|
|
10864
10880
|
: '[hash]',
|
|
10865
10881
|
name: () => this.getChunkName()
|
|
10866
|
-
}), existingNames);
|
|
10882
|
+
}, this.getChunkInfo.bind(this)), existingNames);
|
|
10867
10883
|
}
|
|
10868
10884
|
generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
|
|
10869
10885
|
const id = this.orderedModules[0].id;
|
|
@@ -10881,34 +10897,22 @@ class Chunk$1 {
|
|
|
10881
10897
|
extname: () => extension,
|
|
10882
10898
|
format: () => options.format,
|
|
10883
10899
|
name: () => this.getChunkName()
|
|
10884
|
-
})}`);
|
|
10900
|
+
}, this.getChunkInfo.bind(this))}`);
|
|
10885
10901
|
}
|
|
10886
10902
|
else {
|
|
10887
10903
|
path$1 = `_virtual/${path.basename(sanitizedId)}`;
|
|
10888
10904
|
}
|
|
10889
10905
|
return makeUnique(normalize(path$1), existingNames);
|
|
10890
10906
|
}
|
|
10891
|
-
|
|
10892
|
-
return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName()));
|
|
10893
|
-
}
|
|
10894
|
-
getExportNames() {
|
|
10895
|
-
return (this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName).sort()));
|
|
10896
|
-
}
|
|
10897
|
-
getPrerenderedChunk() {
|
|
10907
|
+
getChunkInfo() {
|
|
10898
10908
|
const facadeModule = this.facadeModule;
|
|
10899
10909
|
const getChunkName = this.getChunkName.bind(this);
|
|
10900
10910
|
return {
|
|
10901
|
-
code: undefined,
|
|
10902
|
-
dynamicImports: Array.from(this.dynamicDependencies, getId),
|
|
10903
10911
|
exports: this.getExportNames(),
|
|
10904
10912
|
facadeModuleId: facadeModule && facadeModule.id,
|
|
10905
|
-
fileName: undefined,
|
|
10906
|
-
implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId),
|
|
10907
|
-
imports: Array.from(this.dependencies, getId),
|
|
10908
10913
|
isDynamicEntry: this.dynamicEntryModules.length > 0,
|
|
10909
10914
|
isEntry: facadeModule !== null && facadeModule.isEntryPoint,
|
|
10910
10915
|
isImplicitEntry: this.implicitEntryModules.length > 0,
|
|
10911
|
-
map: undefined,
|
|
10912
10916
|
modules: this.renderedModules,
|
|
10913
10917
|
get name() {
|
|
10914
10918
|
return getChunkName();
|
|
@@ -10916,11 +10920,28 @@ class Chunk$1 {
|
|
|
10916
10920
|
type: 'chunk'
|
|
10917
10921
|
};
|
|
10918
10922
|
}
|
|
10919
|
-
|
|
10923
|
+
getChunkInfoWithFileNames() {
|
|
10924
|
+
return Object.assign(this.getChunkInfo(), {
|
|
10925
|
+
code: undefined,
|
|
10926
|
+
dynamicImports: Array.from(this.dynamicDependencies, getId),
|
|
10927
|
+
fileName: this.id,
|
|
10928
|
+
implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId),
|
|
10929
|
+
imports: Array.from(this.dependencies, getId),
|
|
10930
|
+
map: undefined,
|
|
10931
|
+
referencedFiles: this.getReferencedFiles()
|
|
10932
|
+
});
|
|
10933
|
+
}
|
|
10934
|
+
getChunkName() {
|
|
10935
|
+
return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName()));
|
|
10936
|
+
}
|
|
10937
|
+
getExportNames() {
|
|
10938
|
+
return (this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName).sort()));
|
|
10939
|
+
}
|
|
10940
|
+
getRenderedHash() {
|
|
10920
10941
|
if (this.renderedHash)
|
|
10921
10942
|
return this.renderedHash;
|
|
10922
10943
|
const hash = createHash();
|
|
10923
|
-
const hashAugmentation =
|
|
10944
|
+
const hashAugmentation = this.pluginDriver.hookReduceValueSync('augmentChunkHash', '', [this.getChunkInfo()], (hashAugmentation, pluginHash) => {
|
|
10924
10945
|
if (pluginHash) {
|
|
10925
10946
|
hashAugmentation += pluginHash;
|
|
10926
10947
|
}
|
|
@@ -10951,7 +10972,7 @@ class Chunk$1 {
|
|
|
10951
10972
|
}
|
|
10952
10973
|
}
|
|
10953
10974
|
// prerender allows chunk hashes and names to be generated before finalizing
|
|
10954
|
-
preRender(options, inputBase
|
|
10975
|
+
preRender(options, inputBase) {
|
|
10955
10976
|
const magicString = new Bundle({ separator: options.compact ? '' : '\n\n' });
|
|
10956
10977
|
this.usedModules = [];
|
|
10957
10978
|
this.indentString = getIndentString(this.orderedModules, options);
|
|
@@ -10965,7 +10986,7 @@ class Chunk$1 {
|
|
|
10965
10986
|
freeze: options.freeze,
|
|
10966
10987
|
indent: this.indentString,
|
|
10967
10988
|
namespaceToStringTag: options.namespaceToStringTag,
|
|
10968
|
-
outputPluginDriver,
|
|
10989
|
+
outputPluginDriver: this.pluginDriver,
|
|
10969
10990
|
varOrConst: options.preferConst ? 'const' : 'var'
|
|
10970
10991
|
};
|
|
10971
10992
|
// for static and dynamic entry points, inline the execution list to avoid loading latency
|
|
@@ -11038,7 +11059,7 @@ class Chunk$1 {
|
|
|
11038
11059
|
this.renderedExports =
|
|
11039
11060
|
this.exportMode === 'none' ? [] : this.getChunkExportDeclarations(options.format);
|
|
11040
11061
|
}
|
|
11041
|
-
async render(options, addons, outputChunk
|
|
11062
|
+
async render(options, addons, outputChunk) {
|
|
11042
11063
|
timeStart('render format', 2);
|
|
11043
11064
|
const format = options.format;
|
|
11044
11065
|
const finalise = finalisers[format];
|
|
@@ -11062,7 +11083,7 @@ class Chunk$1 {
|
|
|
11062
11083
|
}
|
|
11063
11084
|
}
|
|
11064
11085
|
this.finaliseDynamicImports(options);
|
|
11065
|
-
this.finaliseImportMetas(format
|
|
11086
|
+
this.finaliseImportMetas(format);
|
|
11066
11087
|
const hasExports = this.renderedExports.length !== 0 ||
|
|
11067
11088
|
[...this.renderedDependencies.values()].some(dep => (dep.reexports && dep.reexports.length !== 0));
|
|
11068
11089
|
let usesTopLevelAwait = false;
|
|
@@ -11111,7 +11132,7 @@ class Chunk$1 {
|
|
|
11111
11132
|
let code = await renderChunk({
|
|
11112
11133
|
code: prevCode,
|
|
11113
11134
|
options,
|
|
11114
|
-
outputPluginDriver,
|
|
11135
|
+
outputPluginDriver: this.pluginDriver,
|
|
11115
11136
|
renderChunk: outputChunk,
|
|
11116
11137
|
sourcemapChain: chunkSourcemapChain
|
|
11117
11138
|
});
|
|
@@ -11166,7 +11187,7 @@ class Chunk$1 {
|
|
|
11166
11187
|
this.name = sanitizeFileName(name || facadedModule.chunkName || getAliasName(facadedModule.id));
|
|
11167
11188
|
}
|
|
11168
11189
|
}
|
|
11169
|
-
computeContentHashWithDependencies(addons, options, existingNames
|
|
11190
|
+
computeContentHashWithDependencies(addons, options, existingNames) {
|
|
11170
11191
|
const hash = createHash();
|
|
11171
11192
|
hash.update([addons.intro, addons.outro, addons.banner, addons.footer].map(addon => addon || '').join(':'));
|
|
11172
11193
|
hash.update(options.format);
|
|
@@ -11176,8 +11197,8 @@ class Chunk$1 {
|
|
|
11176
11197
|
hash.update(':' + current.renderPath);
|
|
11177
11198
|
}
|
|
11178
11199
|
else {
|
|
11179
|
-
hash.update(current.getRenderedHash(
|
|
11180
|
-
hash.update(current.generateId(addons, options, existingNames, false
|
|
11200
|
+
hash.update(current.getRenderedHash());
|
|
11201
|
+
hash.update(current.generateId(addons, options, existingNames, false));
|
|
11181
11202
|
}
|
|
11182
11203
|
if (current instanceof ExternalModule)
|
|
11183
11204
|
continue;
|
|
@@ -11230,10 +11251,10 @@ class Chunk$1 {
|
|
|
11230
11251
|
}
|
|
11231
11252
|
}
|
|
11232
11253
|
}
|
|
11233
|
-
finaliseImportMetas(format
|
|
11254
|
+
finaliseImportMetas(format) {
|
|
11234
11255
|
for (const [module, code] of this.renderedModuleSources) {
|
|
11235
11256
|
for (const importMeta of module.importMetas) {
|
|
11236
|
-
importMeta.renderFinalMechanism(code, this.id, format,
|
|
11257
|
+
importMeta.renderFinalMechanism(code, this.id, format, this.pluginDriver);
|
|
11237
11258
|
}
|
|
11238
11259
|
}
|
|
11239
11260
|
}
|
|
@@ -11384,6 +11405,18 @@ class Chunk$1 {
|
|
|
11384
11405
|
}
|
|
11385
11406
|
return getAliasName(this.orderedModules[this.orderedModules.length - 1].id);
|
|
11386
11407
|
}
|
|
11408
|
+
getReferencedFiles() {
|
|
11409
|
+
const referencedFiles = [];
|
|
11410
|
+
for (const module of this.orderedModules) {
|
|
11411
|
+
for (const meta of module.importMetas) {
|
|
11412
|
+
const fileName = meta.getReferencedFileName(this.pluginDriver);
|
|
11413
|
+
if (fileName) {
|
|
11414
|
+
referencedFiles.push(fileName);
|
|
11415
|
+
}
|
|
11416
|
+
}
|
|
11417
|
+
}
|
|
11418
|
+
return referencedFiles;
|
|
11419
|
+
}
|
|
11387
11420
|
getRelativePath(targetPath, stripJsExtension) {
|
|
11388
11421
|
let relativePath = normalize(relative(path.dirname(this.id), targetPath));
|
|
11389
11422
|
if (stripJsExtension && relativePath.endsWith('.js')) {
|
|
@@ -11724,7 +11757,7 @@ function generateAssetFileName(name, source, output) {
|
|
|
11724
11757
|
ext: () => path.extname(emittedName).substr(1),
|
|
11725
11758
|
extname: () => path.extname(emittedName),
|
|
11726
11759
|
name: () => emittedName.substr(0, emittedName.length - path.extname(emittedName).length)
|
|
11727
|
-
}), output.bundle);
|
|
11760
|
+
}, () => ({ name, source, type: 'asset' })), output.bundle);
|
|
11728
11761
|
}
|
|
11729
11762
|
function reserveFileNameInBundle(fileName, bundle, warn) {
|
|
11730
11763
|
if (fileName in bundle) {
|
|
@@ -11908,6 +11941,7 @@ class FileEmitter {
|
|
|
11908
11941
|
const options = this.options;
|
|
11909
11942
|
output.bundle[fileName] = {
|
|
11910
11943
|
fileName,
|
|
11944
|
+
name: consumedFile.name,
|
|
11911
11945
|
get isAsset() {
|
|
11912
11946
|
warnDeprecation('Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead', true, options);
|
|
11913
11947
|
return true;
|
|
@@ -11992,17 +12026,11 @@ class Bundle$1 {
|
|
|
11992
12026
|
async addFinalizedChunksToBundle(chunks, inputBase, addons, outputBundle) {
|
|
11993
12027
|
this.assignChunkIds(chunks, inputBase, addons, outputBundle);
|
|
11994
12028
|
for (const chunk of chunks) {
|
|
11995
|
-
|
|
11996
|
-
chunkDescription.fileName = chunk.id;
|
|
12029
|
+
outputBundle[chunk.id] = chunk.getChunkInfoWithFileNames();
|
|
11997
12030
|
}
|
|
11998
|
-
await Promise.all(chunks.map(chunk => {
|
|
12031
|
+
await Promise.all(chunks.map(async (chunk) => {
|
|
11999
12032
|
const outputChunk = outputBundle[chunk.id];
|
|
12000
|
-
|
|
12001
|
-
.render(this.outputOptions, addons, outputChunk, this.pluginDriver)
|
|
12002
|
-
.then(rendered => {
|
|
12003
|
-
outputChunk.code = rendered.code;
|
|
12004
|
-
outputChunk.map = rendered.map;
|
|
12005
|
-
});
|
|
12033
|
+
Object.assign(outputChunk, await chunk.render(this.outputOptions, addons, outputChunk));
|
|
12006
12034
|
}));
|
|
12007
12035
|
}
|
|
12008
12036
|
async addManualChunks(manualChunks) {
|
|
@@ -12036,7 +12064,7 @@ class Bundle$1 {
|
|
|
12036
12064
|
chunk.id = chunk.generateIdPreserveModules(inputBase, this.outputOptions, bundle, this.unsetOptions);
|
|
12037
12065
|
}
|
|
12038
12066
|
else {
|
|
12039
|
-
chunk.id = chunk.generateId(addons, this.outputOptions, bundle, true
|
|
12067
|
+
chunk.id = chunk.generateId(addons, this.outputOptions, bundle, true);
|
|
12040
12068
|
}
|
|
12041
12069
|
bundle[chunk.id] = FILE_PLACEHOLDER;
|
|
12042
12070
|
}
|
|
@@ -12083,7 +12111,7 @@ class Bundle$1 {
|
|
|
12083
12111
|
}))
|
|
12084
12112
|
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
|
|
12085
12113
|
sortByExecutionOrder(modules);
|
|
12086
|
-
const chunk = new Chunk$1(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.graph.modulesById, chunkByModule, this.facadeChunkByModule, alias);
|
|
12114
|
+
const chunk = new Chunk$1(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, this.facadeChunkByModule, alias);
|
|
12087
12115
|
chunks.push(chunk);
|
|
12088
12116
|
for (const module of modules) {
|
|
12089
12117
|
chunkByModule.set(module, chunk);
|
|
@@ -12103,7 +12131,7 @@ class Bundle$1 {
|
|
|
12103
12131
|
chunk.generateExports();
|
|
12104
12132
|
}
|
|
12105
12133
|
for (const chunk of chunks) {
|
|
12106
|
-
chunk.preRender(this.outputOptions, inputBase
|
|
12134
|
+
chunk.preRender(this.outputOptions, inputBase);
|
|
12107
12135
|
}
|
|
12108
12136
|
}
|
|
12109
12137
|
}
|
|
@@ -17515,10 +17543,10 @@ function transform(source, module, pluginDriver, warn) {
|
|
|
17515
17543
|
if (typeof result.map === 'string') {
|
|
17516
17544
|
result.map = JSON.parse(result.map);
|
|
17517
17545
|
}
|
|
17518
|
-
if (
|
|
17546
|
+
if (result.moduleSideEffects != null) {
|
|
17519
17547
|
moduleSideEffects = result.moduleSideEffects;
|
|
17520
17548
|
}
|
|
17521
|
-
if (
|
|
17549
|
+
if (result.syntheticNamedExports != null) {
|
|
17522
17550
|
syntheticNamedExports = result.syntheticNamedExports;
|
|
17523
17551
|
}
|
|
17524
17552
|
}
|
|
@@ -17740,10 +17768,10 @@ class ModuleLoader {
|
|
|
17740
17768
|
module.setSource(cachedModule);
|
|
17741
17769
|
}
|
|
17742
17770
|
else {
|
|
17743
|
-
if (
|
|
17771
|
+
if (sourceDescription.moduleSideEffects != null) {
|
|
17744
17772
|
module.moduleSideEffects = sourceDescription.moduleSideEffects;
|
|
17745
17773
|
}
|
|
17746
|
-
if (
|
|
17774
|
+
if (sourceDescription.syntheticNamedExports != null) {
|
|
17747
17775
|
module.syntheticNamedExports = sourceDescription.syntheticNamedExports;
|
|
17748
17776
|
}
|
|
17749
17777
|
module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options.onwarn));
|
|
@@ -17878,10 +17906,10 @@ class ModuleLoader {
|
|
|
17878
17906
|
if (resolveIdResult.external) {
|
|
17879
17907
|
external = true;
|
|
17880
17908
|
}
|
|
17881
|
-
if (
|
|
17909
|
+
if (resolveIdResult.moduleSideEffects != null) {
|
|
17882
17910
|
moduleSideEffects = resolveIdResult.moduleSideEffects;
|
|
17883
17911
|
}
|
|
17884
|
-
if (
|
|
17912
|
+
if (resolveIdResult.syntheticNamedExports != null) {
|
|
17885
17913
|
syntheticNamedExports = resolveIdResult.syntheticNamedExports;
|
|
17886
17914
|
}
|
|
17887
17915
|
}
|
|
@@ -17902,9 +17930,7 @@ class ModuleLoader {
|
|
|
17902
17930
|
return {
|
|
17903
17931
|
external,
|
|
17904
17932
|
id,
|
|
17905
|
-
moduleSideEffects:
|
|
17906
|
-
? moduleSideEffects
|
|
17907
|
-
: this.hasModuleSideEffects(id, external),
|
|
17933
|
+
moduleSideEffects: moduleSideEffects !== null && moduleSideEffects !== void 0 ? moduleSideEffects : this.hasModuleSideEffects(id, external),
|
|
17908
17934
|
syntheticNamedExports
|
|
17909
17935
|
};
|
|
17910
17936
|
}
|
|
@@ -18394,8 +18420,14 @@ class Graph {
|
|
|
18394
18420
|
timeStart(`treeshaking pass ${treeshakingPass}`, 3);
|
|
18395
18421
|
this.needsTreeshakingPass = false;
|
|
18396
18422
|
for (const module of this.modules) {
|
|
18397
|
-
if (module.isExecuted)
|
|
18398
|
-
module.
|
|
18423
|
+
if (module.isExecuted) {
|
|
18424
|
+
if (module.moduleSideEffects === 'no-treeshake') {
|
|
18425
|
+
module.includeAllInBundle();
|
|
18426
|
+
}
|
|
18427
|
+
else {
|
|
18428
|
+
module.include();
|
|
18429
|
+
}
|
|
18430
|
+
}
|
|
18399
18431
|
}
|
|
18400
18432
|
timeEnd(`treeshaking pass ${treeshakingPass++}`, 3);
|
|
18401
18433
|
} while (this.needsTreeshakingPass);
|
|
@@ -19281,7 +19313,7 @@ function rollup(rawInputOptions) {
|
|
|
19281
19313
|
return rollupInternal(rawInputOptions, null);
|
|
19282
19314
|
}
|
|
19283
19315
|
async function rollupInternal(rawInputOptions, watcher) {
|
|
19284
|
-
const { options: inputOptions, unsetOptions: unsetInputOptions } = getInputOptions(rawInputOptions, watcher !== null);
|
|
19316
|
+
const { options: inputOptions, unsetOptions: unsetInputOptions } = await getInputOptions(rawInputOptions, watcher !== null);
|
|
19285
19317
|
initialiseTimers(inputOptions);
|
|
19286
19318
|
const graph = new Graph(inputOptions, watcher);
|
|
19287
19319
|
// remove the cache option from the memory after graph creation (cache is not used anymore)
|
|
@@ -19317,19 +19349,19 @@ async function rollupInternal(rawInputOptions, watcher) {
|
|
|
19317
19349
|
result.getTimings = getTimings;
|
|
19318
19350
|
return result;
|
|
19319
19351
|
}
|
|
19320
|
-
function getInputOptions(rawInputOptions, watchMode) {
|
|
19352
|
+
async function getInputOptions(rawInputOptions, watchMode) {
|
|
19321
19353
|
if (!rawInputOptions) {
|
|
19322
19354
|
throw new Error('You must supply an options object to rollup');
|
|
19323
19355
|
}
|
|
19324
19356
|
const rawPlugins = ensureArray(rawInputOptions.plugins);
|
|
19325
|
-
const { options, unsetOptions } = normalizeInputOptions(rawPlugins.reduce(applyOptionHook(watchMode), rawInputOptions));
|
|
19357
|
+
const { options, unsetOptions } = normalizeInputOptions(await rawPlugins.reduce(applyOptionHook(watchMode), Promise.resolve(rawInputOptions)));
|
|
19326
19358
|
normalizePlugins(options.plugins, ANONYMOUS_PLUGIN_PREFIX);
|
|
19327
19359
|
return { options, unsetOptions };
|
|
19328
19360
|
}
|
|
19329
19361
|
function applyOptionHook(watchMode) {
|
|
19330
|
-
return (inputOptions, plugin) => {
|
|
19362
|
+
return async (inputOptions, plugin) => {
|
|
19331
19363
|
if (plugin.options)
|
|
19332
|
-
return (plugin.options.call({ meta: { rollupVersion: version, watchMode } }, inputOptions) || inputOptions);
|
|
19364
|
+
return (plugin.options.call({ meta: { rollupVersion: version, watchMode } }, await inputOptions) || inputOptions);
|
|
19333
19365
|
return inputOptions;
|
|
19334
19366
|
};
|
|
19335
19367
|
}
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"description": "Next-generation ES module bundler",
|
|
5
5
|
"main": "dist/rollup.js",
|
|
6
6
|
"module": "dist/es/rollup.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"pretest": "npm run build:test",
|
|
30
30
|
"pretest:coverage": "npm run build:test && shx rm -rf coverage/*",
|
|
31
31
|
"pretest:typescript": "shx rm -rf test/typescript/dist && shx cp -r dist test/typescript/",
|
|
32
|
-
"security": "npm audit",
|
|
32
|
+
"security": "# npm audit # deactivated until there is a solution for the lodash issue",
|
|
33
33
|
"test": "npm run test:all",
|
|
34
34
|
"test:all": "npm run test:only && npm run test:typescript && npm run test:leak && npm run test:package",
|
|
35
35
|
"test:coverage": "nyc --reporter html mocha",
|