rollup 2.41.5 → 2.42.3
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 +36 -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 +142 -122
- 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.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +16 -3
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +142 -122
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
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 v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.42.3
|
|
4
|
+
Mon, 22 Mar 2021 14:48:44 GMT - commit f67e6c9b2cb4066f2ddcdb6d45308f840b2ac62f
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -14,7 +14,7 @@ import * as fs from 'fs';
|
|
|
14
14
|
import { lstatSync, realpathSync, readdirSync } from 'fs';
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
16
|
|
|
17
|
-
var version$1 = "2.
|
|
17
|
+
var version$1 = "2.42.3";
|
|
18
18
|
|
|
19
19
|
var charToInteger = {};
|
|
20
20
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -1465,6 +1465,7 @@ function relative(from, to) {
|
|
|
1465
1465
|
const ArrowFunctionExpression$1 = 'ArrowFunctionExpression';
|
|
1466
1466
|
const BlockStatement$1 = 'BlockStatement';
|
|
1467
1467
|
const CallExpression$1 = 'CallExpression';
|
|
1468
|
+
const ChainExpression$1 = 'ChainExpression';
|
|
1468
1469
|
const ExpressionStatement$1 = 'ExpressionStatement';
|
|
1469
1470
|
const Identifier$1 = 'Identifier';
|
|
1470
1471
|
const ImportDefaultSpecifier$1 = 'ImportDefaultSpecifier';
|
|
@@ -9430,11 +9431,11 @@ function getPluginWithTimers(plugin, index) {
|
|
|
9430
9431
|
timerLabel += ` - ${hook}`;
|
|
9431
9432
|
timedPlugin[hook] = function () {
|
|
9432
9433
|
timeStart(timerLabel, 4);
|
|
9433
|
-
|
|
9434
|
+
let result = plugin[hook].apply(this === timedPlugin ? plugin : this, arguments);
|
|
9434
9435
|
timeEnd(timerLabel, 4);
|
|
9435
9436
|
if (result && typeof result.then === 'function') {
|
|
9436
9437
|
timeStart(`${timerLabel} (async)`, 4);
|
|
9437
|
-
result.then(() => timeEnd(`${timerLabel} (async)`, 4));
|
|
9438
|
+
result = result.then(() => timeEnd(`${timerLabel} (async)`, 4));
|
|
9438
9439
|
}
|
|
9439
9440
|
return result;
|
|
9440
9441
|
};
|
|
@@ -17830,8 +17831,28 @@ function writeFile(dest, data) {
|
|
|
17830
17831
|
});
|
|
17831
17832
|
}
|
|
17832
17833
|
|
|
17833
|
-
|
|
17834
|
-
|
|
17834
|
+
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions) {
|
|
17835
|
+
let skipped = null;
|
|
17836
|
+
let replaceContext = null;
|
|
17837
|
+
if (skip) {
|
|
17838
|
+
skipped = new Set();
|
|
17839
|
+
for (const skippedCall of skip) {
|
|
17840
|
+
if (source === skippedCall.source && importer === skippedCall.importer) {
|
|
17841
|
+
skipped.add(skippedCall.plugin);
|
|
17842
|
+
}
|
|
17843
|
+
}
|
|
17844
|
+
replaceContext = (pluginContext, plugin) => ({
|
|
17845
|
+
...pluginContext,
|
|
17846
|
+
resolve: (source, importer, { custom, skipSelf } = BLANK) => {
|
|
17847
|
+
return moduleLoaderResolveId(source, importer, custom, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
17848
|
+
}
|
|
17849
|
+
});
|
|
17850
|
+
}
|
|
17851
|
+
return pluginDriver.hookFirst('resolveId', [source, importer, { custom: customOptions }], replaceContext, skipped);
|
|
17852
|
+
}
|
|
17853
|
+
|
|
17854
|
+
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions) {
|
|
17855
|
+
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions);
|
|
17835
17856
|
if (pluginResult != null)
|
|
17836
17857
|
return pluginResult;
|
|
17837
17858
|
// external modules (non-entry modules that start with neither '.' or '/')
|
|
@@ -18129,6 +18150,11 @@ class ModuleLoader {
|
|
|
18129
18150
|
this.indexedEntryModules = [];
|
|
18130
18151
|
this.latestLoadModulesPromise = Promise.resolve();
|
|
18131
18152
|
this.nextEntryModuleIndex = 0;
|
|
18153
|
+
this.resolveId = async (source, importer, customOptions, skip = null) => {
|
|
18154
|
+
return this.addDefaultsToResolvedId(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
18155
|
+
? false
|
|
18156
|
+
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions), importer, source));
|
|
18157
|
+
};
|
|
18132
18158
|
this.hasModuleSideEffects = options.treeshake
|
|
18133
18159
|
? options.treeshake.moduleSideEffects
|
|
18134
18160
|
: () => true;
|
|
@@ -18182,11 +18208,6 @@ class ModuleLoader {
|
|
|
18182
18208
|
}
|
|
18183
18209
|
return module;
|
|
18184
18210
|
}
|
|
18185
|
-
async resolveId(source, importer, customOptions, skip = null) {
|
|
18186
|
-
return this.addDefaultsToResolvedId(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
18187
|
-
? false
|
|
18188
|
-
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, skip, customOptions), importer, source));
|
|
18189
|
-
}
|
|
18190
18211
|
addDefaultsToResolvedId(resolvedId) {
|
|
18191
18212
|
var _a, _b;
|
|
18192
18213
|
if (!resolvedId) {
|
|
@@ -18384,7 +18405,7 @@ class ModuleLoader {
|
|
|
18384
18405
|
return resolvedId;
|
|
18385
18406
|
}
|
|
18386
18407
|
async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore) {
|
|
18387
|
-
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, null, EMPTY_OBJECT);
|
|
18408
|
+
const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT);
|
|
18388
18409
|
if (resolveIdResult == null) {
|
|
18389
18410
|
return error(implicitlyLoadedBefore === null
|
|
18390
18411
|
? errUnresolvedEntry(unresolvedId)
|
|
@@ -18458,87 +18479,84 @@ function getDeprecatedContextHandler(handler, handlerName, newHandlerName, plugi
|
|
|
18458
18479
|
return handler(...args);
|
|
18459
18480
|
});
|
|
18460
18481
|
}
|
|
18461
|
-
function
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
existingPluginNames.has(plugin.name)) {
|
|
18469
|
-
cacheable = false;
|
|
18470
|
-
}
|
|
18471
|
-
else {
|
|
18472
|
-
existingPluginNames.add(plugin.name);
|
|
18473
|
-
}
|
|
18474
|
-
}
|
|
18475
|
-
let cacheInstance;
|
|
18476
|
-
if (!pluginCache) {
|
|
18477
|
-
cacheInstance = NO_CACHE;
|
|
18478
|
-
}
|
|
18479
|
-
else if (cacheable) {
|
|
18480
|
-
const cacheKey = plugin.cacheKey || plugin.name;
|
|
18481
|
-
cacheInstance = createPluginCache(pluginCache[cacheKey] || (pluginCache[cacheKey] = Object.create(null)));
|
|
18482
|
+
function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
|
|
18483
|
+
let cacheable = true;
|
|
18484
|
+
if (typeof plugin.cacheKey !== 'string') {
|
|
18485
|
+
if (plugin.name.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
|
|
18486
|
+
plugin.name.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX) ||
|
|
18487
|
+
existingPluginNames.has(plugin.name)) {
|
|
18488
|
+
cacheable = false;
|
|
18482
18489
|
}
|
|
18483
18490
|
else {
|
|
18484
|
-
|
|
18491
|
+
existingPluginNames.add(plugin.name);
|
|
18485
18492
|
}
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18494
|
-
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18501
|
-
|
|
18502
|
-
getFileName: fileEmitter.getFileName,
|
|
18503
|
-
getModuleIds: () => graph.modulesById.keys(),
|
|
18504
|
-
getModuleInfo: graph.getModuleInfo,
|
|
18505
|
-
getWatchFiles: () => Object.keys(graph.watchFiles),
|
|
18506
|
-
isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
|
|
18507
|
-
meta: {
|
|
18508
|
-
rollupVersion: version$1,
|
|
18509
|
-
watchMode: graph.watchMode
|
|
18510
|
-
},
|
|
18511
|
-
get moduleIds() {
|
|
18512
|
-
function* wrappedModuleIds() {
|
|
18513
|
-
warnDeprecation({
|
|
18514
|
-
message: `Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`,
|
|
18515
|
-
plugin: plugin.name
|
|
18516
|
-
}, false, options);
|
|
18517
|
-
yield* moduleIds;
|
|
18518
|
-
}
|
|
18519
|
-
const moduleIds = graph.modulesById.keys();
|
|
18520
|
-
return wrappedModuleIds();
|
|
18521
|
-
},
|
|
18522
|
-
parse: graph.contextParse.bind(graph),
|
|
18523
|
-
resolve(source, importer, { custom, skipSelf } = BLANK) {
|
|
18524
|
-
return graph.moduleLoader.resolveId(source, importer, custom, skipSelf ? pidx : null);
|
|
18525
|
-
},
|
|
18526
|
-
resolveId: getDeprecatedContextHandler((source, importer) => graph.moduleLoader
|
|
18527
|
-
.resolveId(source, importer, BLANK)
|
|
18528
|
-
.then(resolveId => resolveId && resolveId.id), 'resolveId', 'resolve', plugin.name, true, options),
|
|
18529
|
-
setAssetSource: fileEmitter.setAssetSource,
|
|
18530
|
-
warn(warning) {
|
|
18531
|
-
if (typeof warning === 'string')
|
|
18532
|
-
warning = { message: warning };
|
|
18533
|
-
if (warning.code)
|
|
18534
|
-
warning.pluginCode = warning.code;
|
|
18535
|
-
warning.code = 'PLUGIN_WARNING';
|
|
18536
|
-
warning.plugin = plugin.name;
|
|
18537
|
-
options.onwarn(warning);
|
|
18493
|
+
}
|
|
18494
|
+
let cacheInstance;
|
|
18495
|
+
if (!pluginCache) {
|
|
18496
|
+
cacheInstance = NO_CACHE;
|
|
18497
|
+
}
|
|
18498
|
+
else if (cacheable) {
|
|
18499
|
+
const cacheKey = plugin.cacheKey || plugin.name;
|
|
18500
|
+
cacheInstance = createPluginCache(pluginCache[cacheKey] || (pluginCache[cacheKey] = Object.create(null)));
|
|
18501
|
+
}
|
|
18502
|
+
else {
|
|
18503
|
+
cacheInstance = getCacheForUncacheablePlugin(plugin.name);
|
|
18504
|
+
}
|
|
18505
|
+
const context = {
|
|
18506
|
+
addWatchFile(id) {
|
|
18507
|
+
if (graph.phase >= BuildPhase.GENERATE) {
|
|
18508
|
+
return this.error(errInvalidRollupPhaseForAddWatchFile());
|
|
18538
18509
|
}
|
|
18539
|
-
|
|
18540
|
-
|
|
18510
|
+
graph.watchFiles[id] = true;
|
|
18511
|
+
},
|
|
18512
|
+
cache: cacheInstance,
|
|
18513
|
+
emitAsset: getDeprecatedContextHandler((name, source) => fileEmitter.emitFile({ type: 'asset', name, source }), 'emitAsset', 'emitFile', plugin.name, true, options),
|
|
18514
|
+
emitChunk: getDeprecatedContextHandler((id, options) => fileEmitter.emitFile({ type: 'chunk', id, name: options && options.name }), 'emitChunk', 'emitFile', plugin.name, true, options),
|
|
18515
|
+
emitFile: fileEmitter.emitFile,
|
|
18516
|
+
error(err) {
|
|
18517
|
+
return throwPluginError(err, plugin.name);
|
|
18518
|
+
},
|
|
18519
|
+
getAssetFileName: getDeprecatedContextHandler(fileEmitter.getFileName, 'getAssetFileName', 'getFileName', plugin.name, true, options),
|
|
18520
|
+
getChunkFileName: getDeprecatedContextHandler(fileEmitter.getFileName, 'getChunkFileName', 'getFileName', plugin.name, true, options),
|
|
18521
|
+
getFileName: fileEmitter.getFileName,
|
|
18522
|
+
getModuleIds: () => graph.modulesById.keys(),
|
|
18523
|
+
getModuleInfo: graph.getModuleInfo,
|
|
18524
|
+
getWatchFiles: () => Object.keys(graph.watchFiles),
|
|
18525
|
+
isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
|
|
18526
|
+
meta: {
|
|
18527
|
+
rollupVersion: version$1,
|
|
18528
|
+
watchMode: graph.watchMode
|
|
18529
|
+
},
|
|
18530
|
+
get moduleIds() {
|
|
18531
|
+
function* wrappedModuleIds() {
|
|
18532
|
+
warnDeprecation({
|
|
18533
|
+
message: `Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`,
|
|
18534
|
+
plugin: plugin.name
|
|
18535
|
+
}, false, options);
|
|
18536
|
+
yield* moduleIds;
|
|
18537
|
+
}
|
|
18538
|
+
const moduleIds = graph.modulesById.keys();
|
|
18539
|
+
return wrappedModuleIds();
|
|
18540
|
+
},
|
|
18541
|
+
parse: graph.contextParse.bind(graph),
|
|
18542
|
+
resolve(source, importer, { custom, skipSelf } = BLANK) {
|
|
18543
|
+
return graph.moduleLoader.resolveId(source, importer, custom, skipSelf ? [{ importer, plugin, source }] : null);
|
|
18544
|
+
},
|
|
18545
|
+
resolveId: getDeprecatedContextHandler((source, importer) => graph.moduleLoader
|
|
18546
|
+
.resolveId(source, importer, BLANK)
|
|
18547
|
+
.then(resolveId => resolveId && resolveId.id), 'resolveId', 'resolve', plugin.name, true, options),
|
|
18548
|
+
setAssetSource: fileEmitter.setAssetSource,
|
|
18549
|
+
warn(warning) {
|
|
18550
|
+
if (typeof warning === 'string')
|
|
18551
|
+
warning = { message: warning };
|
|
18552
|
+
if (warning.code)
|
|
18553
|
+
warning.pluginCode = warning.code;
|
|
18554
|
+
warning.code = 'PLUGIN_WARNING';
|
|
18555
|
+
warning.plugin = plugin.name;
|
|
18556
|
+
options.onwarn(warning);
|
|
18557
|
+
}
|
|
18541
18558
|
};
|
|
18559
|
+
return context;
|
|
18542
18560
|
}
|
|
18543
18561
|
|
|
18544
18562
|
const inputHookNames = {
|
|
@@ -18565,6 +18583,7 @@ class PluginDriver {
|
|
|
18565
18583
|
constructor(graph, options, userPlugins, pluginCache, basePluginDriver) {
|
|
18566
18584
|
this.graph = graph;
|
|
18567
18585
|
this.options = options;
|
|
18586
|
+
this.pluginContexts = new Map();
|
|
18568
18587
|
warnDeprecatedHooks(userPlugins, options);
|
|
18569
18588
|
this.pluginCache = pluginCache;
|
|
18570
18589
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
@@ -18573,7 +18592,10 @@ class PluginDriver {
|
|
|
18573
18592
|
this.finaliseAssets = this.fileEmitter.assertAssetsFinalized;
|
|
18574
18593
|
this.setOutputBundle = this.fileEmitter.setOutputBundle;
|
|
18575
18594
|
this.plugins = userPlugins.concat(basePluginDriver ? basePluginDriver.plugins : []);
|
|
18576
|
-
|
|
18595
|
+
const existingPluginNames = new Set();
|
|
18596
|
+
for (const plugin of this.plugins) {
|
|
18597
|
+
this.pluginContexts.set(plugin, getPluginContext(plugin, pluginCache, graph, options, this.fileEmitter, existingPluginNames));
|
|
18598
|
+
}
|
|
18577
18599
|
if (basePluginDriver) {
|
|
18578
18600
|
for (const plugin of userPlugins) {
|
|
18579
18601
|
for (const hook of inputHooks) {
|
|
@@ -18588,23 +18610,23 @@ class PluginDriver {
|
|
|
18588
18610
|
return new PluginDriver(this.graph, this.options, plugins, this.pluginCache, this);
|
|
18589
18611
|
}
|
|
18590
18612
|
// chains, first non-null result stops and returns
|
|
18591
|
-
hookFirst(hookName, args, replaceContext,
|
|
18613
|
+
hookFirst(hookName, args, replaceContext, skipped) {
|
|
18592
18614
|
let promise = Promise.resolve(undefined);
|
|
18593
|
-
for (
|
|
18594
|
-
if (
|
|
18615
|
+
for (const plugin of this.plugins) {
|
|
18616
|
+
if (skipped && skipped.has(plugin))
|
|
18595
18617
|
continue;
|
|
18596
18618
|
promise = promise.then(result => {
|
|
18597
18619
|
if (result != null)
|
|
18598
18620
|
return result;
|
|
18599
|
-
return this.runHook(hookName, args,
|
|
18621
|
+
return this.runHook(hookName, args, plugin, false, replaceContext);
|
|
18600
18622
|
});
|
|
18601
18623
|
}
|
|
18602
18624
|
return promise;
|
|
18603
18625
|
}
|
|
18604
18626
|
// chains synchronously, first non-null result stops and returns
|
|
18605
18627
|
hookFirstSync(hookName, args, replaceContext) {
|
|
18606
|
-
for (
|
|
18607
|
-
const result = this.runHookSync(hookName, args,
|
|
18628
|
+
for (const plugin of this.plugins) {
|
|
18629
|
+
const result = this.runHookSync(hookName, args, plugin, replaceContext);
|
|
18608
18630
|
if (result != null)
|
|
18609
18631
|
return result;
|
|
18610
18632
|
}
|
|
@@ -18613,8 +18635,8 @@ class PluginDriver {
|
|
|
18613
18635
|
// parallel, ignores returns
|
|
18614
18636
|
hookParallel(hookName, args, replaceContext) {
|
|
18615
18637
|
const promises = [];
|
|
18616
|
-
for (
|
|
18617
|
-
const hookPromise = this.runHook(hookName, args,
|
|
18638
|
+
for (const plugin of this.plugins) {
|
|
18639
|
+
const hookPromise = this.runHook(hookName, args, plugin, false, replaceContext);
|
|
18618
18640
|
if (!hookPromise)
|
|
18619
18641
|
continue;
|
|
18620
18642
|
promises.push(hookPromise);
|
|
@@ -18624,35 +18646,35 @@ class PluginDriver {
|
|
|
18624
18646
|
// chains, reduces returned value, handling the reduced value as the first hook argument
|
|
18625
18647
|
hookReduceArg0(hookName, [arg0, ...rest], reduce, replaceContext) {
|
|
18626
18648
|
let promise = Promise.resolve(arg0);
|
|
18627
|
-
for (
|
|
18649
|
+
for (const plugin of this.plugins) {
|
|
18628
18650
|
promise = promise.then(arg0 => {
|
|
18629
18651
|
const args = [arg0, ...rest];
|
|
18630
|
-
const hookPromise = this.runHook(hookName, args,
|
|
18652
|
+
const hookPromise = this.runHook(hookName, args, plugin, false, replaceContext);
|
|
18631
18653
|
if (!hookPromise)
|
|
18632
18654
|
return arg0;
|
|
18633
|
-
return hookPromise.then(result => reduce.call(this.pluginContexts
|
|
18655
|
+
return hookPromise.then(result => reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin));
|
|
18634
18656
|
});
|
|
18635
18657
|
}
|
|
18636
18658
|
return promise;
|
|
18637
18659
|
}
|
|
18638
18660
|
// chains synchronously, reduces returned value, handling the reduced value as the first hook argument
|
|
18639
18661
|
hookReduceArg0Sync(hookName, [arg0, ...rest], reduce, replaceContext) {
|
|
18640
|
-
for (
|
|
18662
|
+
for (const plugin of this.plugins) {
|
|
18641
18663
|
const args = [arg0, ...rest];
|
|
18642
|
-
const result = this.runHookSync(hookName, args,
|
|
18643
|
-
arg0 = reduce.call(this.pluginContexts
|
|
18664
|
+
const result = this.runHookSync(hookName, args, plugin, replaceContext);
|
|
18665
|
+
arg0 = reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin);
|
|
18644
18666
|
}
|
|
18645
18667
|
return arg0;
|
|
18646
18668
|
}
|
|
18647
18669
|
// chains, reduces returned value to type T, handling the reduced value separately. permits hooks as values.
|
|
18648
18670
|
hookReduceValue(hookName, initialValue, args, reduce, replaceContext) {
|
|
18649
18671
|
let promise = Promise.resolve(initialValue);
|
|
18650
|
-
for (
|
|
18672
|
+
for (const plugin of this.plugins) {
|
|
18651
18673
|
promise = promise.then(value => {
|
|
18652
|
-
const hookPromise = this.runHook(hookName, args,
|
|
18674
|
+
const hookPromise = this.runHook(hookName, args, plugin, true, replaceContext);
|
|
18653
18675
|
if (!hookPromise)
|
|
18654
18676
|
return value;
|
|
18655
|
-
return hookPromise.then(result => reduce.call(this.pluginContexts
|
|
18677
|
+
return hookPromise.then(result => reduce.call(this.pluginContexts.get(plugin), value, result, plugin));
|
|
18656
18678
|
});
|
|
18657
18679
|
}
|
|
18658
18680
|
return promise;
|
|
@@ -18660,32 +18682,31 @@ class PluginDriver {
|
|
|
18660
18682
|
// chains synchronously, reduces returned value to type T, handling the reduced value separately. permits hooks as values.
|
|
18661
18683
|
hookReduceValueSync(hookName, initialValue, args, reduce, replaceContext) {
|
|
18662
18684
|
let acc = initialValue;
|
|
18663
|
-
for (
|
|
18664
|
-
const result = this.runHookSync(hookName, args,
|
|
18665
|
-
acc = reduce.call(this.pluginContexts
|
|
18685
|
+
for (const plugin of this.plugins) {
|
|
18686
|
+
const result = this.runHookSync(hookName, args, plugin, replaceContext);
|
|
18687
|
+
acc = reduce.call(this.pluginContexts.get(plugin), acc, result, plugin);
|
|
18666
18688
|
}
|
|
18667
18689
|
return acc;
|
|
18668
18690
|
}
|
|
18669
18691
|
// chains, ignores returns
|
|
18670
18692
|
hookSeq(hookName, args, replaceContext) {
|
|
18671
18693
|
let promise = Promise.resolve();
|
|
18672
|
-
for (
|
|
18673
|
-
promise = promise.then(() => this.runHook(hookName, args,
|
|
18694
|
+
for (const plugin of this.plugins) {
|
|
18695
|
+
promise = promise.then(() => this.runHook(hookName, args, plugin, false, replaceContext));
|
|
18674
18696
|
}
|
|
18675
18697
|
return promise;
|
|
18676
18698
|
}
|
|
18677
18699
|
// chains synchronously, ignores returns
|
|
18678
18700
|
hookSeqSync(hookName, args, replaceContext) {
|
|
18679
|
-
for (
|
|
18680
|
-
this.runHookSync(hookName, args,
|
|
18701
|
+
for (const plugin of this.plugins) {
|
|
18702
|
+
this.runHookSync(hookName, args, plugin, replaceContext);
|
|
18681
18703
|
}
|
|
18682
18704
|
}
|
|
18683
|
-
runHook(hookName, args,
|
|
18684
|
-
const plugin = this.plugins[pluginIndex];
|
|
18705
|
+
runHook(hookName, args, plugin, permitValues, hookContext) {
|
|
18685
18706
|
const hook = plugin[hookName];
|
|
18686
18707
|
if (!hook)
|
|
18687
18708
|
return undefined;
|
|
18688
|
-
let context = this.pluginContexts
|
|
18709
|
+
let context = this.pluginContexts.get(plugin);
|
|
18689
18710
|
if (hookContext) {
|
|
18690
18711
|
context = hookContext(context, plugin);
|
|
18691
18712
|
}
|
|
@@ -18705,15 +18726,14 @@ class PluginDriver {
|
|
|
18705
18726
|
* Run a sync plugin hook and return the result.
|
|
18706
18727
|
* @param hookName Name of the plugin hook. Must be in `PluginHooks`.
|
|
18707
18728
|
* @param args Arguments passed to the plugin hook.
|
|
18708
|
-
* @param
|
|
18729
|
+
* @param plugin The acutal plugin
|
|
18709
18730
|
* @param hookContext When passed, the plugin context can be overridden.
|
|
18710
18731
|
*/
|
|
18711
|
-
runHookSync(hookName, args,
|
|
18712
|
-
const plugin = this.plugins[pluginIndex];
|
|
18732
|
+
runHookSync(hookName, args, plugin, hookContext) {
|
|
18713
18733
|
const hook = plugin[hookName];
|
|
18714
18734
|
if (!hook)
|
|
18715
18735
|
return undefined;
|
|
18716
|
-
let context = this.pluginContexts
|
|
18736
|
+
let context = this.pluginContexts.get(plugin);
|
|
18717
18737
|
if (hookContext) {
|
|
18718
18738
|
context = hookContext(context, plugin);
|
|
18719
18739
|
}
|
|
@@ -19021,7 +19041,7 @@ function markPureNode(node, comment) {
|
|
|
19021
19041
|
else {
|
|
19022
19042
|
node._rollupAnnotations = [{ comment }];
|
|
19023
19043
|
}
|
|
19024
|
-
|
|
19044
|
+
while (node.type === ExpressionStatement$1 || node.type === ChainExpression$1) {
|
|
19025
19045
|
node = node.expression;
|
|
19026
19046
|
}
|
|
19027
19047
|
if (node.type === CallExpression$1 || node.type === NewExpression$1) {
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED